Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 50 lines 1.3 kB view raw
1{ 2 coreutils, 3 flattenReferencesGraph, 4 lib, 5 jq, 6 runCommand, 7}: 8{ 9 closureRoots, 10 excludePaths ? [ ], 11 # This could be a path to (or a derivation producing a path to) 12 # a json file containing the pipeline 13 pipeline ? [ ], 14 debug ? false, 15}: 16if closureRoots == [ ] then 17 builtins.toFile "docker-layers-empty" "[]" 18else 19 runCommand "docker-layers" 20 { 21 __structuredAttrs = true; 22 # graph, exclude_paths and pipeline are expected by the 23 # flatten_references_graph executable. 24 exportReferencesGraph.graph = closureRoots; 25 exclude_paths = excludePaths; 26 inherit pipeline; 27 nativeBuildInputs = [ 28 coreutils 29 flattenReferencesGraph 30 jq 31 ]; 32 } 33 '' 34 . .attrs.sh 35 36 flatten_references_graph_arg=.attrs.json 37 38 echo "pipeline: $pipeline" 39 40 if jq -e '.pipeline | type == "string"' .attrs.json; then 41 jq '. + { "pipeline": $pipeline[0] }' \ 42 --slurpfile pipeline "$pipeline" \ 43 .attrs.json > flatten_references_graph_arg.json 44 45 flatten_references_graph_arg=flatten_references_graph_arg.json 46 fi 47 48 ${lib.optionalString debug "export DEBUG=True"} 49 flatten_references_graph "$flatten_references_graph_arg" > ''${outputs[out]} 50 ''