Commit Graph

5 Commits

Author SHA1 Message Date
Alois Wohlschlager
965289e5e0 replaceDependencies: do not build unused replacements
To prevent excessive build times when replacement lists are shared between
partially overlapping closures, skip the build of unused replacements.
Unfortunately, this also means that the replacement won't be applied any more
if another replacement that is applied introduces its source. But this is a
corner case, and we already show a warning, so make it clearer that handling
this situation (should it ever arise) is the responsibility of the user.
2024-09-24 12:20:15 +02:00
Alois Wohlschlager
6fc0699003 replaceDependencies: show warnings as such 2024-09-24 12:20:15 +02:00
Alois Wohlschlager
3616cfb8d9 replaceDependencies: add support for ca-derivations
Unlike regular input-addressed or fixed-output derivations, floating and
deferred derivations do not have their store path available at evaluation time,
so their outPath is a placeholder. The following changes are needed for
replaceDependencies to continue working:
* Detect the placeholder and retrieve the store path using another IFD hack
  when collecting the rewrite plan.
* Try to obtain the derivation name needed for replaceDirectDependencies from
  the derivation arguments if a placeholder is detected.
* Move the length mismatch detection to build time, since the placeholder has a
  fixed length which is unrelated to the store path.
2024-09-24 12:20:15 +02:00
Alois Wohlschlager
59ca239d1a replaceDirectDependencies: split off from replaceDependencies
This allows both swapping out and reusing the rewrite machinery.
2024-09-24 12:20:15 +02:00
Alois Wohlschlager
af3a3f64df replaceDependencies: evolve from replaceDependency
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: https://github.com/NixOS/nixpkgs/issues/199162
2024-09-24 12:20:15 +02:00