Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaceDependency can't be used in pure evaluation mode #199162

Closed
ncfavier opened this issue Nov 2, 2022 · 2 comments · Fixed by #257234
Closed

replaceDependency can't be used in pure evaluation mode #199162

ncfavier opened this issue Nov 2, 2022 · 2 comments · Fixed by #257234
Labels
0.kind: bug Something is broken

Comments

@ncfavier
Copy link
Member

ncfavier commented Nov 2, 2022

As noticed by @yu-re-ka, trying to use pkgs.replaceDependency (or system.replaceRuntimeDependencies in NixOS) in pure evaluation mode results in an error because builtins.storePath is used.

From looking at the source, I couldn't figure out why we need storePath at all. It seems like manipulating context-discarded strings would be enough?

However I'm having trouble testing this because for some reason my system.build.toplevel.outPath is something like /0apn2h3i9xvwfaac83238x97plr9dsn33pxlj7f5mdblc7f6bg9i (which looks like the sort of string that builtins.placeholder produces) instead of an actual store path, so I just get a warning that the placeholder does not depend on $oldDependency. Any idea what's going on here?

ping @shlevy @roconnor

@ncfavier ncfavier added the 0.kind: bug Something is broken label Nov 2, 2022
@ncfavier
Copy link
Member Author

ncfavier commented Nov 2, 2022

Okay, I tested it with a different derivation and it seems to work. Hm, but now the rewritten derivation has no runtime dependency on the original one. That's not great.

alois31 added a commit to alois31/nixpkgs that referenced this issue Jan 27, 2024
Rewrite replaceDependency so that it can apply multiple replacements in
one go. This includes correctly handling the case where one of the
replacements itself needs to have another replacement applied as well.
This rewritten function is now aptly called replaceDependencies.

For compatibility, replaceDependency is retained as a simple wrapper
over replaceDependencies. It will cause a rebuild because the unpatched
dependency is now referenced by derivation instead of by storePath, but
the functionality is equivalent.

Fixes: NixOS#199162
alois31 added a commit to alois31/nixpkgs that referenced this issue Feb 27, 2024
Rewrite replaceDependency so that it can apply multiple replacements in
one go. This includes correctly handling the case where one of the
replacements itself needs to have another replacement applied as well.
This rewritten function is now aptly called replaceDependencies.

For compatibility, replaceDependency is retained as a simple wrapper
over replaceDependencies. It will cause a rebuild because the unpatched
dependency is now referenced by derivation instead of by storePath, but
the functionality is equivalent.

Fixes: NixOS#199162
@aikooo7
Copy link
Contributor

aikooo7 commented Apr 4, 2024

Any update? Right now replaceDependency is completely unusable if using flakes unless using --impure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants