···11+{
22+ pkgs ? import <nixpkgs> { },
33+ outdir ? "bootstrap-tests",
44+ ...
55+}@args:
66+let
77+ # determine the list of available test names by importing once (outdir irrelevant)
88+ names = map (x: x.name) (import ./_bootstrap-tests.nix args).buildInputs;
99+1010+ # for each name we re-import the test definitions with a unique outdir
1111+ perTests = map (
1212+ name:
1313+ let
1414+ shellFor = import ./_bootstrap-tests.nix (args // { outdir = "${outdir}/${name}"; });
1515+ matches = builtins.filter (x: x.name == name) shellFor.buildInputs;
1616+ in
1717+ builtins.head matches
1818+ ) names;
1919+2020+ # create a single shell application that runs every named test in parallel
2121+ test-all = pkgs.writeShellApplication {
2222+ name = "test-all";
2323+ runtimeInputs = perTests;
2424+ text = ''
2525+ set -euo pipefail
2626+2727+ # build a space-separated list of test names supplied by Nix
2828+ names="${pkgs.lib.concatStringsSep " " names}"
2929+3030+ # pmap will record pid:name pairs so we can identify failures later
3131+ pmap=""
3232+3333+ for name in $names; do
3434+ rm -rf "${outdir}/$name"
3535+ mkdir -p "${outdir}/$name"
3636+ (
3737+ set -v
3838+ echo "Boostrap $name"
3939+ "$name" >&2> "${outdir}/$name/output.log"
4040+ ) &
4141+ pid=$!
4242+ pmap="$pmap $pid:$name"
4343+ done
4444+4545+ failures=""
4646+ for entry in $pmap; do
4747+ pid="''${entry%%:*}"
4848+ name="''${entry#*:}"
4949+ echo -n "Waiting for $name"
5050+ if wait "$pid"; then
5151+ echo " [SUCCEED]"
5252+ else
5353+ echo " [FAILED]"
5454+ failures="$failures $name"
5555+ fi
5656+ done
5757+5858+ if [ -n "$failures" ]; then
5959+ echo "FAILURES: $failures"
6060+ for name in $failures; do
6161+ echo "=== $name ==="
6262+ cat "${outdir}/$name/output.log" || true
6363+ echo
6464+ done
6565+ exit 1
6666+ fi
6767+ '';
6868+ };
6969+in
7070+pkgs.mkShell {
7171+ buildInputs = [ test-all ];
7272+}
+1
docs/src/content/docs/reference/bootstrap.mdx
···18181919| App | Description |
2020| --- | --- |
2121+| **`write-lock`** | Detect existing lock file and delegate to one of the following as appropriate; requires a lock file __already present__ |
2122| `write-flake` | Generate a `flake.nix` file |
2223| `write-inputs` | Generate an `inputs.nix` expression (for debugging) |
2324| `write-unflake` | Generate `unflake.nix` via [unflake](https://codeberg.org/goldstein/unflake) |