nixpkgs/pkgs/build-support
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
..
add-opengl-runpath
agda agda: install literate files 2020-06-01 13:59:20 +01:00
alternatives lapack: fix darwin library identifiers 2020-04-24 20:00:56 +02:00
appimage appimage: switch to gst-plugins-base 1.0 2020-07-18 11:51:05 +02:00
bintools-wrapper {bintools,cc}-wrapper: Ensure nix-support/*-flags files exist 2020-06-30 18:26:37 +00:00
build-bazel-package buildBazelPackage: add "fetchConfigured" for fetching only things required for the build 2020-07-17 18:29:58 +02:00
build-dotnet-package
build-fhs-userenv *-wrapper; Switch from infixSalt to suffixSalt 2020-05-12 00:44:44 -04:00
build-setupcfg
buildenv buildenv: paths to link resolving to the same absolute path is not a conflict 2020-06-10 06:42:48 -03:00
cc-wrapper {bintools,cc}-wrapper: Ensure nix-support/*-flags files exist 2020-06-30 18:26:37 +00:00
docker dockerTools: Always set imageTag attribute 2020-07-11 16:58:25 +02:00
dotnetbuildhelpers treewide: pkg-config has targetPrefix 2020-05-16 00:21:21 +00:00
dotnetenv
emacs emacs: Add native builds for nativeComp enabled emacsen 2020-07-24 03:16:17 +02:00
expand-response-params
fetchbitbucket
fetchbower
fetchbzr treewide: replace bazaar with breezy 2020-05-25 09:22:54 +02:00
fetchcvs
fetchdarcs
fetchdocker
fetchfossil
fetchgit nix-prefetch-git: also add store path to json output 2020-05-04 17:43:29 +05:30
fetchgithub
fetchgitiles
fetchgitlab fetchgitlab: escape rev to support "+" in it 2020-05-24 22:24:50 +02:00
fetchgitlocal
fetchgx
fetchhg
fetchipfs
fetchmavenartifact treewide: central.maven.org -> repo1.maven.org 2020-06-12 14:26:08 +00:00
fetchmtn
fetchnuget
fetchpatch fetchpatch: Allow using base64-encoded hash 2020-03-02 23:57:40 +01:00
fetchrepoorcz
fetchrepoproject
fetchs3
fetchsavannah
fetchsvn fetchsvn: Fix for cross 2020-03-09 02:11:45 -04:00
fetchsvnrevision
fetchsvnssh
fetchurl Merge branch 'master' into fetchurl-no-hash 2020-07-06 14:40:49 -04:00
fetchzip Revert "fetchzip, fetchgit: cleanup handling of optional features and whitespace" 2020-03-26 00:35:40 -04:00
icon-conv-tools
install-shell-files
kernel
libredirect libredirect: fix build on darwin 2020-01-23 20:20:20 -05:00
make-desktopitem makeDesktopItem: make categories optional 2020-03-31 04:10:58 +00:00
make-startupitem
make-symlinks
mkshell
mono-dll-fixer
nix-gitignore
nuke-references
ocaml ocamlPackages.buildOasis: fix handling of installation prefix 2020-07-02 07:13:34 +02:00
oci-tools
pkg-config-wrapper pkg-config-wrapper: Move comments outside of strings 2020-05-21 11:35:46 -04:00
prefer-remote-fetch
references-by-popularity
release releaseTools: no-op expression cleanup 2020-03-21 21:15:33 -04:00
remove-references-to
rust Revert "Group packages by language/builder via dummy maintainer" 2020-07-18 17:45:08 +10:00
setup-hooks stdenv: fix backward multiple outputs conditional 2020-06-29 13:56:27 +00:00
singularity-tools singularity: 3.2.1 -> 3.6.1 2020-07-22 08:51:37 +10:00
skaware skawarePackages.cleanPackaging: copy docFiles before rm noise 2020-05-21 19:46:38 +02:00
snap
src-only srcOnly: rename buildInputs to nativeBuildInputs 2020-04-27 14:31:40 +02:00
substitute
substitute-files
templaterpm
upstream-updater
vm Merge pull request #82258 from erikarvstedt/fix-xchg-caching 2020-06-01 22:34:48 +02:00
wrapper-common *-wrapper; Switch from infixSalt to suffixSalt 2020-05-12 00:44:44 -04:00
writers writers.makeScriptWriter: fix on Darwin\MacOS (#93757) 2020-07-25 11:47:20 +02:00
build-maven.nix
build-pecl.nix php.buildPecl: Allow PECLs to depend on other PECLs 2020-05-09 23:38:21 +02:00
closure-info.nix
dhall-to-nix.nix
plugins.nix
replace-dependency.nix
setup-systemd-units.nix
source-from-head-fun.nix
trivial-builders.nix trivial-builders: Sanitize derivation name 2020-04-15 00:31:57 +02:00