ci.nix (2617B)
1 # This file provides all the buildable and cacheable packages and 2 # package outputs in you 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 { sources ? import ./nix 13 , pkgs ? sources.pkgs { } 14 , pkgs-unstable ? sources.pkgs-unstable { } 15 , nixpkgs ? sources.nixpkgs { } 16 }: 17 18 with builtins; 19 let 20 isReserved = n: n == "lib" || n == "overlays" || n == "modules"; 21 isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; 22 isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; 23 isCacheable = p: !(p.preferLocalBuild or false); 24 shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; 25 nameValuePair = n: v: { name = n; value = v; }; 26 concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); 27 flattenPkgs = s: 28 let 29 f = p: 30 if shouldRecurseForDerivations p then flattenPkgs p 31 else if isDerivation p then [ p ] 32 else [ ]; 33 in 34 concatMap f (attrValues s); 35 outputsOf = p: map (o: p.${o}) p.outputs; 36 nurAttrs = p: import ./nix/packages/default.nix { pkgs = p; }; 37 nurPkgs = p: 38 flattenPkgs ( 39 listToAttrs ( 40 map 41 (n: nameValuePair n (nurAttrs p).${n}) 42 ( 43 filter 44 (n: !isReserved n) 45 (attrNames (nurAttrs p)) 46 ) 47 ) 48 ); 49 nixosNurPkgs = nurPkgs pkgs; 50 nixosUnstableNurPkgs = nurPkgs pkgs-unstable; 51 nixpkgsNurPkgs = nurPkgs nixpkgs; 52 in 53 rec { 54 nixosBuildPkgs = filter isBuildable nixosNurPkgs; 55 nixosCachePkgs = filter isCacheable nixosBuildPkgs; 56 nixosUnstableBuildPkgs = filter isBuildable nixosUnstableNurPkgs; 57 nixosUnstableCachePkgs = filter isCacheable nixosUnstableBuildPkgs; 58 nixpkgsBuildPkgs = filter isBuildable nixpkgsNurPkgs; 59 nixpkgsCachePkgs = filter isCacheable nixpkgsBuildPkgs; 60 61 nixosBuildOutputs = concatMap outputsOf nixosBuildPkgs; 62 nixosCacheOutputs = concatMap outputsOf nixosCachePkgs; 63 nixosUnstableBuildOutputs = concatMap outputsOf nixosUnstableBuildPkgs; 64 nixosUnstableCacheOutputs = concatMap outputsOf nixosUnstableCachePkgs; 65 nixpkgsBuildOutputs = concatMap outputsOf nixpkgsBuildPkgs; 66 nixpkgsCacheOutputs = concatMap outputsOf nixpkgsCachePkgs; 67 68 buildOuputs = nixosBuildOutputs ++ nixosUnstableBuildOutputs ++ nixpkgsBuildOutputs; 69 cacheOutputs = nixosCacheOutputs ++ nixosUnstableCacheOutputs ++ nixpkgsCacheOutputs; 70 }