From 7151eeec4819222c181df80696f1bf43547bca51 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 21 Apr 2024 20:04:29 +0200 Subject: [PATCH] treewide: `--replace` -> `--replace-fail` Hardening the packages I maintain. We use `--replace-fail` in every case except for `python3Packages.remi`, which does a glob `--replace-quiet` to reduce warnings --- pkgs/by-name/no/normcap/package.nix | 2 +- pkgs/development/compilers/gnu-cim/default.nix | 2 +- .../development/libraries/librealsense/default.nix | 2 +- pkgs/development/python-modules/birch/default.nix | 4 ++-- .../development/python-modules/cachier/default.nix | 2 +- pkgs/development/python-modules/ffmpy/default.nix | 2 +- .../python-modules/pymongo-inmemory/default.nix | 4 ++-- .../python-modules/pyrender/default.nix | 2 +- .../python-modules/pyunpack/default.nix | 2 +- pkgs/development/python-modules/remi/default.nix | 8 ++++---- pkgs/development/python-modules/strct/default.nix | 4 ++-- pkgs/tools/misc/pokemonsay/default.nix | 14 +++++++------- pkgs/tools/misc/remote-exec/default.nix | 2 +- pkgs/tools/misc/rmate-sh/default.nix | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pkgs/by-name/no/normcap/package.nix b/pkgs/by-name/no/normcap/package.nix index 7018cc565780..b9276d0abf8b 100644 --- a/pkgs/by-name/no/normcap/package.nix +++ b/pkgs/by-name/no/normcap/package.nix @@ -40,7 +40,7 @@ ps.buildPythonApplication rec { postPatch = '' # disable coverage testing substituteInPlace pyproject.toml \ - --replace "addopts = [" "addopts_ = [" + --replace-fail "addopts = [" "addopts_ = [" ''; pythonRemoveDeps = [ diff --git a/pkgs/development/compilers/gnu-cim/default.nix b/pkgs/development/compilers/gnu-cim/default.nix index b1cb9f08597e..54ba6cffff13 100644 --- a/pkgs/development/compilers/gnu-cim/default.nix +++ b/pkgs/development/compilers/gnu-cim/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { postPatch = '' for fname in lib/{simulation,simset}.c; do substituteInPlace "$fname" \ - --replace \ + --replace-fail \ '#include "../../lib/cim.h"' \ '#include "../lib/cim.h"' done diff --git a/pkgs/development/libraries/librealsense/default.nix b/pkgs/development/libraries/librealsense/default.nix index fe35759da63a..cb69770f054a 100644 --- a/pkgs/development/libraries/librealsense/default.nix +++ b/pkgs/development/libraries/librealsense/default.nix @@ -74,7 +74,7 @@ stdenv.mkDerivation rec { # ( https://github.com/IntelRealSense/meta-intel-realsense/issues/20 ) postInstall = '' substituteInPlace $out/lib/cmake/realsense2/realsense2Targets.cmake \ - --replace "\''${_IMPORT_PREFIX}/include" "$dev/include" + --replace-fail "\''${_IMPORT_PREFIX}/include" "$dev/include" '' + lib.optionalString enablePython '' cp ../wrappers/python/pyrealsense2/__init__.py $out/${pythonPackages.python.sitePackages}/pyrealsense2 ''; diff --git a/pkgs/development/python-modules/birch/default.nix b/pkgs/development/python-modules/birch/default.nix index 1dd4848427e5..4c6c85599345 100644 --- a/pkgs/development/python-modules/birch/default.nix +++ b/pkgs/development/python-modules/birch/default.nix @@ -31,13 +31,13 @@ buildPythonPackage rec { postPatch = '' substituteInPlace pytest.ini \ - --replace \ + --replace-fail \ "--cov" \ "#--cov" # configure correct version, which fails due to missing .git substituteInPlace versioneer.py birch/_version.py \ - --replace '"0+unknown"' '"${version}"' + --replace-fail '"0+unknown"' '"${version}"' ''; nativeBuildInputs = [ diff --git a/pkgs/development/python-modules/cachier/default.nix b/pkgs/development/python-modules/cachier/default.nix index 037f02b4d3ee..572cda49eaab 100644 --- a/pkgs/development/python-modules/cachier/default.nix +++ b/pkgs/development/python-modules/cachier/default.nix @@ -42,7 +42,7 @@ buildPythonPackage rec { preCheck = '' substituteInPlace pyproject.toml \ - --replace \ + --replace-fail \ '"--cov' \ '#"--cov' ''; diff --git a/pkgs/development/python-modules/ffmpy/default.nix b/pkgs/development/python-modules/ffmpy/default.nix index 8e00a4678ebf..974e2bcd8fda 100644 --- a/pkgs/development/python-modules/ffmpy/default.nix +++ b/pkgs/development/python-modules/ffmpy/default.nix @@ -25,7 +25,7 @@ buildPythonPackage rec { postPatch = '' # default to store ffmpeg substituteInPlace ffmpy.py \ - --replace 'executable="ffmpeg",' 'executable="${ffmpeg-headless}/bin/ffmpeg",' + --replace-fail 'executable="ffmpeg",' 'executable="${ffmpeg-headless}/bin/ffmpeg",' # The tests test a mock that does not behave like ffmpeg. If we default to the nix-store ffmpeg they fail. for fname in tests/*.py; do diff --git a/pkgs/development/python-modules/pymongo-inmemory/default.nix b/pkgs/development/python-modules/pymongo-inmemory/default.nix index 604f0c1c3cd3..28b52dd9a3ee 100644 --- a/pkgs/development/python-modules/pymongo-inmemory/default.nix +++ b/pkgs/development/python-modules/pymongo-inmemory/default.nix @@ -25,13 +25,13 @@ buildPythonPackage rec { postPatch = '' # move cache location from nix store to home substituteInPlace pymongo_inmemory/context.py \ - --replace \ + --replace-fail \ 'CACHE_FOLDER = path.join(path.dirname(__file__), "..", ".cache")' \ 'CACHE_FOLDER = os.environ.get("XDG_CACHE_HOME", os.environ["HOME"] + "/.cache") + "/pymongo-inmemory"' # fix a broken assumption arising from the above fix substituteInPlace pymongo_inmemory/_utils.py \ - --replace \ + --replace-fail \ 'os.mkdir(current_path)' \ 'os.makedirs(current_path)' ''; diff --git a/pkgs/development/python-modules/pyrender/default.nix b/pkgs/development/python-modules/pyrender/default.nix index eb1d5d17ee47..0916608b8ac0 100644 --- a/pkgs/development/python-modules/pyrender/default.nix +++ b/pkgs/development/python-modules/pyrender/default.nix @@ -45,7 +45,7 @@ buildPythonPackage rec { # the commit does not apply as a patch when cherry picked, hence the substituteInPlace postPatch = '' substituteInPlace tests/unit/test_meshes.py \ - --replace \ + --replace-fail \ "bm = trimesh.load('tests/data/WaterBottle.glb').dump()[0]" \ 'bm = trimesh.load("tests/data/WaterBottle.glb").geometry["WaterBottle"]' ''; diff --git a/pkgs/development/python-modules/pyunpack/default.nix b/pkgs/development/python-modules/pyunpack/default.nix index ea7ad7d416a3..cc529f86032c 100644 --- a/pkgs/development/python-modules/pyunpack/default.nix +++ b/pkgs/development/python-modules/pyunpack/default.nix @@ -23,7 +23,7 @@ buildPythonPackage rec { postPatch = '' substituteInPlace pyunpack/__init__.py \ - --replace \ + --replace-fail \ '_exepath("patool")' \ '"${lib.getBin patool}/bin/.patool-wrapped"' ''; diff --git a/pkgs/development/python-modules/remi/default.nix b/pkgs/development/python-modules/remi/default.nix index b1f28e269099..490a7361613e 100644 --- a/pkgs/development/python-modules/remi/default.nix +++ b/pkgs/development/python-modules/remi/default.nix @@ -23,19 +23,19 @@ buildPythonPackage rec { preCheck = '' # for some reason, REMI already deal with these using try blocks, but they fail substituteInPlace test/test_widget.py \ - --replace \ + --replace-fail \ "from html_validator import " \ "from .html_validator import " substituteInPlace test/test_examples_app.py \ - --replace \ + --replace-fail \ "from mock_server_and_request import " \ "from .mock_server_and_request import " \ - --replace \ + --replace-fail \ "from html_validator import " \ "from .html_validator import " # Halves number of warnings substituteInPlace test/test_*.py \ - --replace \ + --replace-quiet \ "self.assertEquals(" \ "self.assertEqual(" ''; diff --git a/pkgs/development/python-modules/strct/default.nix b/pkgs/development/python-modules/strct/default.nix index 061e2a90c07c..c5f9bc2f994b 100644 --- a/pkgs/development/python-modules/strct/default.nix +++ b/pkgs/development/python-modules/strct/default.nix @@ -30,13 +30,13 @@ buildPythonPackage rec { postPatch = '' substituteInPlace pytest.ini \ - --replace \ + --replace-fail \ "--cov" \ "#--cov" # configure correct version, which fails due to missing .git substituteInPlace versioneer.py strct/_version.py \ - --replace '"0+unknown"' '"${version}"' + --replace-fail '"0+unknown"' '"${version}"' ''; nativeBuildInputs = [ diff --git a/pkgs/tools/misc/pokemonsay/default.nix b/pkgs/tools/misc/pokemonsay/default.nix index 7053e4ba8073..669fa6a49413 100644 --- a/pkgs/tools/misc/pokemonsay/default.nix +++ b/pkgs/tools/misc/pokemonsay/default.nix @@ -28,27 +28,27 @@ stdenvNoCC.mkDerivation rec { postPatch = '' substituteInPlace pokemonsay.sh \ - --replace \ + --replace-fail \ 'INSTALL_PATH=''${HOME}/.bin/pokemonsay' \ "" \ - --replace \ + --replace-fail \ 'POKEMON_PATH=''${INSTALL_PATH}/pokemons' \ 'POKEMON_PATH=${placeholder "out"}/share/pokemonsay' \ - --replace \ + --replace-fail \ '$(find ' \ '$(${findutils}/bin/find ' \ - --replace \ + --replace-fail \ '$(basename ' \ '$(${coreutils}/bin/basename ' \ - --replace \ + --replace-fail \ 'cowsay -f ' \ '${cowsay}/bin/cowsay -f ' \ - --replace \ + --replace-fail \ 'cowthink -f ' \ '${cowsay}/bin/cowthink -f ' substituteInPlace pokemonthink.sh \ - --replace \ + --replace-fail \ './pokemonsay.sh' \ "${placeholder "out"}/bin/pokemonsay" ''; diff --git a/pkgs/tools/misc/remote-exec/default.nix b/pkgs/tools/misc/remote-exec/default.nix index 979f0f53bae0..ec5ad043272b 100644 --- a/pkgs/tools/misc/remote-exec/default.nix +++ b/pkgs/tools/misc/remote-exec/default.nix @@ -34,7 +34,7 @@ buildPythonApplication rec { # remove legacy endpoints, we use --multi now postPatch = '' substituteInPlace setup.py \ - --replace '"mremote' '#"mremote' + --replace-fail '"mremote' '#"mremote' ''; propagatedBuildInputs = [ diff --git a/pkgs/tools/misc/rmate-sh/default.nix b/pkgs/tools/misc/rmate-sh/default.nix index bc93c6e437fe..81189a1cd6c7 100644 --- a/pkgs/tools/misc/rmate-sh/default.nix +++ b/pkgs/tools/misc/rmate-sh/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation rec { runHook preBuild substituteInPlace rmate \ - --replace \ + --replace-fail \ 'echo "hostname"' \ 'echo "${hostname}/bin/hostname"' patsh -f rmate -s ${builtins.storeDir}