From 55442f689a925f1a4d2efb4d4990d98cc9faca98 Mon Sep 17 00:00:00 2001 From: w Date: Thu, 9 Jan 2025 05:45:17 +0000 Subject: [PATCH] elixir: use env shebang only on Darwin --- .../interpreters/elixir/generic-builder.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/elixir/generic-builder.nix b/pkgs/development/interpreters/elixir/generic-builder.nix index b3a7f60e03080..1abbdd25c9892 100644 --- a/pkgs/development/interpreters/elixir/generic-builder.nix +++ b/pkgs/development/interpreters/elixir/generic-builder.nix @@ -57,6 +57,16 @@ let true else versionOlder (versions.major (getVersion erlang)) maxShiftMajor; + + elixirShebang = + if stdenv.hostPlatform.isDarwin then + # Darwin disallows shebang scripts from using other scripts as their + # command. Use env as an intermediary instead of calling elixir directly + # (another shebang script). + # See https://github.com/NixOS/nixpkgs/pull/9671 + "${coreutils}/bin/env $out/bin/elixir" + else + "$out/bin/elixir"; in assert assertMsg (versionAtLeast (getVersion erlang) minimumOTPVersion) compatibilityMsg; assert assertMsg maxAssert compatibilityMsg; @@ -104,7 +114,7 @@ stdenv.mkDerivation ({ done substituteInPlace $out/bin/mix \ - --replace "/usr/bin/env elixir" "${coreutils}/bin/env $out/bin/elixir" + --replace "/usr/bin/env elixir" "${elixirShebang}" ''; pos = builtins.unsafeGetAttrPos "sha256" args;