splice.nix: improve performance with early cut-off (#350295)

This commit is contained in:
Artturin 2024-10-31 18:42:15 +02:00 committed by GitHub
commit 6977b4cdab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,6 +128,15 @@ let
"packages" "packages"
]; ];
packagesWithXorg = pkgs // builtins.removeAttrs pkgs.xorg [
"callPackage"
"newScope"
"overrideScope"
"packages"
];
pkgsForCall = if actuallySplice then splicedPackagesWithXorg else packagesWithXorg;
in in
{ {
@ -138,9 +147,9 @@ in
# `newScope' for sets of packages in `pkgs' (see e.g. `gnome' below). # `newScope' for sets of packages in `pkgs' (see e.g. `gnome' below).
callPackage = pkgs.newScope { }; callPackage = pkgs.newScope { };
callPackages = lib.callPackagesWith splicedPackagesWithXorg; callPackages = lib.callPackagesWith pkgsForCall;
newScope = extra: lib.callPackageWith (splicedPackagesWithXorg // extra); newScope = extra: lib.callPackageWith (pkgsForCall // extra);
# prefill 2 fields of the function for convenience # prefill 2 fields of the function for convenience
makeScopeWithSplicing = lib.makeScopeWithSplicing splicePackages pkgs.newScope; makeScopeWithSplicing = lib.makeScopeWithSplicing splicePackages pkgs.newScope;
@ -169,5 +178,5 @@ in
# Haskell package sets need this because they reimplement their own # Haskell package sets need this because they reimplement their own
# `newScope`. # `newScope`.
__splicedPackages = splicedPackages // { recurseForDerivations = false; }; __splicedPackages = if actuallySplice then splicedPackages // { recurseForDerivations = false; } else pkgs;
} }