ci.nix (1654B)
1 # This file provides all the buildable and cacheable packages and 2 # package outputs in your package set. These are what gets built by CI, 3 # so if you correctly mark packages as 4 # 5 # - broken (using `meta.broken`), 6 # - unfree (using `meta.license.free`), and 7 # - locally built (using `preferLocalBuild`) 8 # 9 # then your CI will be able to build and cache only those packages for 10 # which this is possible. 11 12 { 13 pkgs ? import <nixpkgs> { }, 14 }: 15 16 with builtins; 17 let 18 isReserved = n: n == "lib" || n == "overlays" || n == "modules"; 19 isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; 20 isBuildable = 21 p: !(p.meta.broken or false) && !(p.meta.skip.ci or false) && p.meta.license.free or true; 22 isCacheable = p: !(p.preferLocalBuild or false); 23 shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; 24 25 nameValuePair = n: v: { 26 name = n; 27 value = v; 28 }; 29 30 concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); 31 32 flattenPkgs = 33 s: 34 let 35 f = 36 p: 37 if shouldRecurseForDerivations p then 38 flattenPkgs p 39 else if isDerivation p then 40 [ p ] 41 else 42 [ ]; 43 in 44 concatMap f (attrValues s); 45 46 outputsOf = p: map (o: p.${o}) p.outputs; 47 48 nurAttrs = import ./default.nix { inherit pkgs; }; 49 50 nurPkgs = flattenPkgs ( 51 listToAttrs ( 52 map (n: nameValuePair n nurAttrs.${n}) (filter (n: !isReserved n) (attrNames nurAttrs)) 53 ) 54 ); 55 in 56 rec { 57 buildPkgs = filter isBuildable nurPkgs; 58 cachePkgs = filter isCacheable buildPkgs; 59 60 buildOutputs = concatMap outputsOf buildPkgs; 61 cacheOutputs = concatMap outputsOf cachePkgs; 62 }