Skip to content

replaceVars: work around content-addressed output path shenanigans#439003

Closed
timschumi wants to merge 1 commit intoNixOS:masterfrom
timschumi:replacevar-ca
Closed

replaceVars: work around content-addressed output path shenanigans#439003
timschumi wants to merge 1 commit intoNixOS:masterfrom
timschumi:replacevar-ca

Conversation

@timschumi
Copy link
Copy Markdown
Member

@timschumi timschumi commented Aug 31, 2025

The placeholder output paths in content-addressed derivations lack the derivation name (NixOS/nix#12361), 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 without many unneeded ill effects.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

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.
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 31, 2025
@nix-owners nix-owners Bot requested a review from philiptaron August 31, 2025 20:25
@LunNova
Copy link
Copy Markdown
Member

LunNova commented Aug 31, 2025

Is this a common issue? rocmPackages' llvm is only doing the path filtering as a workaround for #375431 - it removes and then reapplies the same patch to avoid a non-overridden LLVM sneaking in.

@timschumi
Copy link
Copy Markdown
Member Author

I'm not sure if the issue would be considered "common", but it certainly is an issue. However, I'd expect that most cases of patches being filtered are hidden in out-of-tree in nixpkgs overlays.

That said, if there is another possible workaround to this that I missed that would be considered less intrusive then I'm all ears, because on my testing configuration this patch causes ~2700 derivations to be reevaluated.

Copy link
Copy Markdown
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix this in the rocmModules definition. Much of what I read in pkgs/development/rocm-modules/6/llvm/default.nix makes me believe that #421201 ought to be merged. Since this is all code within Nixpkgs, surely we can concoct a better interface between the LLVM derivations and the ROCm transformations on them than observing the store paths. Turning off content-addressed derivation support for replaceVars instead seems backwards to me.

preferLocalBuild = true;
allowSubstitutes = false;

# Due to NixOS/nix#12361 the placeholder paths of content-addressed derivations
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This meta-issue doesn't actually explain the behavior here described. Is there a more specific issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen anything that would be more specific than "this output path has a weird format", and this seemed to have been the only issue relating to this in the nix namespace. But probably a moot discussion point anyway, since we ideally want to fix this without disabling the described behavior.

@wolfgangwalther
Copy link
Copy Markdown
Contributor

Let's fix this in the rocmModules definition. [...] Turning off content-addressed derivation support for replaceVars instead seems backwards to me.

Very much agree.

@LunNova
Copy link
Copy Markdown
Member

LunNova commented Sep 1, 2025

Sorry for that mess :c Fixing it there makes more sense to me too.

I think it'd only make sense to apply a workaround in replaceVars if running into this in out-of-tree overrides is common and preventing people testing enabling content addressing by default.

@philiptaron
Copy link
Copy Markdown
Contributor

There's nothing about replaceVars that conflict with content addressed derivations. What conflicts is existing derivation code (in this case, the override named above) that makes assumptions about how store paths are named, and locks in the pre-CA naming algorithm. Hyrum's law applies. This build helper is an innocent bystander.

As I read it, anyway.

@timschumi
Copy link
Copy Markdown
Member Author

Closing in favor of whatever other solution we can come up with.

@timschumi timschumi closed this Sep 1, 2025
@timschumi
Copy link
Copy Markdown
Member Author

I think it'd only make sense to apply a workaround in replaceVars if running into this in out-of-tree overrides is common and preventing people testing enabling content addressing by default.

If ROCm is indeed the only group of packages that does this then I suppose that is preferable, I don't have the experience or the Nix grepping skills to confirm that, so I opted for putting up the all-encompassing solution for debate. For out-of-tree overrides we probably don't have very accurate metrics, right?

This build helper is an innocent bystander. As I read it, anyway.

Indeed it is, the original description also mentions that all of this really isn't replaceVars fault.

@LunNova
Copy link
Copy Markdown
Member

LunNova commented Sep 5, 2025

#436350 changes the LLVM package set to be an overrideable scope which will allow overrides on top of it not to rely on filtering out and reapplying patches, probably resolving this issue. Does that sound good @timschumi?

@timschumi
Copy link
Copy Markdown
Member Author

#436350 changes the LLVM package set to be an overrideable scope which will allow overrides on top of it not to rely on filtering out and reapplying patches, probably resolving this issue. Does that sound good @timschumi?

I'm not up-to-date enough on overridable scopes to judge that, from looking at the PR I can only tell that neither findClangNostdlibincPatch nor its usage is removed, so I assume that PR alone won't yet fix it by itself. If adding overridable scopes adds some magic behavior (that I am not aware of) that does not require writing out the full patch list verbatim in ROCm then I guess it will resolve the issue, yes.

@timschumi
Copy link
Copy Markdown
Member Author

That said, I'll obviously be happy to retest as required, since I have the build output locally already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants