From 5c6ae8863d1dea6684f7db26aeb5e4d9d7f5acf7 Mon Sep 17 00:00:00 2001 From: Artturin Date: Sun, 13 Aug 2023 05:40:01 +0300 Subject: [PATCH 1/2] treewide: Amend hacks of removing $(pwd) The strip phase is using $TMPDIR now, so it would fail with: `mktemp: failed to create file via template 'striperr.XXXXXX': No such file or directory` --- pkgs/development/libraries/qt-5/modules/qtwebkit.nix | 9 +++++---- pkgs/development/tools/simavr/default.nix | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix index a70ebd3fb74f..fc1766488ecc 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix @@ -47,12 +47,13 @@ qtModule { doCheck = false; # fails 13 out of 13 tests (ctest) - # Hack to avoid TMPDIR in RPATHs. - preFixup = '' - rm -rf "$(pwd)" - mkdir "$(pwd)" + # remove forbidden references to $TMPDIR + preFixup = lib.optionalString stdenv.isLinux '' + patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out"/libexec/* ''; + enableParallelBuilding = true; + meta = { maintainers = with lib.maintainers; [ abbradar periklis ]; knownVulnerabilities = [ diff --git a/pkgs/development/tools/simavr/default.nix b/pkgs/development/tools/simavr/default.nix index 11b146e55c5e..db3f9e6664e1 100644 --- a/pkgs/development/tools/simavr/default.nix +++ b/pkgs/development/tools/simavr/default.nix @@ -35,8 +35,10 @@ in stdenv.mkDerivation rec { buildInputs = [ libelf freeglut libGLU libGL ] ++ lib.optional stdenv.isDarwin GLUT; - # Hack to avoid TMPDIR in RPATHs. - preFixup = ''rm -rf "$(pwd)" && mkdir "$(pwd)" ''; + # remove forbidden references to $TMPDIR + preFixup = lib.optionalString stdenv.isLinux '' + patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out"/bin/* + ''; doCheck = true; checkTarget = "-C tests run_tests"; From 25eef24033b80ade0a9b1e085bc08f62aee27c81 Mon Sep 17 00:00:00 2001 From: Artturin Date: Sun, 13 Aug 2023 05:44:01 +0300 Subject: [PATCH 2/2] treewide: Don't hardcode nix store in patchelf calls --- .../science/misc/openmodelica/omcompiler/default.nix | 4 ++-- pkgs/development/libraries/hipfft/default.nix | 2 +- pkgs/development/libraries/hipsolver/default.nix | 2 +- pkgs/development/libraries/migraphx/default.nix | 2 +- pkgs/development/pharo/default.nix | 2 +- pkgs/development/tools/misc/rdc/default.nix | 2 +- pkgs/os-specific/linux/libsmbios/default.nix | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix b/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix index 39591eceb40d..360fea56fedf 100644 --- a/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix +++ b/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix @@ -46,8 +46,8 @@ mkOpenModelicaDerivation ({ preFixup = '' for entry in $(find $out -name libipopt.so); do - patchelf --shrink-rpath --allowed-rpath-prefixes /nix/store $entry - patchelf --set-rpath '$ORIGIN':"$(patchelf --print-rpath $entry)" $entry + patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$entry" + patchelf --set-rpath '$ORIGIN':"$(patchelf --print-rpath $entry)" "$entry" done ''; diff --git a/pkgs/development/libraries/hipfft/default.nix b/pkgs/development/libraries/hipfft/default.nix index 7f64cb3b5797..c4d13cb4f55e 100644 --- a/pkgs/development/libraries/hipfft/default.nix +++ b/pkgs/development/libraries/hipfft/default.nix @@ -85,7 +85,7 @@ stdenv.mkDerivation (finalAttrs: { '' + lib.optionalString buildSamples '' mkdir -p $sample/bin mv clients/staging/hipfft_* $sample/bin - patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes /nix/store + patchelf $sample/bin/hipfft_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" '' + lib.optionalString (buildTests || buildBenchmarks) '' rmdir $out/bin ''; diff --git a/pkgs/development/libraries/hipsolver/default.nix b/pkgs/development/libraries/hipsolver/default.nix index 0b7f3edc358d..ff499b342f26 100644 --- a/pkgs/development/libraries/hipsolver/default.nix +++ b/pkgs/development/libraries/hipsolver/default.nix @@ -78,7 +78,7 @@ stdenv.mkDerivation (finalAttrs: { '' + lib.optionalString buildSamples '' mkdir -p $sample/bin mv clients/staging/example-* $sample/bin - patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes /nix/store + patchelf $sample/bin/example-* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" '' + lib.optionalString (buildTests || buildBenchmarks) '' rmdir $out/bin ''; diff --git a/pkgs/development/libraries/migraphx/default.nix b/pkgs/development/libraries/migraphx/default.nix index 0cee9c3e42f6..3b32b86f41af 100644 --- a/pkgs/development/libraries/migraphx/default.nix +++ b/pkgs/development/libraries/migraphx/default.nix @@ -140,7 +140,7 @@ in stdenv.mkDerivation (finalAttrs: { '' + lib.optionalString buildTests '' mkdir -p $test/bin mv bin/test_* $test/bin - patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes /nix/store + patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" ''; passthru.updateScript = rocmUpdateScript { diff --git a/pkgs/development/pharo/default.nix b/pkgs/development/pharo/default.nix index 6e83a31d5dd5..2cf98d493698 100644 --- a/pkgs/development/pharo/default.nix +++ b/pkgs/development/pharo/default.nix @@ -77,7 +77,7 @@ stdenv.mkDerivation { mkdir "$out/bin" cp build/vm/*.so* "$out/lib/" cp build/vm/pharo "$out/bin/pharo" - patchelf --allowed-rpath-prefixes /nix/store --shrink-rpath "$out/bin/pharo" + patchelf --allowed-rpath-prefixes "$NIX_STORE" --shrink-rpath "$out/bin/pharo" wrapProgram "$out/bin/pharo" --set LD_LIBRARY_PATH "${library_path}" runHook postInstall diff --git a/pkgs/development/tools/misc/rdc/default.nix b/pkgs/development/tools/misc/rdc/default.nix index 110b38de75f8..906f35b47c52 100644 --- a/pkgs/development/tools/misc/rdc/default.nix +++ b/pkgs/development/tools/misc/rdc/default.nix @@ -102,7 +102,7 @@ in stdenv.mkDerivation (finalAttrs: { postInstall = '' find $out/bin -executable -type f -exec \ - patchelf {} --shrink-rpath --allowed-rpath-prefixes /nix/store \; + patchelf {} --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" \; '' + lib.optionalString buildTests '' mkdir -p $test mv $out/bin/rdctst_tests $test/bin diff --git a/pkgs/os-specific/linux/libsmbios/default.nix b/pkgs/os-specific/linux/libsmbios/default.nix index 144533621b75..df4337a6caff 100644 --- a/pkgs/os-specific/linux/libsmbios/default.nix +++ b/pkgs/os-specific/linux/libsmbios/default.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation rec { # remove forbidden reference to $TMPDIR preFixup = '' - patchelf --shrink-rpath --allowed-rpath-prefixes "/nix/store" "$out/sbin/smbios-sys-info-lite" + patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out/sbin/smbios-sys-info-lite" ''; meta = with lib; {