mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
nixos/top-level: improve replaceRuntimeDependencies
Instead of iterating over all replacements and applying them one by one, use the newly introduced replaceDependencies function to apply them all at once for replaceRuntimeDependencies. The advantages are twofold in case there are multiple replacements: * Performance is significantly improved, because there is only one pass over the closure to be made. * Correctness is improved, because replaceDependencies also replaces dependencies of the replacements themselves if applicable. Fixes: https://github.com/NixOS/nixpkgs/issues/4336
This commit is contained in:
committed by
Yureka
parent
af3a3f64df
commit
d3abae8dee
@@ -68,9 +68,17 @@ let
|
||||
else showWarnings config.warnings baseSystem;
|
||||
|
||||
# Replace runtime dependencies
|
||||
system = foldr ({ oldDependency, newDependency }: drv:
|
||||
pkgs.replaceDependency { inherit oldDependency newDependency drv; }
|
||||
) baseSystemAssertWarn config.system.replaceRuntimeDependencies;
|
||||
system = let replacements = config.system.replaceRuntimeDependencies; in
|
||||
if replacements == [] then
|
||||
# Avoid IFD if possible, by sidestepping replaceDependencies if no replacements are specified.
|
||||
baseSystemAssertWarn
|
||||
else
|
||||
(pkgs.replaceDependencies.override {
|
||||
nix = config.nix.package;
|
||||
}) {
|
||||
drv = baseSystemAssertWarn;
|
||||
inherit replacements;
|
||||
};
|
||||
|
||||
systemWithBuildDeps = system.overrideAttrs (o: {
|
||||
systemBuildClosure = pkgs.closureInfo { rootPaths = [ system.drvPath ]; };
|
||||
|
||||
Reference in New Issue
Block a user