summary refs log tree commit diff
path: root/pkgs/test/patch-shebangs/default.nix
blob: 3e68d96004f291b95211262540ff1308ed31a170 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{ stdenv, runCommand }:

let
  bad-shebang = stdenv.mkDerivation {
    name         = "bad-shebang";
    dontUnpack = true;
    installPhase = ''
      mkdir -p $out/bin
      echo "#!/bin/sh" > $out/bin/test
      echo "echo -n hello" >> $out/bin/test
      chmod +x $out/bin/test
    '';
  };
in runCommand "patch-shebangs-test" {
  passthru = { inherit bad-shebang; };
  meta.platforms = stdenv.lib.platforms.all;
} ''
  printf "checking whether patchShebangs works properly... ">&2
  if ! grep -q '^#!/bin/sh' ${bad-shebang}/bin/test; then
    echo "yes" >&2
    touch $out
  else
    echo "no" >&2
    exit 1
  fi
''