From d75a137c0fa6498ca6e35a0f257634ea3df1bec6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 10 May 2024 15:10:01 +0200 Subject: initial commit --- .gitignore | 3 +++ LICENSE | 22 ++++++++++++++++++++++ README.md | 5 +++++ ci.nix | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ default.nix | 20 ++++++++++++++++++++ flake.lock | 27 ++++++++++++++++++++++++++ flake.nix | 22 ++++++++++++++++++++++ lib/default.nix | 7 +++++++ modules/default.nix | 5 +++++ overlay.nix | 15 +++++++++++++++ overlays/default.nix | 5 +++++ 11 files changed, 184 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 ci.nix create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 lib/default.nix create mode 100644 modules/default.nix create mode 100644 overlay.nix create mode 100644 overlays/default.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7dc3520 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +result +result-* + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..212cbf2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2018 Francesco Gazzetta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..81666eb --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +## README template + +# nix-packages + +**My personal [NUR](https://github.com/nix-community/NUR) repository** diff --git a/ci.nix b/ci.nix new file mode 100644 index 0000000..22b1352 --- /dev/null +++ b/ci.nix @@ -0,0 +1,53 @@ +# This file provides all the buildable and cacheable packages and +# package outputs in your package set. These are what gets built by CI, +# so if you correctly mark packages as +# +# - broken (using `meta.broken`), +# - unfree (using `meta.license.free`), and +# - locally built (using `preferLocalBuild`) +# +# then your CI will be able to build and cache only those packages for +# which this is possible. + +{ pkgs ? import { } }: + +with builtins; +let + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; + isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; + isCacheable = p: !(p.preferLocalBuild or false); + shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; + + nameValuePair = n: v: { name = n; value = v; }; + + concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); + + flattenPkgs = s: + let + f = p: + if shouldRecurseForDerivations p then flattenPkgs p + else if isDerivation p then [ p ] + else [ ]; + in + concatMap f (attrValues s); + + outputsOf = p: map (o: p.${o}) p.outputs; + + nurAttrs = import ./default.nix { inherit pkgs; }; + + nurPkgs = + flattenPkgs + (listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (filter (n: !isReserved n) + (attrNames nurAttrs)))); + +in +rec { + buildPkgs = filter isBuildable nurPkgs; + cachePkgs = filter isCacheable buildPkgs; + + buildOutputs = concatMap outputsOf buildPkgs; + cacheOutputs = concatMap outputsOf cachePkgs; +} diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..3846c24 --- /dev/null +++ b/default.nix @@ -0,0 +1,20 @@ +# This file describes your repository contents. +# It should return a set of nix derivations +# and optionally the special attributes `lib`, `modules` and `overlays`. +# It should NOT import . Instead, you should take pkgs as an argument. +# Having pkgs default to is fine though, and it lets you use short +# commands such as: +# nix-build -A mypackage + +{ pkgs ? import { } }: + +{ + # The `lib`, `modules`, and `overlays` names are special + lib = import ./lib { inherit pkgs; }; # functions + modules = import ./modules; # NixOS modules + overlays = import ./overlays; # nixpkgs overlays + + example-package = pkgs.callPackage ./pkgs/example-package { }; + # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { }; + # ... +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..78cf35d --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1712449641, + "narHash": "sha256-U9DDWMexN6o5Td2DznEgguh8TRIUnIl9levmit43GcI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "600b15aea1b36eeb43833a50b0e96579147099ff", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..81a143f --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + description = "My personal NUR repository"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" + "i686-linux" + "x86_64-darwin" + "aarch64-linux" + "armv6l-linux" + "armv7l-linux" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); + in + { + legacyPackages = forAllSystems (system: import ./default.nix { + pkgs = import nixpkgs { inherit system; }; + }); + packages = forAllSystems (system: nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system}); + }; +} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..a7fab1d --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,7 @@ +{ pkgs }: + +with pkgs.lib; { + # Add your library functions here + # + # hexint = x: hexvals.${toLower x}; +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..ff6c7c0 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,5 @@ +{ + # Add your NixOS modules here + # + # my-module = ./my-module; +} diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..bff7396 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,15 @@ +# You can use this file as a nixpkgs overlay. This is useful in the +# case where you don't want to add the whole NUR namespace to your +# configuration. + +self: super: +let + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + nameValuePair = n: v: { name = n; value = v; }; + nurAttrs = import ./default.nix { pkgs = super; }; + +in +builtins.listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (builtins.filter (n: !isReserved n) + (builtins.attrNames nurAttrs))) diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..0c2d870 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,5 @@ +{ + # Add your overlays here + # + # my-overlay = import ./my-overlay; +} -- cgit 1.4.1