at master 1.2 kB view raw
1# This turns ./outpaths.nix into chunks of a fixed size. 2{ 3 lib ? import ../../lib, 4 path ? ../.., 5 # The file containing all available attribute paths, which are split into chunks here 6 attrpathFile, 7 chunkSize, 8 myChunk, 9 includeBroken, 10 systems, 11}: 12 13let 14 attrpaths = lib.importJSON attrpathFile; 15 myAttrpaths = lib.sublist (chunkSize * myChunk) chunkSize attrpaths; 16 17 unfiltered = import ./outpaths.nix { 18 inherit path; 19 inherit includeBroken systems; 20 }; 21 22 # Turns the unfiltered recursive attribute set into one that is limited to myAttrpaths 23 filtered = 24 let 25 recurse = 26 index: paths: attrs: 27 lib.mapAttrs ( 28 name: values: 29 if attrs ? ${name} then 30 if lib.any (value: lib.length value <= index + 1) values then 31 attrs.${name} 32 else 33 recurse (index + 1) values attrs.${name} 34 # Make sure nix-env recurses as well 35 // { 36 recurseForDerivations = true; 37 } 38 else 39 null 40 ) (lib.groupBy (a: lib.elemAt a index) paths); 41 in 42 recurse 0 myAttrpaths unfiltered; 43 44in 45filtered