nixpkgs/pkgs
Adrian a6133b7a39
writers.makeScriptWriter: fix on Darwin\MacOS (#93757)
* writers.makeScriptWriter: fix on Darwin\MacOS

On Darwin a script cannot be used as an interpreter in a shebang line, which
causes scripts produced with makeScriptWriter (and its derivatives) to fail at
run time if the used interpreter was wrapped with makeWrapper (as in the case
of python3.withPackages).

This commit fixes the problem by detecting if the interpreter is a script
and prepending its shebang to the final interpreter line.

For example if used interpreter is;
```
/nix/store/ynwv137n2650qy39swcflxbcygk5jwv1-python3-3.8.3-env/bin/python
```

which is a script with following shebang:
```
#! /nix/store/knd85yc7iwli8344ghav3zli8d9gril0-bash-4.4-p23/bin/bash -e
```

then the shebang line in the produced script will be
```
#! /nix/store/knd85yc7iwli8344ghav3zli8d9gril0-bash-4.4-p23/bin/bash -e /nix/store/ynwv137n2650qy39swcflxbcygk5jwv1-python3-3.8.3-env/bin/python
```

This works on Darwin since there does not seem to be a limit to the length
of the shabang line and the shebang lines support multiple arguments to
the interpreters (as opposed to linux where the kernel imposes a strict limit
on shebang lengh and everything following the interpreter is passed to it
as a single string).

fixes; #93609
related to: #65351 #11133 (and probably a bunch of others)

NOTE: scripts produced on platforms other than Darwin will remain unmodified
by this PR. However it might worth considering extending this fix to BSD systems
in general. I didn't do it since I have no way of testing it on systems other
than MacOS and linux.

* writers.makeScriptWriter: fix typo in comment

* writers.makeScriptWriter: fail build if interpreter of interpreter is a script
2020-07-25 11:47:20 +02:00
..
applications Merge pull request #93783 from equirosa/tut 2020-07-25 11:33:17 +02:00
build-support writers.makeScriptWriter: fix on Darwin\MacOS (#93757) 2020-07-25 11:47:20 +02:00
common-updater
data all-cabal-hashes: update to Hackage at 2020-07-24T00:16:27Z 2020-07-24 21:38:22 +02:00
desktops pantheon.appcenter: fix build 2020-07-22 16:00:09 -04:00
development polyml: 5.8 -> 5.8.1 2020-07-25 18:31:43 +10:00
games Merge pull request #84873 from mnacamura/cdda-mods 2020-07-22 16:18:32 -04:00
misc vimPlugins: add overrides for new ncm2 plugin deps 2020-07-18 17:01:56 -07:00
os-specific pam_p11: add 2020-07-25 09:37:48 +02:00
servers Merge pull request #92719 from pjjw/update/mongodb-42 2020-07-24 20:15:29 +02:00
shells oh-my-zsh: 2020-07-18 -> 2020-07-23 2020-07-23 13:43:01 -04:00
stdenv redox: add as target 2020-07-21 13:11:36 -07:00
test
tools Merge pull request #93775 from r-ryantm/auto-update/clib 2020-07-25 11:39:22 +02:00
top-level pam_p11: add 2020-07-25 09:37:48 +02:00