From bfb147b6a8c4a3ddc581aab0b8a29b418db3b7a6 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 15 Jan 2017 18:03:59 -0500 Subject: [PATCH] top-level: Only splice as needed for performance --- pkgs/stdenv/booter.nix | 13 ++++++------- pkgs/top-level/splice.nix | 11 +++++++++-- pkgs/top-level/stage.nix | 8 +++++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 6e5d073e55a7..2c82d12da95d 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -63,12 +63,11 @@ stageFuns: let __bootPackages = finalSoFar; }; }; - self = - if args.__raw or false - then args' - else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // { - buildPackages = if args.selfBuild or true then self else finalSoFar; - }); - in self; + in + if args.__raw or false + then args' + else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // { + buildPackages = if args.selfBuild or true then null else finalSoFar; + }); in lib.lists.fold folder {} withAllowCustomOverrides diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix index f57f42020c27..7afbd956d5bb 100644 --- a/pkgs/top-level/splice.nix +++ b/pkgs/top-level/splice.nix @@ -17,7 +17,11 @@ # `mkDerivation` knows how to pull out the right ones for `buildDepends` and # friends, but a few packages use them directly, so it seemed efficient (to # @Ericson2314) to reuse those names, at least initially, to minimize breakage. -lib: pkgs: +# +# For performance reasons, rather than uniformally splice in all cases, we only +# do so when `pkgs` and `buildPackages` are distinct. The `actuallySplice` +# parameter there the boolean value of that equality check. +lib: pkgs: actuallySplice: let defaultBuildScope = pkgs.buildPackages // pkgs.buildPackages.xorg; @@ -58,7 +62,10 @@ let }; in lib.listToAttrs (map merge (lib.attrNames mash)); - splicedPackages = splicer defaultBuildScope defaultRunScope; + splicedPackages = + if actuallySplice + then splicer defaultBuildScope defaultRunScope + else pkgs // pkgs.xorg; in diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 0f3d967a0914..6febedb79f3d 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -45,7 +45,8 @@ ## Other parameters ## -, # The package set used at build-time +, # The package set used at build-time. If null, `buildPackages` will + # be defined internally as the produced package set as itself. buildPackages , # The standard environment to use for building packages. @@ -84,7 +85,8 @@ let }; stdenvBootstappingAndPlatforms = self: super: { - buildPackages = buildPackages // { recurseForDerivations = false; }; + buildPackages = (if buildPackages == null then self else buildPackages) + // { recurseForDerivations = false; }; inherit stdenv buildPlatform hostPlatform targetPlatform; }; @@ -103,7 +105,7 @@ let inherit (buildPlatform) system platform; }; - splice = self: super: import ./splice.nix lib self; + splice = self: super: import ./splice.nix lib self (buildPackages != null); allPackages = self: super: let res = import ./all-packages.nix