Generate flake.nix from module options. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic nix inputs
at main 72 lines 1.9 kB view raw
1{ 2 pkgs ? import <nixpkgs> { }, 3 outdir ? "bootstrap-tests", 4 ... 5}@args: 6let 7 # determine the list of available test names by importing once (outdir irrelevant) 8 names = map (x: x.name) (import ./_bootstrap-tests.nix args).buildInputs; 9 10 # for each name we re-import the test definitions with a unique outdir 11 perTests = map ( 12 name: 13 let 14 shellFor = import ./_bootstrap-tests.nix (args // { outdir = "${outdir}/${name}"; }); 15 matches = builtins.filter (x: x.name == name) shellFor.buildInputs; 16 in 17 builtins.head matches 18 ) names; 19 20 # create a single shell application that runs every named test in parallel 21 test-all = pkgs.writeShellApplication { 22 name = "test-all"; 23 runtimeInputs = perTests; 24 text = '' 25 set -euo pipefail 26 27 # build a space-separated list of test names supplied by Nix 28 names="${pkgs.lib.concatStringsSep " " names}" 29 30 # pmap will record pid:name pairs so we can identify failures later 31 pmap="" 32 33 for name in $names; do 34 rm -rf "${outdir}/$name" 35 mkdir -p "${outdir}/$name" 36 ( 37 set -v 38 echo "Boostrap $name" 39 "$name" >&2> "${outdir}/$name/output.log" 40 ) & 41 pid=$! 42 pmap="$pmap $pid:$name" 43 done 44 45 failures="" 46 for entry in $pmap; do 47 pid="''${entry%%:*}" 48 name="''${entry#*:}" 49 echo -n "Waiting for $name" 50 if wait "$pid"; then 51 echo " [SUCCEED]" 52 else 53 echo " [FAILED]" 54 failures="$failures $name" 55 fi 56 done 57 58 if [ -n "$failures" ]; then 59 echo "FAILURES: $failures" 60 for name in $failures; do 61 echo "=== $name ===" 62 cat "${outdir}/$name/output.log" || true 63 echo 64 done 65 exit 1 66 fi 67 ''; 68 }; 69in 70pkgs.mkShell { 71 buildInputs = [ test-all ]; 72}