From 6f665a1dab40145f3775d8711e837299a5026b78 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 31 Aug 2025 22:01:35 +0200 Subject: [PATCH] replaceVars: work around content-addressed output path shenanigans The placeholder output paths in content-addressed derivations lack the derivation name, which breaks the general assumption that we could filter them using said name (e.g. when adjusting patch sets). This is not really the fault of `replaceVar`, but the combination of it together with a patch seems common enough that we can just work around this here. --- .../replace-vars/replace-vars-with.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/build-support/replace-vars/replace-vars-with.nix b/pkgs/build-support/replace-vars/replace-vars-with.nix index 42be45b6dcf1d..081487a79ad6c 100644 --- a/pkgs/build-support/replace-vars/replace-vars-with.nix +++ b/pkgs/build-support/replace-vars/replace-vars-with.nix @@ -82,6 +82,25 @@ let preferLocalBuild = true; allowSubstitutes = false; + # Due to NixOS/nix#12361 the placeholder paths of content-addressed derivations + # do not follow the expected format, it lacks the `storeDir` and (more importantly) + # the `name`. + # This breaks assumptions of some downstream users of replaceVars, notably being able + # to filter out patches using their name: + # $ nix build -f. rocmPackages.clang --arg config '{ contentAddressedByDefault = true; }' + # [...] + # > applying patch /nix/store/8va99vng26z2pqlhvsva787rkqnqw8j4-clang-at-least-16-LLVMgold-path.patch + # > patching file lib/Driver/ToolChains/CommonArgs.cpp + # > Hunk #1 succeeded at 775 (offset 186 lines). + # [...] + # > applying patch /nix/store/8va99vng26z2pqlhvsva787rkqnqw8j4-clang-at-least-16-LLVMgold-path.patch + # > patching file lib/Driver/ToolChains/CommonArgs.cpp + # > Reversed (or previously applied) patch detected! Assume -R? [n] + # > Apply anyway? [n] + # > Skipping patch. + # > 1 out of 1 hunk ignored -- saving rejects to file lib/Driver/ToolChains/CommonArgs.cpp.rej + __contentAddressed = false; + buildPhase = '' runHook preBuild