svanderburg / composer2nix

Generate Nix expressions to build PHP composer packages
MIT License
88 stars 25 forks source link

call php scripts via php interpreter instead of relying on shebang #12

Closed christian-blades-cb closed 3 years ago

christian-blades-cb commented 4 years ago

The problem

Looks like in recent versions of nixpkgs, ${php}/bin/php is a shell script wrapping the actual php binary. The consequence is that it's not usable as a shebang in this state, and we can't build composer2nix.

$ nix-build -A package.x86_64-darwin --arg systems '[ "x86_64-darwin" ]' ./release.nix
[...]
/nix/store/5p443xmpksknmbdcipygsddrpl3jxk3b-reconstructinstalled.php: line 2: ?php: No such file or directory
/nix/store/5p443xmpksknmbdcipygsddrpl3jxk3b-reconstructinstalled.php: line 3: syntax error near unexpected token `$argv[1]'
/nix/store/5p443xmpksknmbdcipygsddrpl3jxk3b-reconstructinstalled.php: line 3: `if(file_exists($argv[1]))'
builder for '/nix/store/flmwgq14wkbknv1yl7yklcidi10zn8vb-composer-svanderburg-composer2nix.drv' failed with exit code 2
error: build of '/nix/store/flmwgq14wkbknv1yl7yklcidi10zn8vb-composer-svanderburg-composer2nix.drv' failed

Proposed solution

Call the two php scripts in composer-env.nix via the php interpreter instead of relying on the shebang.

christian-blades-cb commented 4 years ago

This appears to only be a problem in macos, I can't reproduce the issue on linux.

wmertens commented 3 years ago

macOS doesn't allow scripts that use a script as an interpreter. See https://github.com/doronbehar/rfcs/blob/declarative-wrappers/rfcs/0075-declarative-wrappers.md for an effort to fix this.