1 { lib, stdenv, runCommand }:
5 bad-shebang = stdenv.mkDerivation {
10 echo "#!/bin/sh" > $out/bin/test
11 echo "echo -n hello" >> $out/bin/test
12 chmod +x $out/bin/test
15 assertion = "grep -v '^#!/bin/sh' $out/bin/test > /dev/null";
19 ignores-nix-store = stdenv.mkDerivation {
20 name = "ignores-nix-store";
24 echo "#!$NIX_STORE/path/to/sh" > $out/bin/test
25 echo "echo -n hello" >> $out/bin/test
26 chmod +x $out/bin/test
29 assertion = "grep \"^#!$NIX_STORE/path/to/sh\" $out/bin/test > /dev/null";
33 in runCommand "patch-shebangs-test" {
34 passthru = { inherit (tests) bad-shebang ignores-nix-store; };
35 meta.platforms = lib.platforms.all;
42 echo -n "... $name: " >&2
45 (out=$testout eval "$assertion") || rc=1
47 if [ "$rc" -eq 0 ]; then
56 echo "checking whether patchShebangs works properly... ">&2
59 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (_: test: ''
60 validate "${test.name}" "${test}" ${lib.escapeShellArg test.assertion} || fail=1