nix-helpers: d24abb84496572885e15f94585dc57f7fd879900
1: { bash, coreutils, lib, writeScript }:
2:
3: toFail:
4: lib.overrideDerivation toFail (old: {
5: builder = writeScript "toFail-${old.name}" ''
6: #!${bash}/bin/bash
7: echo "Ensuring that ${old.name} fails to build" 1>&2
8: if "${old.builder}" ${builtins.concatStringsSep " " old.args}
9: then
10: echo "Error: ${old.name} succeeded but should have failed" 1>&2
11: exit 1
12: fi
13:
14: echo "isBroken: ${old.name} failed to build, as we expected" 1>&2
15:
16: echo "Generating outputs [$outputs] to appease Nix" 1>&2
17: MADE=0
18: for O_STRING in $outputs
19: do
20: O_PATH="${"$" + "{!O_STRING}"}"
21: if [[ -e "$O_PATH" ]]
22: then
23: echo "Cleaning up '$O_PATH' after build" 1>&2
24: "${coreutils}/bin/rm" -rf "$O_PATH"
25: fi
26:
27: echo "Failed as expected" > "$O_PATH"
28: MADE=$(( MADE + 1 ))
29: done
30: [[ "$MADE" -gt 0 ]] || {
31: echo "Didn't spot any outputs, attempting to make 'out' ($out)" 1>&2
32: if [[ -e "$out" ]]
33: then
34: echo "Cleaning up 'out' after build" 1>&2
35: "${coreutils}/bin/rm" -rf "$out"
36: fi
37: echo "Failed as expected" > "$out"
38: }
39: '';
40: })
Generated by git2html.