Skip to content

Commit

Permalink
itstool: use wrapPython to fix double shebang on macOS
Browse files Browse the repository at this point in the history
(cherry picked from commit 02a5f3e)
  • Loading branch information
Mic92 authored and LnL7 committed Apr 5, 2020
1 parent 6e14cf0 commit 7601af2
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions pkgs/development/tools/misc/itstool/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@ stdenv.mkDerivation rec {
sha256 = "1acjgf8zlyk7qckdk19iqaca4jcmywd7vxjbcs1mm6kaf8icqcv2";
};

buildInputs = [ (python3.withPackages(ps: with ps; [ libxml2 ])) ];
pythonPath = [ python3.pkgs.libxml2 ];
buildInputs = [ python3 python3.pkgs.libxml2 ];
nativeBuildInputs = [ python3.pkgs.wrapPython ];

# bin/itstool's shebang is "#!${python3.withPackages(...)/bin/python} -s"
# withPackages' shebang is "#!#{bash}/bin/bash -e
#
# macOS won't allow the target of a shebang to be an interpreted script,
# causing bin/itstool to get interpreted as bash.
#
# By prefixing /usr/bin/env to the shebang, we have env fork/exec the python
# wrapper, which is perfectly happy to execute an interpreted script.
#
# However, we don't want to do this on Linux, which only allows one argument
# in a shebang.
postFixup = lib.optionalString stdenv.isDarwin ''
substituteInPlace $out/bin/itstool \
--replace "#!/" "#!/usr/bin/env /"
postFixup = ''
wrapPythonPrograms
'';

meta = {
Expand Down

0 comments on commit 7601af2

Please sign in to comment.