mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-30 08:00:59 +00:00
replaceDependencies: only resolve newDependency if drv depends on it
Flips the if statements in relevantReplacements, so that newDependency is only evailuated if drv depends on oldDependency it replaces.
This commit is contained in:
@@ -123,17 +123,17 @@ let
|
||||
rootReferences = referencesOf drv;
|
||||
relevantReplacements = filter (
|
||||
{ oldDependency, newDependency }:
|
||||
if toString oldDependency == toString newDependency then
|
||||
warn "replaceDependencies: attempting to replace dependency ${oldDependency} of ${drv} with itself"
|
||||
# Attempting to replace a dependency by itself is completely useless, and would only lead to infinite recursion.
|
||||
# Hence it must not be attempted to apply this replacement in any case.
|
||||
false
|
||||
else if !hasAttr (realisation oldDependency) rootReferences then
|
||||
if !hasAttr (realisation oldDependency) rootReferences then
|
||||
warn "replaceDependencies: ${drv} does not depend on ${oldDependency}, so it will not be replaced"
|
||||
# Strictly speaking, another replacement could introduce the dependency.
|
||||
# However, handling this corner case would add significant complexity.
|
||||
# So we just leave it to the user to apply the replacement at the correct place, but show a warning to let them know.
|
||||
false
|
||||
else if toString oldDependency == toString newDependency then
|
||||
warn "replaceDependencies: attempting to replace dependency ${oldDependency} of ${drv} with itself"
|
||||
# Attempting to replace a dependency by itself is completely useless, and would only lead to infinite recursion.
|
||||
# Hence it must not be attempted to apply this replacement in any case.
|
||||
false
|
||||
else
|
||||
true
|
||||
) replacements;
|
||||
|
||||
Reference in New Issue
Block a user