ci.nix (1680B)
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 { pkgs ? import <nixpkgs> { } }: 13 14 with builtins; 15 let 16 isReserved = n: n == "lib" || n == "overlays" || n == "modules"; 17 isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; 18 isBuildable = p: !(p.meta.broken or false) && !(p.meta.skip.ci or false) && p.meta.license.free or true; 19 isCacheable = p: !(p.preferLocalBuild or false); 20 shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; 21 22 nameValuePair = n: v: { name = n; value = v; }; 23 24 concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); 25 26 flattenPkgs = s: 27 let 28 f = p: 29 if shouldRecurseForDerivations p then flattenPkgs p 30 else if isDerivation p then [ p ] 31 else [ ]; 32 in 33 concatMap f (attrValues s); 34 35 outputsOf = p: map (o: p.${o}) p.outputs; 36 37 nurAttrs = import ./default.nix { inherit pkgs; }; 38 39 nurPkgs = 40 flattenPkgs ( 41 listToAttrs ( 42 map 43 (n: nameValuePair n nurAttrs.${n}) 44 ( 45 filter 46 (n: !isReserved n) 47 (attrNames nurAttrs) 48 ) 49 ) 50 ); 51 52 in 53 rec { 54 buildPkgs = filter isBuildable nurPkgs; 55 cachePkgs = filter isCacheable buildPkgs; 56 57 buildOutputs = concatMap outputsOf buildPkgs; 58 cacheOutputs = concatMap outputsOf cachePkgs; 59 }