various: fix some substituteAll / replace with replaceVars (#376792)

This commit is contained in:
Wolfgang Walther
2025-01-28 20:13:11 +01:00
committed by GitHub
9 changed files with 57 additions and 64 deletions
+7 -5
View File
@@ -4,7 +4,7 @@
fetchFromGitHub,
fish,
runtimeShell,
substituteAll,
replaceVars,
}:
stdenv.mkDerivation (finalAttrs: {
@@ -38,14 +38,16 @@ stdenv.mkDerivation (finalAttrs: {
cp -vr * $out/share/oh-my-fish
cp -v ${
substituteAll {
name = "omf-install";
src = ./omf-install;
omf = placeholder "out";
replaceVars ./omf-install {
inherit fish runtimeShell;
# replaced below
omf = null;
}
} $out/bin/omf-install
substituteInPlace $out/bin/omf-install \
--replace-fail '@omf@' "$out"
chmod +x $out/bin/omf-install
cat $out/bin/omf-install
@@ -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";
})
];
@@ -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") ];
})
];
@@ -246,7 +246,7 @@ rec {
lib,
callPackage,
mitm-cache,
substituteAll,
replaceVars,
symlinkJoin,
concatTextFile,
makeSetupHook,
@@ -266,11 +266,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}";
})
];
}))
@@ -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
@@ -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
+8 -9
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";
+4
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/
'';
+12 -12
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 =
[