diff options
author | Ivan Trubach <mr.trubach@icloud.com> | 2023-06-19 08:56:21 +0300 |
---|---|---|
committer | Ivan Trubach <mr.trubach@icloud.com> | 2023-06-19 09:01:21 +0300 |
commit | ebd4619053711ffb317a36dca4b118ae33f17828 (patch) | |
tree | 824330cff0b7831a399d1fd0b72af344210be030 /pkgs/test/stdenv | |
parent | c1bca7fe84c646cfd4ebf3482c0e6317a0b13f22 (diff) |
patch-shebangs: add a flag to update shebangs with store paths
This change adds a flag to update shebang paths that point to the Nix store. This is particularly useful when a cross-compiled package uses same script at compile-time and run-time, but the interpreter must be changed since hostPlatform != buildPlatform.
Diffstat (limited to 'pkgs/test/stdenv')
-rw-r--r-- | pkgs/test/stdenv/patch-shebangs.nix | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pkgs/test/stdenv/patch-shebangs.nix b/pkgs/test/stdenv/patch-shebangs.nix index fb52f38ecc91b..888d4a53a2733 100644 --- a/pkgs/test/stdenv/patch-shebangs.nix +++ b/pkgs/test/stdenv/patch-shebangs.nix @@ -39,6 +39,23 @@ let }; }; + updates-nix-store = stdenv.mkDerivation { + name = "updates-nix-store"; + strictDeps = false; + dontUnpack = true; + installPhase = '' + mkdir -p $out/bin + echo "#!$NIX_STORE/path/to/bash" > $out/bin/test + echo "echo -n hello" >> $out/bin/test + chmod +x $out/bin/test + patchShebangs --update $out/bin/test + dontPatchShebangs=1 + ''; + passthru = { + assertion = "grep '^#!${stdenv.shell}' $out/bin/test > /dev/null"; + }; + }; + split-string = stdenv.mkDerivation { name = "split-string"; strictDeps = false; @@ -59,7 +76,7 @@ let in stdenv.mkDerivation { name = "test-patch-shebangs"; - passthru = { inherit (tests) bad-shebang ignores-nix-store split-string; }; + passthru = { inherit (tests) bad-shebang ignores-nix-store updates-nix-store split-string; }; buildCommand = '' validate() { local name=$1 |