various: replace substituteAll with replaceVars

A few more interesting cases, separated from the big treewide for better
visibility and testing.
This commit is contained in:
Wolfgang Walther 2025-01-25 20:59:09 +01:00
parent ca4d24ef53
commit 1c6126f709
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
8 changed files with 50 additions and 59 deletions

View File

@ -5,7 +5,7 @@
pytestCheckHook,
pythonOlder,
fetchFromGitLab,
substituteAll,
replaceVars,
bubblewrap,
exiftool,
ffmpeg,
@ -40,22 +40,21 @@ buildPythonPackage rec {
patches =
[
# hardcode paths to some binaries
(substituteAll (
{
src = ./paths.patch;
exiftool = "${exiftool}/bin/exiftool";
ffmpeg = "${ffmpeg}/bin/ffmpeg";
}
// lib.optionalAttrs dolphinIntegration { kdialog = "${plasma5Packages.kdialog}/bin/kdialog"; }
))
(replaceVars ./paths.patch {
exiftool = "${exiftool}/bin/exiftool";
ffmpeg = "${ffmpeg}/bin/ffmpeg";
kdialog = if dolphinIntegration then "${plasma5Packages.kdialog}/bin/kdialog" else null;
# replaced in postPatch
mat2 = null;
mat2svg = null;
})
# the executable shouldn't be called .mat2-wrapped
./executable-name.patch
# hardcode path to mat2 executable
./tests.patch
]
++ lib.optionals (stdenv.hostPlatform.isLinux) [
(substituteAll {
src = ./bubblewrap-path.patch;
(replaceVars ./bubblewrap-path.patch {
bwrap = "${bubblewrap}/bin/bwrap";
})
];

View File

@ -17,7 +17,7 @@
python,
pytestCheckHook,
stdenv,
substituteAll,
replaceVars,
setuptools,
torchWithRocm,
zlib,
@ -43,28 +43,20 @@ buildPythonPackage {
patches =
[
./0001-setup.py-introduce-TRITON_OFFLINE_BUILD.patch
(substituteAll {
src = ./0001-_build-allow-extra-cc-flags.patch;
(replaceVars ./0001-_build-allow-extra-cc-flags.patch {
ccCmdExtraFlags = "-Wl,-rpath,${addDriverRunpath.driverLink}/lib";
})
(substituteAll (
{
src = ./0002-nvidia-amd-driver-short-circuit-before-ldconfig.patch;
}
// lib.optionalAttrs rocmSupport { libhipDir = "${lib.getLib rocmPackages.clr}/lib"; }
// lib.optionalAttrs cudaSupport {
libcudaStubsDir = "${lib.getOutput "stubs" cudaPackages.cuda_cudart}/lib/stubs";
ccCmdExtraFlags = "-Wl,-rpath,${addDriverRunpath.driverLink}/lib";
}
))
(replaceVars ./0002-nvidia-amd-driver-short-circuit-before-ldconfig.patch {
libhipDir = if rocmSupport then "${lib.getLib rocmPackages.clr}/lib" else null;
libcudaStubsDir =
if cudaSupport then "${lib.getOutput "stubs" cudaPackages.cuda_cudart}/lib/stubs" else null;
})
]
++ lib.optionals cudaSupport [
(substituteAll {
src = ./0003-nvidia-cudart-a-systempath.patch;
(replaceVars ./0003-nvidia-cudart-a-systempath.patch {
cudaToolkitIncludeDirs = "${lib.getInclude cudaPackages.cuda_cudart}/include";
})
(substituteAll {
src = ./0004-nvidia-allow-static-ptxas-path.patch;
(replaceVars ./0004-nvidia-allow-static-ptxas-path.patch {
nixpkgsExtraBinaryPaths = lib.escapeShellArgs [ (lib.getExe' cudaPackages.cuda_nvcc "ptxas") ];
})
];

View File

@ -244,7 +244,7 @@ rec {
lib,
callPackage,
mitm-cache,
substituteAll,
replaceVars,
symlinkJoin,
concatTextFile,
makeSetupHook,
@ -264,11 +264,10 @@ rec {
name = "setup-hook.sh";
files = [
(mitm-cache.setupHook)
(substituteAll {
src = ./setup-hook.sh;
(replaceVars ./setup-hook.sh {
# jdk used for keytool
inherit (gradle) jdk;
init_script = ./init-build.gradle;
init_script = "${./init-build.gradle}";
})
];
}))

View File

@ -2,7 +2,7 @@
lib,
stdenv,
fetchurl,
substituteAll,
replaceVars,
nixosTests,
docbook_xml_dtd_45,
@ -65,8 +65,7 @@ stdenv.mkDerivation (finalAttrs: {
./respect-xml-catalog-files-var.patch
# Hardcode paths
(substituteAll {
src = ./fix-paths.patch;
(replaceVars ./fix-paths.patch {
brz = "${breezy}/bin/brz";
cp = "${coreutils}/bin/cp";
patch = "${patch}/bin/patch";
@ -81,8 +80,7 @@ stdenv.mkDerivation (finalAttrs: {
euelfcompress = "${elfutils}/bin/eu-elfcompress";
})
(substituteAll {
src = ./fix-test-paths.patch;
(replaceVars ./fix-test-paths.patch {
inherit glibcLocales;
})
./fix-test-prefix.patch

View File

@ -5,7 +5,7 @@
skip_without_python2 () {
- if ! test -f /usr/bin/python2 || ! /usr/bin/python2 -c "import sys; sys.exit(0 if sys.version_info >= (2, 7) else 1)" ; then
+ if ! test -f @python2@/bin/python2 || ! @python2@/bin/python2 -c "import sys; sys.exit(0 if sys.version_info >= (2, 7) else 1)" ; then
+ if true ; then
echo "1..0 # SKIP this test requires /usr/bin/python2 (2.7) support"
exit 0
fi

View File

@ -12,7 +12,7 @@ outer@{
nixosTests,
installShellFiles,
substituteAll,
replaceVars,
removeReferencesTo,
gd,
geoip,
@ -40,7 +40,7 @@ outer@{
buildInputs ? [ ],
extraPatches ? [ ],
fixPatch ? p: p,
postPatch ? "",
postPatch ? null,
preConfigure ? "",
preInstall ? "",
postInstall ? "",
@ -214,12 +214,7 @@ stdenv.mkDerivation {
patches =
map fixPatch (
[
(substituteAll {
src = ./nix-etag-1.15.4.patch;
preInstall = ''
export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}"
'';
})
./nix-etag-1.15.4.patch
./nix-skip-check-logs-path.patch
]
++
@ -255,7 +250,11 @@ stdenv.mkDerivation {
)
++ extraPatches;
inherit postPatch;
postPatch = lib.defaultTo ''
substituteInPlace src/http/ngx_http_core_module.c \
--replace-fail '@nixStoreDir@' "$NIX_STORE" \
--replace-fail '@nixStoreDirLen@' "''${#NIX_STORE}"
'' postPatch;
hardeningEnable = lib.optional (!stdenv.hostPlatform.isDarwin) "pie";

View File

@ -39,6 +39,10 @@ callPackage ../nginx/generic.nix args rec {
buildInputs = [ postgresql ];
postPatch = ''
substituteInPlace bundle/nginx-${nginxVersion}/src/http/ngx_http_core_module.c \
--replace-fail '@nixStoreDir@' "$NIX_STORE" \
--replace-fail '@nixStoreDirLen@' "''${#NIX_STORE}"
patchShebangs configure bundle/
'';

View File

@ -8,7 +8,7 @@
libxcrypt,
libxml2,
libxslt,
substituteAll,
replaceVars,
gd,
geoip,
gperftools,
@ -48,17 +48,17 @@ stdenv.mkDerivation rec {
jemalloc
] ++ lib.concatMap (mod: mod.inputs or [ ]) modules;
patches =
lib.singleton (substituteAll {
src = ../nginx/nix-etag-1.15.4.patch;
preInstall = ''
export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}"
'';
})
++ [
./check-resolv-conf.patch
../nginx/nix-skip-check-logs-path.patch
];
patches = [
../nginx/nix-etag-1.15.4.patch
./check-resolv-conf.patch
../nginx/nix-skip-check-logs-path.patch
];
postPatch = ''
substituteInPlace src/http/ngx_http_core_module.c \
--replace-fail '@nixStoreDir@' "$NIX_STORE" \
--replace-fail '@nixStoreDirLen@' "''${#NIX_STORE}"
'';
configureFlags =
[