diff --git a/ci.nix b/ci.nix index 22b1352761a22be6fb657c15eaa917f446d4394e..c0b404204c6e2288e5b9b719b5b818ccbf53050d 100644 --- a/ci.nix +++ b/ci.nix @@ -9,10 +9,12 @@ # # then your CI will be able to build and cache only those packages for # which this is possible. -{ pkgs ? import { } }: +{ 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; @@ -27,10 +29,10 @@ flattenPkgs = s: let f = p: if shouldRecurseForDerivations p then flattenPkgs p - else if isDerivation p then [ p ] - else [ ]; + else if isDerivation p then [p] + else []; in - concatMap f (attrValues s); + concatMap f (attrValues s); outputsOf = p: map (o: p.${o}) p.outputs; @@ -38,12 +40,13 @@ nurAttrs = import ./default.nix { inherit pkgs; }; nurPkgs = flattenPkgs - (listToAttrs - (map (n: nameValuePair n nurAttrs.${n}) - (filter (n: !isReserved n) - (attrNames nurAttrs)))); + (listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (filter (n: !isReserved n) + (attrNames nurAttrs)))); in + rec { buildPkgs = filter isBuildable nurPkgs; cachePkgs = filter isCacheable buildPkgs; diff --git a/default.nix b/default.nix index d6497c913792821327299a11d77f5266aa1e5d0b..46c40905331bc2233819c960917844bc49828cb1 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ # Having pkgs default to is fine though, and it lets you use short # commands such as: # nix-build -A mypackage -{ pkgs ? import { } }: +{ pkgs ? import {} }: { # The `lib`, `modules`, and `overlay` names are special @@ -18,3 +18,4 @@ example-package = pkgs.callPackage ./pkgs/example-package { }; # some-qt5-package = pkgs.libsForQt5.callPackage ./pkgs/some-qt5-package { }; # ... } + diff --git a/lib/default.nix b/lib/default.nix index a7fab1d2be536ab904a73a62194297419e60fdb4..53d6abe26e7c7a60e5e24d137a795b305197cbdc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,3 +5,4 @@ # Add your library functions here # # hexint = x: hexvals.${toLower x}; } + diff --git a/modules/default.nix b/modules/default.nix index ff6c7c0c429f0a38db757dd4f19e910dd5783deb..84ccb1a28fe36699f28375364e4b9986a1740120 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,3 +3,4 @@ # Add your NixOS modules here # # my-module = ./my-module; } + diff --git a/overlay.nix b/overlay.nix index bff7396a70d9bb78a88226f72f467f073eb18ef3..122729de0fdc9ac97ec903c039bb438d92958ad6 100644 --- a/overlay.nix +++ b/overlay.nix @@ -3,13 +3,16 @@ # 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 + + builtins.listToAttrs (map (n: nameValuePair n nurAttrs.${n}) - (builtins.filter (n: !isReserved n) - (builtins.attrNames nurAttrs))) + (builtins.filter (n: !isReserved n) + (builtins.attrNames nurAttrs))) diff --git a/overlays/default.nix b/overlays/default.nix index 0c2d870dddf36697ed50cda0acee515a8e9b994f..642fefaf88cb74d6275a9b9f7d9355f06f383f4e 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -3,3 +3,4 @@ # Add your overlays here # # my-overlay = import ./my-overlay; } + diff --git a/pkgs/example-package/default.nix b/pkgs/example-package/default.nix index 41e22df3354f7b6c68cc81bc5846a7b1db73aae4..2533adf6073229ea11cc244ffdf1c479109e9ccf 100644 --- a/pkgs/example-package/default.nix +++ b/pkgs/example-package/default.nix @@ -7,3 +7,4 @@ src = ./.; buildPhase = "echo echo Hello World > example"; installPhase = "install -Dm755 example $out"; } +