diff options
author | Alan Pearce | 2024-05-10 15:10:01 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-10 15:24:10 +0200 |
commit | d75a137c0fa6498ca6e35a0f257634ea3df1bec6 (patch) | |
tree | 1f40b38343c7b3b3c9288026585ec5c0644bde0a /ci.nix | |
download | nix-packages-d75a137c0fa6498ca6e35a0f257634ea3df1bec6.tar.lz nix-packages-d75a137c0fa6498ca6e35a0f257634ea3df1bec6.tar.zst nix-packages-d75a137c0fa6498ca6e35a0f257634ea3df1bec6.zip |
initial commit
Diffstat (limited to 'ci.nix')
-rw-r--r-- | ci.nix | 53 |
1 files changed, 53 insertions, 0 deletions
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 <nixpkgs> { } }: + +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; +} |