From e68001550de99fac8336e2c230dcd7e0157777ed Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 6 Nov 2023 00:13:45 +0200 Subject: [PATCH 1/2] stdenv: run patchShebangs on the configure script when it's a file if the configure script has a `/usr/bin/env` or some other shebang which is not in the sandbox then there will be errors such as `...-stdenv-linux/setup: line 1299: ./configure: cannot execute: required file not found` There are 250 files which `patchShebangs` `./configure` https://github.com/search?q=NOT+is%3Afork+lang%3Anix+%2FpatchShebangs+.%5C%2Fconfigure%2F&type=code --- pkgs/stdenv/generic/setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index ad9857fc9d61..b06758821da8 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -1273,6 +1273,10 @@ configurePhase() { prependToVar configureFlags --disable-static fi fi + + if [ -z "${dontPatchShebangsInConfigure:-}" ]; then + patchShebangs --build "$configureScript" + fi fi if [ -n "$configureScript" ]; then From 20591326aaff590f5051a17f2b50ade7636d908f Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 6 Nov 2023 04:44:32 +0200 Subject: [PATCH 2/2] treewide: remove unnecessary patching of configure script The configure phase of `stdenv` now runs `patchShebangs` on `configureScript`. Did not remove `patchShebangs` in packages which override `configurePhase` --- pkgs/applications/editors/vis/default.nix | 4 ---- pkgs/by-name/ze/zesarux/package.nix | 2 +- pkgs/data/documentation/stdman/default.nix | 1 - pkgs/development/coq-modules/Cheerios/default.nix | 5 ----- pkgs/development/coq-modules/InfSeqExt/default.nix | 5 ----- pkgs/development/coq-modules/StructTact/default.nix | 5 ----- pkgs/development/coq-modules/Verdi/default.nix | 5 ----- pkgs/development/coq-modules/corn/default.nix | 1 - pkgs/development/coq-modules/metacoq/default.nix | 1 - pkgs/development/libraries/SDL/default.nix | 3 --- pkgs/development/libraries/expat/default.nix | 2 +- .../libraries/physics/fastjet-contrib/default.nix | 2 +- pkgs/development/libraries/physics/pythia/default.nix | 4 ---- pkgs/development/ocaml-modules/javalib/default.nix | 2 -- pkgs/development/ocaml-modules/sawja/default.nix | 2 -- pkgs/development/tools/kcat/default.nix | 4 ---- pkgs/development/tools/pyenv/default.nix | 4 ---- pkgs/games/eboard/default.nix | 4 ---- pkgs/os-specific/linux/dracut/default.nix | 4 ---- pkgs/os-specific/linux/hwdata/default.nix | 4 ---- pkgs/servers/tvheadend/default.nix | 2 -- pkgs/tools/networking/dhcpcd/default.nix | 2 -- 22 files changed, 3 insertions(+), 65 deletions(-) diff --git a/pkgs/applications/editors/vis/default.nix b/pkgs/applications/editors/vis/default.nix index f4d25b8547f4..479a475e0741 100644 --- a/pkgs/applications/editors/vis/default.nix +++ b/pkgs/applications/editors/vis/default.nix @@ -30,10 +30,6 @@ stdenv.mkDerivation rec { libselinux ]; - postPatch = '' - patchShebangs ./configure - ''; - postInstall = '' wrapProgram $out/bin/vis \ --prefix LUA_CPATH ';' "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \ diff --git a/pkgs/by-name/ze/zesarux/package.nix b/pkgs/by-name/ze/zesarux/package.nix index e19dd5b60f08..915bfe3905cf 100644 --- a/pkgs/by-name/ze/zesarux/package.nix +++ b/pkgs/by-name/ze/zesarux/package.nix @@ -48,7 +48,7 @@ stdenv.mkDerivation (finalAttrs: { sourceRoot = "${finalAttrs.src.name}/src"; postPatch = '' - patchShebangs ./configure *.sh + patchShebangs *.sh ''; configureFlags = [ diff --git a/pkgs/data/documentation/stdman/default.nix b/pkgs/data/documentation/stdman/default.nix index 57e32d864053..adb735c38a1e 100644 --- a/pkgs/data/documentation/stdman/default.nix +++ b/pkgs/data/documentation/stdman/default.nix @@ -14,7 +14,6 @@ stdenv.mkDerivation rec { outputDevdoc = "out"; preConfigure = " - patchShebangs ./configure patchShebangs ./do_install "; diff --git a/pkgs/development/coq-modules/Cheerios/default.nix b/pkgs/development/coq-modules/Cheerios/default.nix index cacdacde326f..4f02f4fca7a3 100644 --- a/pkgs/development/coq-modules/Cheerios/default.nix +++ b/pkgs/development/coq-modules/Cheerios/default.nix @@ -14,9 +14,4 @@ mkCoqDerivation { release."20200201".sha256 = "1h55s6lk47bk0lv5ralh81z55h799jbl9mhizmqwqzy57y8wqgs1"; propagatedBuildInputs = [ StructTact ]; - preConfigure = '' - if [ -f ./configure ]; then - patchShebangs ./configure - fi - ''; } diff --git a/pkgs/development/coq-modules/InfSeqExt/default.nix b/pkgs/development/coq-modules/InfSeqExt/default.nix index ae20898e3ce9..5727afa983a0 100644 --- a/pkgs/development/coq-modules/InfSeqExt/default.nix +++ b/pkgs/development/coq-modules/InfSeqExt/default.nix @@ -12,9 +12,4 @@ mkCoqDerivation { release."20230107".sha256 = "sha256-YMBzVIsLkIC+w2TeyHrKe29eWLIxrH3wIMZqhik8p9I="; release."20200131".rev = "203d4c20211d6b17741f1fdca46dbc091f5e961a"; release."20200131".sha256 = "0xylkdmb2dqnnqinf3pigz4mf4zmczcbpjnn59g5g76m7f2cqxl0"; - preConfigure = '' - if [ -f ./configure ]; then - patchShebangs ./configure - fi - ''; } diff --git a/pkgs/development/coq-modules/StructTact/default.nix b/pkgs/development/coq-modules/StructTact/default.nix index 16bc63ff3a74..96173ae640b2 100644 --- a/pkgs/development/coq-modules/StructTact/default.nix +++ b/pkgs/development/coq-modules/StructTact/default.nix @@ -15,9 +15,4 @@ mkCoqDerivation { release."20210328".sha256 = "sha256:1y5r1zm3hli10ah6lnj7n8hxad6rb6rgldd0g7m2fjibzvwqzhdg"; release."20181102".rev = "82a85b7ec07e71fa6b30cfc05f6a7bfb09ef2510"; release."20181102".sha256 = "08zry20flgj7qq37xk32kzmg4fg6d4wi9m7pf9aph8fd3j2a0b5v"; - preConfigure = '' - if [ -f ./configure ]; then - patchShebangs ./configure - fi - ''; } diff --git a/pkgs/development/coq-modules/Verdi/default.nix b/pkgs/development/coq-modules/Verdi/default.nix index 748f16b2ea8a..b0ff84c45981 100644 --- a/pkgs/development/coq-modules/Verdi/default.nix +++ b/pkgs/development/coq-modules/Verdi/default.nix @@ -24,9 +24,4 @@ mkCoqDerivation { release."20181102".sha256 = "1vw47c37k5vaa8vbr6ryqy8riagngwcrfmb3rai37yi9xhdqg55z"; propagatedBuildInputs = [ Cheerios InfSeqExt ssreflect ]; - preConfigure = '' - if [ -f ./configure ]; then - patchShebangs ./configure - fi - ''; } diff --git a/pkgs/development/coq-modules/corn/default.nix b/pkgs/development/coq-modules/corn/default.nix index a33fd8b87e27..1f19ed2c9ec5 100644 --- a/pkgs/development/coq-modules/corn/default.nix +++ b/pkgs/development/coq-modules/corn/default.nix @@ -17,7 +17,6 @@ mkCoqDerivation rec { "8.18.0".sha256 = "sha256-ow3mfarZ1PvBGf5WLnI8LdF3E+8A6fN7cOcXHrZJLo0="; }; - preConfigure = "patchShebangs ./configure.sh"; configureScript = "./configure.sh"; dontAddPrefix = true; diff --git a/pkgs/development/coq-modules/metacoq/default.nix b/pkgs/development/coq-modules/metacoq/default.nix index b61b729eb475..9ab49f8e0861 100644 --- a/pkgs/development/coq-modules/metacoq/default.nix +++ b/pkgs/development/coq-modules/metacoq/default.nix @@ -48,7 +48,6 @@ let propagatedBuildInputs = [ equations coq.ocamlPackages.zarith ] ++ metacoq-deps; patchPhase = '' - patchShebangs ./configure.sh patchShebangs ./template-coq/update_plugin.sh patchShebangs ./template-coq/gen-src/to-lower.sh patchShebangs ./pcuic/clean_extraction.sh diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index e82220b2398e..fa816c0add0f 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -31,9 +31,6 @@ stdenv.mkDerivation rec { sha256 = "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"; }; - # make: *** No rule to make target 'build/*.lo', needed by 'build/libSDL.la'. Stop. - postPatch = "patchShebangs ./configure"; - outputs = [ "out" "dev" ]; outputBin = "dev"; # sdl-config diff --git a/pkgs/development/libraries/expat/default.nix b/pkgs/development/libraries/expat/default.nix index ac6e9bfdc386..248e3774f4cd 100644 --- a/pkgs/development/libraries/expat/default.nix +++ b/pkgs/development/libraries/expat/default.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { doCheck = true; # not cross; preCheck = '' - patchShebangs ./configure ./run.sh ./test-driver-wrapper.sh + patchShebangs ./run.sh ./test-driver-wrapper.sh ''; # CMake files incorrectly calculate library path from dev prefix diff --git a/pkgs/development/libraries/physics/fastjet-contrib/default.nix b/pkgs/development/libraries/physics/fastjet-contrib/default.nix index b61db08457fd..3c4e8008639c 100644 --- a/pkgs/development/libraries/physics/fastjet-contrib/default.nix +++ b/pkgs/development/libraries/physics/fastjet-contrib/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { for f in Makefile.in */Makefile; do substituteInPlace "$f" --replace "CXX=g++" "" done - patchShebangs ./configure ./utils/check.sh ./utils/install-sh + patchShebangs ./utils/check.sh ./utils/install-sh ''; # Written in shell manually, does not support autoconf-style diff --git a/pkgs/development/libraries/physics/pythia/default.nix b/pkgs/development/libraries/physics/pythia/default.nix index 0916eae24669..917dbf40a37d 100644 --- a/pkgs/development/libraries/physics/pythia/default.nix +++ b/pkgs/development/libraries/physics/pythia/default.nix @@ -13,10 +13,6 @@ stdenv.mkDerivation rec { ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ]; buildInputs = [ boost fastjet hepmc zlib lhapdf ]; - preConfigure = '' - patchShebangs ./configure - ''; - configureFlags = [ "--enable-shared" "--with-lhapdf6=${lhapdf}" diff --git a/pkgs/development/ocaml-modules/javalib/default.nix b/pkgs/development/ocaml-modules/javalib/default.nix index 5675e10dbad1..fbe2d71fcd00 100644 --- a/pkgs/development/ocaml-modules/javalib/default.nix +++ b/pkgs/development/ocaml-modules/javalib/default.nix @@ -30,8 +30,6 @@ stdenv.mkDerivation rec { createFindlibDestdir = true; - preConfigure = "patchShebangs ./configure.sh"; - configureScript = "./configure.sh"; dontAddPrefix = "true"; dontAddStaticConfigureFlags = true; diff --git a/pkgs/development/ocaml-modules/sawja/default.nix b/pkgs/development/ocaml-modules/sawja/default.nix index a5d042fc1907..ab21f11fa31f 100644 --- a/pkgs/development/ocaml-modules/sawja/default.nix +++ b/pkgs/development/ocaml-modules/sawja/default.nix @@ -29,8 +29,6 @@ stdenv.mkDerivation { createFindlibDestdir = true; - preConfigure = "patchShebangs ./configure.sh"; - configureScript = "./configure.sh"; dontAddPrefix = "true"; dontAddStaticConfigureFlags = true; diff --git a/pkgs/development/tools/kcat/default.nix b/pkgs/development/tools/kcat/default.nix index 224d18ed2e69..f363e4e51039 100644 --- a/pkgs/development/tools/kcat/default.nix +++ b/pkgs/development/tools/kcat/default.nix @@ -16,10 +16,6 @@ stdenv.mkDerivation rec { buildInputs = [ zlib rdkafka yajl avro-c libserdes ]; - preConfigure = '' - patchShebangs ./configure - ''; - meta = with lib; { description = "A generic non-JVM producer and consumer for Apache Kafka"; homepage = "https://github.com/edenhill/kcat"; diff --git a/pkgs/development/tools/pyenv/default.nix b/pkgs/development/tools/pyenv/default.nix index b5f73a13c358..b54fa9e3b356 100644 --- a/pkgs/development/tools/pyenv/default.nix +++ b/pkgs/development/tools/pyenv/default.nix @@ -15,10 +15,6 @@ stdenv.mkDerivation rec { hash = "sha256-liDm8lcHSdn9f/tNISRlnqEIcBtmusMplH0N4tW5Lgo="; }; - postPatch = '' - patchShebangs --build src/configure - ''; - nativeBuildInputs = [ installShellFiles ]; diff --git a/pkgs/games/eboard/default.nix b/pkgs/games/eboard/default.nix index 49721fd2ce1e..0250208fd48a 100644 --- a/pkgs/games/eboard/default.nix +++ b/pkgs/games/eboard/default.nix @@ -16,10 +16,6 @@ stdenv.mkDerivation rec { hardeningDisable = [ "format" ]; - preConfigure = '' - patchShebangs ./configure - ''; - env.NIX_CFLAGS_COMPILE = "-fpermissive"; meta = { diff --git a/pkgs/os-specific/linux/dracut/default.nix b/pkgs/os-specific/linux/dracut/default.nix index c6bf684f7fc8..e5461bddbc8f 100644 --- a/pkgs/os-specific/linux/dracut/default.nix +++ b/pkgs/os-specific/linux/dracut/default.nix @@ -61,10 +61,6 @@ stdenv.mkDerivation rec { echo 'DRACUT_VERSION=${version}' >dracut-version.sh ''; - preConfigure = '' - patchShebangs ./configure - ''; - postFixup = '' wrapProgram $out/bin/dracut --prefix PATH : ${lib.makeBinPath [ coreutils diff --git a/pkgs/os-specific/linux/hwdata/default.nix b/pkgs/os-specific/linux/hwdata/default.nix index a64a0574d8ff..63b5e2f8474c 100644 --- a/pkgs/os-specific/linux/hwdata/default.nix +++ b/pkgs/os-specific/linux/hwdata/default.nix @@ -11,10 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-RvjYd8iD6JkGhh6TDy/Qo+UzLxbhPvIJvhl/Rw14lbk="; }; - postPatch = '' - patchShebangs ./configure - ''; - configureFlags = [ "--datadir=${placeholder "out"}/share" ]; doCheck = false; # this does build machine-specific checks (e.g. enumerates PCI bus) diff --git a/pkgs/servers/tvheadend/default.nix b/pkgs/servers/tvheadend/default.nix index 573a857becd7..7cb28e9088ba 100644 --- a/pkgs/servers/tvheadend/default.nix +++ b/pkgs/servers/tvheadend/default.nix @@ -102,8 +102,6 @@ in stdenv.mkDerivation { ]; preConfigure = '' - patchShebangs ./configure - substituteInPlace src/config.c \ --replace /usr/bin/tar ${gnutar}/bin/tar diff --git a/pkgs/tools/networking/dhcpcd/default.nix b/pkgs/tools/networking/dhcpcd/default.nix index 40cfa4077227..2d7a646299ad 100644 --- a/pkgs/tools/networking/dhcpcd/default.nix +++ b/pkgs/tools/networking/dhcpcd/default.nix @@ -40,8 +40,6 @@ stdenv.mkDerivation rec { substituteInPlace hooks/dhcpcd-run-hooks.in --replace /bin/sh ${runtimeShell} ''; - preConfigure = "patchShebangs ./configure"; - configureFlags = [ "--sysconfdir=/etc" "--localstatedir=/var"