From 9444d6e6ded8c281174599c6c1e7281e956896b6 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 19:48:01 +0000 Subject: [PATCH 01/44] Split miss-indented last lines. to simplify future diffs. --- pkgs/top-level/all-packages.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 54a2ee0b8f43..2fd1cb51ac31 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16478,4 +16478,8 @@ tweakAlias = _n: alias: with lib; removeAttrs alias ["recurseForDerivations"] else alias; -in lib.mapAttrs tweakAlias aliases // self; in pkgs +in + lib.mapAttrs tweakAlias aliases // self; + +in + pkgs From a39c5ff0d891d451a9ce08cab7ff99942664cc72 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 20:18:03 +0000 Subject: [PATCH 02/44] Re-indent the top of pkgsFun. --- pkgs/top-level/all-packages.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2fd1cb51ac31..4cc95221e30c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -126,8 +126,10 @@ let # The package compositions. Yes, this isn't properly indented. pkgsFun = pkgs: overrides: with helperFunctions; - let defaultScope = pkgs // pkgs.xorg; self = self_ // overrides; - self_ = with self; helperFunctions // { + let + defaultScope = pkgs // pkgs.xorg; + self = self_ // overrides; + self_ = with self; helperFunctions // { # Make some arguments passed to all-packages.nix available inherit system platform; From 11a566b5bc9cb90619df16170f47c9acac8eb57d Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 20:19:44 +0000 Subject: [PATCH 03/44] Move 'with helperFunctions' above the set of all packages. --- pkgs/top-level/all-packages.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4cc95221e30c..c5c4820b584e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -125,11 +125,10 @@ let # The package compositions. Yes, this isn't properly indented. pkgsFun = pkgs: overrides: - with helperFunctions; let defaultScope = pkgs // pkgs.xorg; self = self_ // overrides; - self_ = with self; helperFunctions // { + self_ = with self; helperFunctions // (with helperFunctions; { # Make some arguments passed to all-packages.nix available inherit system platform; @@ -16470,7 +16469,7 @@ let mg = callPackage ../applications/editors/mg { }; -}; # self_ = +}); # self_ = aliases = import ./aliases.nix self; From 5f4cb91a1c022ca20f47ff189dfa0e4c98e5b592 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 20:22:15 +0000 Subject: [PATCH 04/44] Move helperfunctions and stdenvAdapters under pkgsFun. The `helperFunctions` and `stdenvAdapters` both use the `pkgs` attribute as input, either to inherit some properties, either to use it as argument. The `pkgs` binding used in both expressions of the `helperFunctions` and `stdenvAdapters` is no longer the result of the `applyGlobalOverrides` function, but the argument of the `pkgsFun` function. The `pkgsFun` functions is called twice under `applyGlobalOverrides`, and in both cases, the first argument of `pkgsFun` correspond to the result of `applyGlobalOverrides`. Thus, this modification will change the bindings, but the evaluation of ``. A third call the `pkgsFun` exists under `overridePackages` in the set of all packages. Previously, the `helperFunctions` and `stdenvAdapaters` would use the functions defined as part of the default `` set. With this modification, the `helperFunctions` and the `stdenvAdapters` are now using the fix-point of the newly evaluated package set. This implies that this modification allow the user to use `overridePackages`, which is already not recommended for performance reasons, to override the inputs of the `helperFucntions` and `stdenvAdapaters` too, where this was not possible before. --- pkgs/top-level/all-packages.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c5c4820b584e..0a80c5b48d22 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -83,15 +83,6 @@ let platform = if platform_ != null then platform_ else config.platform or platformAuto; - # Helper functions that are exported through `pkgs'. - helperFunctions = - stdenvAdapters // - (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); - - stdenvAdapters = - import ../stdenv/adapters.nix pkgs; - - # Allow packages to be overriden globally via the `packageOverrides' # configuration option, which must be a function that takes `pkgs' # as an argument and returns a set of new or overriden packages. @@ -128,6 +119,15 @@ let let defaultScope = pkgs // pkgs.xorg; self = self_ // overrides; + + # Helper functions that are exported through `pkgs'. + helperFunctions = + stdenvAdapters // + (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); + + stdenvAdapters = + import ../stdenv/adapters.nix pkgs; + self_ = with self; helperFunctions // (with helperFunctions; { # Make some arguments passed to all-packages.nix available From f9a29887fe5e8c6205a982ef3fed4b77553c43b9 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 21:03:22 +0000 Subject: [PATCH 05/44] Move pkgsOrig outside applyGlobalOverrides and provide it as argument. --- pkgs/top-level/all-packages.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0a80c5b48d22..1f8b04a83504 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -90,15 +90,18 @@ let # (un-overriden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - pkgs = applyGlobalOverrides (config.packageOverrides or (pkgs: {})); + pkgs = applyGlobalOverrides pkgsInit (config.packageOverrides or (pkgs: {})); mkOverrides = pkgsOrig: overrides: overrides // (lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig)); + # The un-overriden packages, passed to `overrider'. + pkgsInit = pkgsFun pkgs {}; + # Return the complete set of packages, after applying the overrides # returned by the `overrider' function (see above). Warning: this # function is very expensive! - applyGlobalOverrides = overrider: + applyGlobalOverrides = pkgsOrig: overrider: let # Call the overrider function. We don't want stdenv overrides # in the case of cross-building, or otherwise the basic @@ -106,9 +109,6 @@ let # adapter. overrides = mkOverrides pkgsOrig (overrider pkgsOrig); - # The un-overriden packages, passed to `overrider'. - pkgsOrig = pkgsFun pkgs {}; - # The overriden, final packages. pkgs = pkgsFun pkgs overrides; in pkgs; From a6e260c91f38dacbc42a08273101f222276075b7 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 21:05:03 +0000 Subject: [PATCH 06/44] Add an extra argument to the overrider function of applyGlobalOverrides. --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1f8b04a83504..bda8ff62c56f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -90,7 +90,7 @@ let # (un-overriden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - pkgs = applyGlobalOverrides pkgsInit (config.packageOverrides or (pkgs: {})); + pkgs = applyGlobalOverrides pkgsInit (self: config.packageOverrides or (super: {})); mkOverrides = pkgsOrig: overrides: overrides // (lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig)); @@ -107,7 +107,7 @@ let # in the case of cross-building, or otherwise the basic # overrided packages will not be built with the crossStdenv # adapter. - overrides = mkOverrides pkgsOrig (overrider pkgsOrig); + overrides = mkOverrides pkgsOrig (overrider pkgs pkgsOrig); # The overriden, final packages. pkgs = pkgsFun pkgs overrides; From a5188bda7b008c942ae58a43a2d4d0b9d3ba4ebc Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 21:07:13 +0000 Subject: [PATCH 07/44] Unify the applyGlobalOverride function with the overridePackages function. --- pkgs/top-level/all-packages.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bda8ff62c56f..b40014a2e75e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -158,11 +158,7 @@ let # # The result is `pkgs' where all the derivations depending on `foo' # will use the new version. - overridePackages = f: - let - newpkgs = pkgsFun newpkgs overrides; - overrides = mkOverrides pkgs (f newpkgs pkgs); - in newpkgs; + overridePackages = f: applyGlobalOverrides pkgs f; # Override system. This is useful to build i686 packages on x86_64-linux. forceSystem = system: kernel: (import ./../..) { From 00963c3dfdab7fbcc3e2a9db6df47cea25d46688 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 17 Mar 2016 21:24:53 +0000 Subject: [PATCH 08/44] Extract stdenvOverrides function out of mkOverrides function. --- pkgs/top-level/all-packages.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b40014a2e75e..b7d688855074 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -92,8 +92,14 @@ let # ... pkgs.foo ..."). pkgs = applyGlobalOverrides pkgsInit (self: config.packageOverrides or (super: {})); - mkOverrides = pkgsOrig: overrides: overrides // - (lib.optionalAttrs (pkgsOrig.stdenv ? overrides && crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig)); + mkOverrides = pkgs: overrides: overrides // stdenvOverrides pkgs; + + # stdenvOverrides is used to avoid circular dependencies for building the + # standard build environment. This mechanism use the override mechanism to + # implement some staged compilation of the stdenv. + stdenvOverrides = pkgs: + lib.optionalAttrs (pkgs.stdenv ? overrides && crossSystem == null) + (pkgs.stdenv.overrides pkgs); # The un-overriden packages, passed to `overrider'. pkgsInit = pkgsFun pkgs {}; From acaa99cbd2db20fad9ee63118d0828f0f237709a Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 18 Mar 2016 20:36:00 +0000 Subject: [PATCH 09/44] Move applyGlobalOverrides comment to stdenvOverrides, where it fits better. --- pkgs/top-level/all-packages.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b7d688855074..1798b120cd10 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -97,6 +97,10 @@ let # stdenvOverrides is used to avoid circular dependencies for building the # standard build environment. This mechanism use the override mechanism to # implement some staged compilation of the stdenv. + # + # We don't want stdenv overrides in the case of cross-building, or + # otherwise the basic overrided packages will not be built with the + # crossStdenv adapter. stdenvOverrides = pkgs: lib.optionalAttrs (pkgs.stdenv ? overrides && crossSystem == null) (pkgs.stdenv.overrides pkgs); @@ -109,10 +113,6 @@ let # function is very expensive! applyGlobalOverrides = pkgsOrig: overrider: let - # Call the overrider function. We don't want stdenv overrides - # in the case of cross-building, or otherwise the basic - # overrided packages will not be built with the crossStdenv - # adapter. overrides = mkOverrides pkgsOrig (overrider pkgs pkgsOrig); # The overriden, final packages. From 71b2fd92b3be82291563699a94a795b8becd5a65 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 18 Mar 2016 20:56:40 +0000 Subject: [PATCH 10/44] Move mkOverrides under applyGlobalOverrides. --- pkgs/top-level/all-packages.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1798b120cd10..eb30c460d475 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -92,8 +92,6 @@ let # ... pkgs.foo ..."). pkgs = applyGlobalOverrides pkgsInit (self: config.packageOverrides or (super: {})); - mkOverrides = pkgs: overrides: overrides // stdenvOverrides pkgs; - # stdenvOverrides is used to avoid circular dependencies for building the # standard build environment. This mechanism use the override mechanism to # implement some staged compilation of the stdenv. @@ -113,13 +111,14 @@ let # function is very expensive! applyGlobalOverrides = pkgsOrig: overrider: let + mkOverrides = pkgs: overrides: overrides // stdenvOverrides pkgs; + overrides = mkOverrides pkgsOrig (overrider pkgs pkgsOrig); # The overriden, final packages. pkgs = pkgsFun pkgs overrides; in pkgs; - # The package compositions. Yes, this isn't properly indented. pkgsFun = pkgs: overrides: let From a8374f2168e4ad6dda41ae6457feac69614e271b Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 18 Mar 2016 20:58:24 +0000 Subject: [PATCH 11/44] Under applyGlobalOverrides, inline mkOverrides in overrides. --- pkgs/top-level/all-packages.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index eb30c460d475..5f27f94b44c9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -111,9 +111,7 @@ let # function is very expensive! applyGlobalOverrides = pkgsOrig: overrider: let - mkOverrides = pkgs: overrides: overrides // stdenvOverrides pkgs; - - overrides = mkOverrides pkgsOrig (overrider pkgs pkgsOrig); + overrides = overrider pkgs pkgsOrig // stdenvOverrides pkgsOrig; # The overriden, final packages. pkgs = pkgsFun pkgs overrides; From a658645e1e277ecea37ccbdac6c2ce64e55eed13 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 18 Mar 2016 22:54:24 +0000 Subject: [PATCH 12/44] Remove with helperFunction above the list of all packages. This modification change the names bound to the `helperFunctions` attribute set, to be bound to `self` which is constructed by merging the same `helperFunctions` set with the set of all packages. This patch works as expected because none of the helperFunction names is aliased by the name of a package. --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5f27f94b44c9..12ebed19f2d8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -131,7 +131,7 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - self_ = with self; helperFunctions // (with helperFunctions; { + self_ = with self; helperFunctions // { # Make some arguments passed to all-packages.nix available inherit system platform; @@ -16468,7 +16468,7 @@ let mg = callPackage ../applications/editors/mg { }; -}); # self_ = +}; # self_ = aliases = import ./aliases.nix self; From ffcb6682bcc14f70c49949fdcbfbba8841c63e0c Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 19 Mar 2016 14:02:20 +0000 Subject: [PATCH 13/44] Under pkgsFun, move the merge of helper functions from self_ to self. --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 12ebed19f2d8..5d21f1fd9e56 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -121,7 +121,7 @@ let pkgsFun = pkgs: overrides: let defaultScope = pkgs // pkgs.xorg; - self = self_ // overrides; + self = helperFunctions // self_ // overrides; # Helper functions that are exported through `pkgs'. helperFunctions = @@ -131,7 +131,7 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - self_ = with self; helperFunctions // { + self_ = with self; { # Make some arguments passed to all-packages.nix available inherit system platform; From 8d355b8d85b7ce454bca1473bf8cc5aebf8f0c48 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 19 Mar 2016 14:39:48 +0000 Subject: [PATCH 14/44] Under pkgsFun, expand self attribute, and rename self_ to self. Note, the aliases are now computed against the set of packages defined in the set of all packages, and no longer apply to any overriden package. I think this is better as this reduces the amount of surprizes. --- pkgs/top-level/all-packages.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5d21f1fd9e56..fb39447c9995 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -121,7 +121,6 @@ let pkgsFun = pkgs: overrides: let defaultScope = pkgs // pkgs.xorg; - self = helperFunctions // self_ // overrides; # Helper functions that are exported through `pkgs'. helperFunctions = @@ -131,7 +130,7 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - self_ = with self; { + self = with helperFunctions; with self; with overrides; { # Make some arguments passed to all-packages.nix available inherit system platform; @@ -16468,7 +16467,7 @@ let mg = callPackage ../applications/editors/mg { }; -}; # self_ = +}; # self = aliases = import ./aliases.nix self; @@ -16479,7 +16478,7 @@ tweakAlias = _n: alias: with lib; else alias; in - lib.mapAttrs tweakAlias aliases // self; + lib.mapAttrs tweakAlias aliases // helperFunctions // self // overrides; in pkgs From 7f3a4f428746620ca555797f1a7269bb2226e5dc Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 13:15:37 +0000 Subject: [PATCH 15/44] Swap conditions of stdenvOverrides to prevent infinite loops while evaluating stdenvCross. While evaluating the derivation of xbursttools: the condition `pkgs.stdenv ? overrides` causes the evaluation of `stdenvCross`. This evaluation comes too early during the execution, as it prevents the resolution of names such as `pkgs.lib`, and `stdenvAdapaters.makeStdenvCross`, which we want to take from `pkgs` instead of `self` in following patches. By swapping the conditions, we effectively make the resolution of `pkgs.lib` and `stdenvAdapaters.makeStdenvCross` possible through the pkgs attribute. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fb39447c9995..f16a7b6691c6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -100,7 +100,7 @@ let # otherwise the basic overrided packages will not be built with the # crossStdenv adapter. stdenvOverrides = pkgs: - lib.optionalAttrs (pkgs.stdenv ? overrides && crossSystem == null) + lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) (pkgs.stdenv.overrides pkgs); # The un-overriden packages, passed to `overrider'. From 020bb40454712e9149cfce31ba21cf918afb34dc Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 19 Mar 2016 18:11:09 +0000 Subject: [PATCH 16/44] Split stdenv attribute set. Extract stdenvDefault from the set of all packages. As this set of attributes are inter-dependant, probably due to stdenvOverrides, we have to keep them in a close set of inter-dependent options. I guess I will have to investigate more ... --- pkgs/top-level/all-packages.nix | 92 +++++++++++++++++---------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f16a7b6691c6..6d5bf04cfa3e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -130,7 +130,40 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - self = with helperFunctions; with self; with overrides; { + stdenvDefault = with helperFunctions; with self; with overrides; { + + + ### STANDARD ENVIRONMENT + + + allStdenvs = import ../stdenv { + inherit system platform config lib; + allPackages = args: import ./../.. ({ inherit config system; } // args); + }; + + defaultStdenv = allStdenvs.stdenv // { inherit platform; }; + + stdenv = + if bootStdenv != null then (bootStdenv // {inherit platform;}) else + if crossSystem != null then + stdenvCross + else + let + changer = config.replaceStdenv or null; + in if changer != null then + changer { + # We import again all-packages to avoid recursivities. + pkgs = import ./../.. { + # We remove packageOverrides to avoid recursivities + config = removeAttrs config [ "replaceStdenv" ]; + }; + } + else + defaultStdenv; + +}; + + self = with pkgs; stdenvDefault // { # Make some arguments passed to all-packages.nix available inherit system platform; @@ -170,12 +203,24 @@ let crossSystem; }; - # Used by wine, firefox with debugging version of Flash, ... pkgsi686Linux = forceSystem "i686-linux" "i386"; callPackage_i686 = lib.callPackageWith (pkgsi686Linux // pkgsi686Linux.xorg); + forceNativeDrv = drv : if crossSystem == null then drv else + (drv // { crossDrv = drv.nativeDrv; }); + + stdenvCross = lowPrio (makeStdenvCross defaultStdenv crossSystem binutilsCross gccCrossStageFinal); + + # A stdenv capable of building 32-bit binaries. On x86_64-linux, + # it uses GCC compiled with multilib support; on i686-linux, it's + # just the plain stdenv. + stdenv_32bit = lowPrio ( + if system == "x86_64-linux" then + overrideCC stdenv gcc_multi + else + stdenv); # For convenience, allow callers to get the path to Nixpkgs. path = ../..; @@ -205,49 +250,6 @@ let nixpkgs-lint = callPackage ../../maintainers/scripts/nixpkgs-lint.nix { }; - ### STANDARD ENVIRONMENT - - - allStdenvs = import ../stdenv { - inherit system platform config lib; - allPackages = args: import ./../.. ({ inherit config system; } // args); - }; - - defaultStdenv = allStdenvs.stdenv // { inherit platform; }; - - stdenvCross = lowPrio (makeStdenvCross defaultStdenv crossSystem binutilsCross gccCrossStageFinal); - - stdenv = - if bootStdenv != null then (bootStdenv // {inherit platform;}) else - if crossSystem != null then - stdenvCross - else - let - changer = config.replaceStdenv or null; - in if changer != null then - changer { - # We import again all-packages to avoid recursivities. - pkgs = import ./../.. { - # We remove packageOverrides to avoid recursivities - config = removeAttrs config [ "replaceStdenv" ]; - }; - } - else - defaultStdenv; - - forceNativeDrv = drv : if crossSystem == null then drv else - (drv // { crossDrv = drv.nativeDrv; }); - - # A stdenv capable of building 32-bit binaries. On x86_64-linux, - # it uses GCC compiled with multilib support; on i686-linux, it's - # just the plain stdenv. - stdenv_32bit = lowPrio ( - if system == "x86_64-linux" then - overrideCC stdenv gcc_multi - else - stdenv); - - ### BUILD SUPPORT attrSetToDir = arg: callPackage ../build-support/upstream-updater/attrset-to-dir.nix { From be3531a56e153a4947b4c4b5f22a43e65b174d5e Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 13:46:14 +0000 Subject: [PATCH 17/44] Replace with statements of stdenvDefault to rely on pkgs instead of self. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d5bf04cfa3e..9cb6b371427c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -130,7 +130,7 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - stdenvDefault = with helperFunctions; with self; with overrides; { + stdenvDefault = with pkgs; with stdenvDefault; { ### STANDARD ENVIRONMENT From f7c86ee01841f85b94b3823f381119faf7060810 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 13:47:31 +0000 Subject: [PATCH 18/44] Move merge of stdenvDefault from the self attribute to the returned value of pkgsFun. --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9cb6b371427c..1d120339110d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -163,7 +163,7 @@ let }; - self = with pkgs; stdenvDefault // { + self = with pkgs; { # Make some arguments passed to all-packages.nix available inherit system platform; @@ -16480,7 +16480,7 @@ tweakAlias = _n: alias: with lib; else alias; in - lib.mapAttrs tweakAlias aliases // helperFunctions // self // overrides; + lib.mapAttrs tweakAlias aliases // helperFunctions // stdenvDefault // self // overrides; in pkgs From 0b67f7cb5dfc2b5080b8e3046917a0a15bb5140d Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 14:50:27 +0000 Subject: [PATCH 19/44] Move tweakAlias function into the aliases.nix file, and rename it. --- pkgs/top-level/aliases.nix | 14 +++++++++++++- pkgs/top-level/all-packages.nix | 7 +------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index f2e1bbc5102c..944de7919293 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -2,9 +2,21 @@ self: with self; +let + # Removind recurseForDerivation prevents derivations of aliased attribute + # set to appear while listing all the packages available. + removeRecurseForDerivations = _n: alias: with lib; + if alias.recurseForDerivations or false then + removeAttrs alias ["recurseForDerivations"] + else alias; + + doNotDisplayTwice = aliases: + lib.mapAttrs removeRecurseForDerivations aliases; +in + ### Deprecated aliases - for backward compatibility -rec { +doNotDisplayTwice rec { accounts-qt = qt5.accounts-qt; # added 2015-12-19 adobeReader = adobe-reader; aircrackng = aircrack-ng; # added 2016-01-14 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1d120339110d..188c548050ce 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16474,13 +16474,8 @@ let aliases = import ./aliases.nix self; -tweakAlias = _n: alias: with lib; - if alias.recurseForDerivations or false then - removeAttrs alias ["recurseForDerivations"] - else alias; - in - lib.mapAttrs tweakAlias aliases // helperFunctions // stdenvDefault // self // overrides; + aliases // helperFunctions // stdenvDefault // self // overrides; in pkgs From a09683ed298fc741cc9a80ca2fce57c4c4ead43b Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 14:51:20 +0000 Subject: [PATCH 20/44] Remove unused 'ncat' alias, as a package with the same name already exists. --- pkgs/top-level/aliases.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 944de7919293..c0b93335c80d 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -61,7 +61,6 @@ doNotDisplayTwice rec { mssys = ms-sys; # added 2015-12-13 multipath_tools = multipath-tools; # added 2016-01-21 mupen64plus1_5 = mupen64plus; # added 2016-02-12 - ncat = nmap; # added 2016-01-26 nfsUtils = nfs-utils; # added 2014-12-06 phonon_qt5 = qt5.phonon; # added 2015-12-19 phonon_qt5_backend_gstreamer = qt5.phonon-backend-gstreamer; # added 2015-12-19 From f043ffcea463e3f965283e26b458b5fab5ddbbd9 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 14:52:28 +0000 Subject: [PATCH 21/44] Move the set of aliases after 'self', such that we can later use the extend function. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 188c548050ce..a0bae697db2f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16475,7 +16475,7 @@ let aliases = import ./aliases.nix self; in - aliases // helperFunctions // stdenvDefault // self // overrides; + helperFunctions // stdenvDefault // self // aliases // overrides; in pkgs From 054327729cfe043587f4a0cff86fb4f5f5f20ec5 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 15:14:57 +0000 Subject: [PATCH 22/44] Move stdenvDefault into its own file. --- pkgs/top-level/all-packages.nix | 38 ++++++--------------------------- pkgs/top-level/stdenv.nix | 31 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 pkgs/top-level/stdenv.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a0bae697db2f..f0bb6a7ee7b8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -83,6 +83,11 @@ let platform = if platform_ != null then platform_ else config.platform or platformAuto; + topLevelArguments = { + inherit system bootStdenv noSysDirs gccWithCC gccWithProfiling config + crossSystem platform lib; + }; + # Allow packages to be overriden globally via the `packageOverrides' # configuration option, which must be a function that takes `pkgs' # as an argument and returns a set of new or overriden packages. @@ -130,38 +135,7 @@ let stdenvAdapters = import ../stdenv/adapters.nix pkgs; - stdenvDefault = with pkgs; with stdenvDefault; { - - - ### STANDARD ENVIRONMENT - - - allStdenvs = import ../stdenv { - inherit system platform config lib; - allPackages = args: import ./../.. ({ inherit config system; } // args); - }; - - defaultStdenv = allStdenvs.stdenv // { inherit platform; }; - - stdenv = - if bootStdenv != null then (bootStdenv // {inherit platform;}) else - if crossSystem != null then - stdenvCross - else - let - changer = config.replaceStdenv or null; - in if changer != null then - changer { - # We import again all-packages to avoid recursivities. - pkgs = import ./../.. { - # We remove packageOverrides to avoid recursivities - config = removeAttrs config [ "replaceStdenv" ]; - }; - } - else - defaultStdenv; - -}; + stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; self = with pkgs; { diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix new file mode 100644 index 000000000000..aeb36b8edc35 --- /dev/null +++ b/pkgs/top-level/stdenv.nix @@ -0,0 +1,31 @@ +{ system, bootStdenv, crossSystem, config, platform, lib, ... }: +self: super: + +with super; + +rec { + allStdenvs = import ../stdenv { + inherit system platform config lib; + allPackages = args: import ./../.. ({ inherit config system; } // args); + }; + + defaultStdenv = allStdenvs.stdenv // { inherit platform; }; + + stdenv = + if bootStdenv != null then (bootStdenv // {inherit platform;}) else + if crossSystem != null then + stdenvCross + else + let + changer = config.replaceStdenv or null; + in if changer != null then + changer { + # We import again all-packages to avoid recursivities. + pkgs = import ./../.. { + # We remove packageOverrides to avoid recursivities + config = removeAttrs config [ "replaceStdenv" ]; + }; + } + else + defaultStdenv; +} From 007500f2ece22ab43b6c73e33cb39c4c29221745 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 15:17:34 +0000 Subject: [PATCH 23/44] Move the merge of the overrides from pkgsFun to applyGlobalOverrides. --- pkgs/top-level/all-packages.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f0bb6a7ee7b8..5f94da4b6e40 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -109,7 +109,7 @@ let (pkgs.stdenv.overrides pkgs); # The un-overriden packages, passed to `overrider'. - pkgsInit = pkgsFun pkgs {}; + pkgsInit = pkgsFun pkgs; # Return the complete set of packages, after applying the overrides # returned by the `overrider' function (see above). Warning: this @@ -119,11 +119,11 @@ let overrides = overrider pkgs pkgsOrig // stdenvOverrides pkgsOrig; # The overriden, final packages. - pkgs = pkgsFun pkgs overrides; + pkgs = pkgsFun pkgs // overrides; in pkgs; # The package compositions. Yes, this isn't properly indented. - pkgsFun = pkgs: overrides: + pkgsFun = pkgs: let defaultScope = pkgs // pkgs.xorg; @@ -16449,7 +16449,7 @@ let aliases = import ./aliases.nix self; in - helperFunctions // stdenvDefault // self // aliases // overrides; + helperFunctions // stdenvDefault // self // aliases; in pkgs From 5e3ce6334c5c4fbec260f71e69f02493403aa2eb Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 15:27:14 +0000 Subject: [PATCH 24/44] Remove applyGlobalOverrides's pkgsOrig argument. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch change the behaviour or overridePackages: - Before, overridePackages was based on top of the set of packages overriden by `~/.nixpkgs/config.nix` file. - After, overridePackages should when given a function f, behave almost¹ the same as-if the packageOverrides attribute of `~/.nixpkgs/config.nix` file attribute was set to f, assuming that we ignore the extra `self` argument. ¹ It is not yet exactly the same because we have many paths which are re-entering nixpkgs while taking the default attributes, such as the bootstrap phase of stdenv. Thus if the nixpkgs configuration overrides any of the dependencies need for the bootstrap, then we might get different sha. --- pkgs/top-level/all-packages.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5f94da4b6e40..614978b011d7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -95,7 +95,7 @@ let # (un-overriden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - pkgs = applyGlobalOverrides pkgsInit (self: config.packageOverrides or (super: {})); + pkgs = applyGlobalOverrides (self: config.packageOverrides or (super: {})); # stdenvOverrides is used to avoid circular dependencies for building the # standard build environment. This mechanism use the override mechanism to @@ -108,16 +108,16 @@ let lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) (pkgs.stdenv.overrides pkgs); - # The un-overriden packages, passed to `overrider'. - pkgsInit = pkgsFun pkgs; - # Return the complete set of packages, after applying the overrides # returned by the `overrider' function (see above). Warning: this # function is very expensive! - applyGlobalOverrides = pkgsOrig: overrider: + applyGlobalOverrides = overrider: let overrides = overrider pkgs pkgsOrig // stdenvOverrides pkgsOrig; + # The un-overriden packages, passed to `overrider'. + pkgsOrig = pkgsFun pkgs; + # The overriden, final packages. pkgs = pkgsFun pkgs // overrides; in pkgs; @@ -167,7 +167,7 @@ let # # The result is `pkgs' where all the derivations depending on `foo' # will use the new version. - overridePackages = f: applyGlobalOverrides pkgs f; + overridePackages = f: applyGlobalOverrides f; # Override system. This is useful to build i686 packages on x86_64-linux. forceSystem = system: kernel: (import ./../..) { From 32e96bbb8b05bbc5aecaf4a8edec9a20e150d8cd Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 15:43:27 +0000 Subject: [PATCH 25/44] Within applyGlobalOverrides, alias pkgsFun calls. --- pkgs/top-level/all-packages.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 614978b011d7..778ce916d12b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -113,13 +113,13 @@ let # function is very expensive! applyGlobalOverrides = overrider: let - overrides = overrider pkgs pkgsOrig // stdenvOverrides pkgsOrig; + overrides = super: overrider pkgs super // stdenvOverrides super; # The un-overriden packages, passed to `overrider'. - pkgsOrig = pkgsFun pkgs; + pkgs_ = pkgsFun pkgs; # The overriden, final packages. - pkgs = pkgsFun pkgs // overrides; + pkgs = pkgs_ // overrides pkgs_; in pkgs; # The package compositions. Yes, this isn't properly indented. From 07e549ee5b8b53ecedb8c3932982a1547d8963c6 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 15:54:26 +0000 Subject: [PATCH 26/44] Rename applyGlobalOverrides to pkgsWithOverrides --- pkgs/top-level/all-packages.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 778ce916d12b..119870908064 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -95,7 +95,7 @@ let # (un-overriden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - pkgs = applyGlobalOverrides (self: config.packageOverrides or (super: {})); + pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); # stdenvOverrides is used to avoid circular dependencies for building the # standard build environment. This mechanism use the override mechanism to @@ -111,7 +111,7 @@ let # Return the complete set of packages, after applying the overrides # returned by the `overrider' function (see above). Warning: this # function is very expensive! - applyGlobalOverrides = overrider: + pkgsWithOverrides = overrider: let overrides = super: overrider pkgs super // stdenvOverrides super; @@ -167,7 +167,7 @@ let # # The result is `pkgs' where all the derivations depending on `foo' # will use the new version. - overridePackages = f: applyGlobalOverrides f; + overridePackages = f: pkgsWithOverrides f; # Override system. This is useful to build i686 packages on x86_64-linux. forceSystem = system: kernel: (import ./../..) { From a543a57ab5758d174e6351938a73583091517273 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 16:04:00 +0000 Subject: [PATCH 27/44] Reformat pkgsWithOverrides to later facilitate the identitication with the extend functions. --- pkgs/top-level/all-packages.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 119870908064..769cae55406d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -113,13 +113,13 @@ let # function is very expensive! pkgsWithOverrides = overrider: let - overrides = super: overrider pkgs super // stdenvOverrides super; - # The un-overriden packages, passed to `overrider'. - pkgs_ = pkgsFun pkgs; + pkgs_6 = pkgsFun pkgs; + + pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; # The overriden, final packages. - pkgs = pkgs_ // overrides pkgs_; + pkgs = pkgs_7 // stdenvOverrides pkgs_6; in pkgs; # The package compositions. Yes, this isn't properly indented. From ad317834053983e1bf3b61f58c923ca48a0dd2d7 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 16:28:18 +0000 Subject: [PATCH 28/44] Extract the top-level logic out of all-packages.nix into pkgs/top-level/default.nix --- default.nix | 2 +- pkgs/top-level/all-packages.nix | 155 +++----------------------------- pkgs/top-level/default.nix | 147 ++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 146 deletions(-) create mode 100644 pkgs/top-level/default.nix diff --git a/default.nix b/default.nix index 12c3cf876186..c384a5bb6946 100644 --- a/default.nix +++ b/default.nix @@ -6,4 +6,4 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins. else - import ./pkgs/top-level/all-packages.nix + import ./pkgs/top-level diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 769cae55406d..18fc8b958113 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1,143 +1,16 @@ -/* This file composes the Nix Packages collection. That is, it - imports the functions that build the various packages, and calls - them with appropriate arguments. The result is a set of all the - packages in the Nix Packages collection for some particular - platform. */ +{ system, bootStdenv, noSysDirs, gccWithCC, gccWithProfiling +, config, crossSystem, platform, lib +, pkgsWithOverrides, stdenvAdapters, helperFunctions +, ... }: +self: pkgs: - -{ # The system (e.g., `i686-linux') for which to build the packages. - system ? builtins.currentSystem - -, # The standard environment to use. Only used for bootstrapping. If - # null, the default standard environment is used. - bootStdenv ? null - -, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc - # outside of the store. Thus, GCC, GFortran, & co. must always look for - # files in standard system directories (/usr/include, etc.) - noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd" - && system != "x86_64-solaris" - && system != "x86_64-kfreebsd-gnu") - - # More flags for the bootstrapping of stdenv. -, gccWithCC ? true -, gccWithProfiling ? true - -, # Allow a configuration attribute set to be passed in as an - # argument. Otherwise, it's read from $NIXPKGS_CONFIG or - # ~/.nixpkgs/config.nix. - config ? null - -, crossSystem ? null -, platform ? null -}: - - -let config_ = config; platform_ = platform; in # rename the function arguments +with pkgs; let + defaultScope = pkgs // pkgs.xorg; +in - lib = import ../../lib; - - # The contents of the configuration file found at $NIXPKGS_CONFIG or - # $HOME/.nixpkgs/config.nix. - # for NIXOS (nixos-rebuild): use nixpkgs.config option - config = - let - toPath = builtins.toPath; - getEnv = x: if builtins ? getEnv then builtins.getEnv x else ""; - pathExists = name: - builtins ? pathExists && builtins.pathExists (toPath name); - - configFile = getEnv "NIXPKGS_CONFIG"; - homeDir = getEnv "HOME"; - configFile2 = homeDir + "/.nixpkgs/config.nix"; - - configExpr = - if config_ != null then config_ - else if configFile != "" && pathExists configFile then import (toPath configFile) - else if homeDir != "" && pathExists configFile2 then import (toPath configFile2) - else {}; - - in - # allow both: - # { /* the config */ } and - # { pkgs, ... } : { /* the config */ } - if builtins.isFunction configExpr - then configExpr { inherit pkgs; } - else configExpr; - - # Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc) - - platformAuto = let - platforms = (import ./platforms.nix); - in - if system == "armv6l-linux" then platforms.raspberrypi - else if system == "armv7l-linux" then platforms.armv7l-hf-multiplatform - else if system == "armv5tel-linux" then platforms.sheevaplug - else if system == "mips64el-linux" then platforms.fuloong2f_n32 - else if system == "x86_64-linux" then platforms.pc64 - else if system == "i686-linux" then platforms.pc32 - else platforms.pcBase; - - platform = if platform_ != null then platform_ - else config.platform or platformAuto; - - topLevelArguments = { - inherit system bootStdenv noSysDirs gccWithCC gccWithProfiling config - crossSystem platform lib; - }; - - # Allow packages to be overriden globally via the `packageOverrides' - # configuration option, which must be a function that takes `pkgs' - # as an argument and returns a set of new or overriden packages. - # The `packageOverrides' function is called with the *original* - # (un-overriden) set of packages, allowing packageOverrides - # attributes to refer to the original attributes (e.g. "foo = - # ... pkgs.foo ..."). - pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); - - # stdenvOverrides is used to avoid circular dependencies for building the - # standard build environment. This mechanism use the override mechanism to - # implement some staged compilation of the stdenv. - # - # We don't want stdenv overrides in the case of cross-building, or - # otherwise the basic overrided packages will not be built with the - # crossStdenv adapter. - stdenvOverrides = pkgs: - lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) - (pkgs.stdenv.overrides pkgs); - - # Return the complete set of packages, after applying the overrides - # returned by the `overrider' function (see above). Warning: this - # function is very expensive! - pkgsWithOverrides = overrider: - let - # The un-overriden packages, passed to `overrider'. - pkgs_6 = pkgsFun pkgs; - - pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; - - # The overriden, final packages. - pkgs = pkgs_7 // stdenvOverrides pkgs_6; - in pkgs; - - # The package compositions. Yes, this isn't properly indented. - pkgsFun = pkgs: - let - defaultScope = pkgs // pkgs.xorg; - - # Helper functions that are exported through `pkgs'. - helperFunctions = - stdenvAdapters // - (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); - - stdenvAdapters = - import ../stdenv/adapters.nix pkgs; - - stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; - - self = with pkgs; { +{ # Make some arguments passed to all-packages.nix available inherit system platform; @@ -16443,13 +16316,5 @@ let mg = callPackage ../applications/editors/mg { }; -}; # self = +} - -aliases = import ./aliases.nix self; - -in - helperFunctions // stdenvDefault // self // aliases; - -in - pkgs diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix new file mode 100644 index 000000000000..39626a7485f7 --- /dev/null +++ b/pkgs/top-level/default.nix @@ -0,0 +1,147 @@ +/* This file composes the Nix Packages collection. That is, it + imports the functions that build the various packages, and calls + them with appropriate arguments. The result is a set of all the + packages in the Nix Packages collection for some particular + platform. */ + + +{ # The system (e.g., `i686-linux') for which to build the packages. + system ? builtins.currentSystem + +, # The standard environment to use. Only used for bootstrapping. If + # null, the default standard environment is used. + bootStdenv ? null + +, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc + # outside of the store. Thus, GCC, GFortran, & co. must always look for + # files in standard system directories (/usr/include, etc.) + noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd" + && system != "x86_64-solaris" + && system != "x86_64-kfreebsd-gnu") + + # More flags for the bootstrapping of stdenv. +, gccWithCC ? true +, gccWithProfiling ? true + +, # Allow a configuration attribute set to be passed in as an + # argument. Otherwise, it's read from $NIXPKGS_CONFIG or + # ~/.nixpkgs/config.nix. + config ? null + +, crossSystem ? null +, platform ? null +}: + + +let config_ = config; platform_ = platform; in # rename the function arguments + +let + + lib = import ../../lib; + + # The contents of the configuration file found at $NIXPKGS_CONFIG or + # $HOME/.nixpkgs/config.nix. + # for NIXOS (nixos-rebuild): use nixpkgs.config option + config = + let + toPath = builtins.toPath; + getEnv = x: if builtins ? getEnv then builtins.getEnv x else ""; + pathExists = name: + builtins ? pathExists && builtins.pathExists (toPath name); + + configFile = getEnv "NIXPKGS_CONFIG"; + homeDir = getEnv "HOME"; + configFile2 = homeDir + "/.nixpkgs/config.nix"; + + configExpr = + if config_ != null then config_ + else if configFile != "" && pathExists configFile then import (toPath configFile) + else if homeDir != "" && pathExists configFile2 then import (toPath configFile2) + else {}; + + in + # allow both: + # { /* the config */ } and + # { pkgs, ... } : { /* the config */ } + if builtins.isFunction configExpr + then configExpr { inherit pkgs; } + else configExpr; + + # Allow setting the platform in the config file. Otherwise, let's use a reasonable default (pc) + + platformAuto = let + platforms = (import ./platforms.nix); + in + if system == "armv6l-linux" then platforms.raspberrypi + else if system == "armv7l-linux" then platforms.armv7l-hf-multiplatform + else if system == "armv5tel-linux" then platforms.sheevaplug + else if system == "mips64el-linux" then platforms.fuloong2f_n32 + else if system == "x86_64-linux" then platforms.pc64 + else if system == "i686-linux" then platforms.pc32 + else platforms.pcBase; + + platform = if platform_ != null then platform_ + else config.platform or platformAuto; + + topLevelArguments = { + inherit system bootStdenv noSysDirs gccWithCC gccWithProfiling config + crossSystem platform lib; + }; + + # Allow packages to be overriden globally via the `packageOverrides' + # configuration option, which must be a function that takes `pkgs' + # as an argument and returns a set of new or overriden packages. + # The `packageOverrides' function is called with the *original* + # (un-overriden) set of packages, allowing packageOverrides + # attributes to refer to the original attributes (e.g. "foo = + # ... pkgs.foo ..."). + pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); + + # stdenvOverrides is used to avoid circular dependencies for building the + # standard build environment. This mechanism use the override mechanism to + # implement some staged compilation of the stdenv. + # + # We don't want stdenv overrides in the case of cross-building, or + # otherwise the basic overrided packages will not be built with the + # crossStdenv adapter. + stdenvOverrides = pkgs: + lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) + (pkgs.stdenv.overrides pkgs); + + # Return the complete set of packages, after applying the overrides + # returned by the `overrider' function (see above). Warning: this + # function is very expensive! + pkgsWithOverrides = overrider: + let + # The un-overriden packages, passed to `overrider'. + pkgs_6 = pkgsFun pkgs; + + pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; + + # The overriden, final packages. + pkgs = pkgs_7 // stdenvOverrides pkgs_6; + in pkgs; + + # The package compositions. Yes, this isn't properly indented. + pkgsFun = pkgs: + let + # Helper functions that are exported through `pkgs'. + helperFunctions = + stdenvAdapters // + (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); + + stdenvAdapters = + import ../stdenv/adapters.nix pkgs; + + stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; + + selfArgs = topLevelArguments // { inherit pkgsWithOverrides stdenvAdapters helperFunctions; }; + self = (import ./all-packages.nix selfArgs) self pkgs; + + aliases = import ./aliases.nix self; + + in + helperFunctions // stdenvDefault // self // aliases; + +in + pkgs From 335a969d458e72a4f9049f247ea33dde8cb10630 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 16:33:46 +0000 Subject: [PATCH 29/44] Inline pkgsFun in pkgsWithOverrides. --- pkgs/top-level/default.nix | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 39626a7485f7..135ec2a49d29 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -112,18 +112,6 @@ let # returned by the `overrider' function (see above). Warning: this # function is very expensive! pkgsWithOverrides = overrider: - let - # The un-overriden packages, passed to `overrider'. - pkgs_6 = pkgsFun pkgs; - - pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; - - # The overriden, final packages. - pkgs = pkgs_7 // stdenvOverrides pkgs_6; - in pkgs; - - # The package compositions. Yes, this isn't properly indented. - pkgsFun = pkgs: let # Helper functions that are exported through `pkgs'. helperFunctions = @@ -140,8 +128,13 @@ let aliases = import ./aliases.nix self; - in - helperFunctions // stdenvDefault // self // aliases; + pkgs_6 = helperFunctions // stdenvDefault // self // aliases; + + pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; + + # The overriden, final packages. + pkgs = pkgs_7 // stdenvOverrides pkgs_6; + in pkgs; in pkgs From ae0471b737c28aa046934058fc8b984ecf87ba39 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 16:40:36 +0000 Subject: [PATCH 30/44] Split consecutive merge operators to simplify the identification of extend functions. --- pkgs/top-level/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 135ec2a49d29..acce228ddfff 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -128,7 +128,10 @@ let aliases = import ./aliases.nix self; - pkgs_6 = helperFunctions // stdenvDefault // self // aliases; + pkgs_3 = helperFunctions; + pkgs_4 = pkgs_3 // stdenvDefault; + pkgs_5 = pkgs_4 // self; + pkgs_6 = pkgs_5 // aliases; pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; From 5cdaa7b90766f69e8fee9eb2a2ce1cbb1c22624a Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 16:41:20 +0000 Subject: [PATCH 31/44] Remove all-packages.nix helperFunctions dependency. --- pkgs/build-support/dotnetbuildhelpers/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 6 ++---- pkgs/top-level/default.nix | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/dotnetbuildhelpers/default.nix b/pkgs/build-support/dotnetbuildhelpers/default.nix index ed0d4f790c81..0edfd0b467ab 100644 --- a/pkgs/build-support/dotnetbuildhelpers/default.nix +++ b/pkgs/build-support/dotnetbuildhelpers/default.nix @@ -1,5 +1,5 @@ -{ helperFunctions, mono, pkgconfig }: - helperFunctions.runCommand +{ runCommand, mono, pkgconfig }: + runCommand "dotnetbuildhelpers" { preferLocalBuild = true; } '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 18fc8b958113..e8b659586c21 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1,6 +1,6 @@ { system, bootStdenv, noSysDirs, gccWithCC, gccWithProfiling , config, crossSystem, platform, lib -, pkgsWithOverrides, stdenvAdapters, helperFunctions +, pkgsWithOverrides, stdenvAdapters , ... }: self: pkgs: @@ -151,9 +151,7 @@ in dotnetfx = dotnetfx40; }; - dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers { - inherit helperFunctions; - }; + dotnetbuildhelpers = callPackage ../build-support/dotnetbuildhelpers { }; dispad = callPackage ../tools/X11/dispad { }; diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index acce228ddfff..8b499b96215d 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -123,7 +123,7 @@ let stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; - selfArgs = topLevelArguments // { inherit pkgsWithOverrides stdenvAdapters helperFunctions; }; + selfArgs = topLevelArguments // { inherit pkgsWithOverrides stdenvAdapters; }; self = (import ./all-packages.nix selfArgs) self pkgs; aliases = import ./aliases.nix self; From ff72cf185e0f0b5eaa5691f31574d16563a703d0 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 17:37:40 +0000 Subject: [PATCH 32/44] Split helperFunctions to simplify the identification with the extend function. --- pkgs/top-level/default.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 8b499b96215d..58b2a75f0d25 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -113,14 +113,12 @@ let # function is very expensive! pkgsWithOverrides = overrider: let - # Helper functions that are exported through `pkgs'. - helperFunctions = - stdenvAdapters // - (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); - stdenvAdapters = import ../stdenv/adapters.nix pkgs; + trivialBuilders = + (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); + stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; selfArgs = topLevelArguments // { inherit pkgsWithOverrides stdenvAdapters; }; @@ -128,7 +126,8 @@ let aliases = import ./aliases.nix self; - pkgs_3 = helperFunctions; + pkgs_2 = stdenvAdapters; + pkgs_3 = pkgs_2 // trivialBuilders; pkgs_4 = pkgs_3 // stdenvDefault; pkgs_5 = pkgs_4 // self; pkgs_6 = pkgs_5 // aliases; From 01693ac154138e95324959d260056312021e0dae Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 17:50:06 +0000 Subject: [PATCH 33/44] Move stdenvAdapaters attribute from all-packages.nix into the stdenvAdapters of the top-level. --- pkgs/top-level/all-packages.nix | 4 ++-- pkgs/top-level/default.nix | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e8b659586c21..14e870533879 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1,6 +1,6 @@ { system, bootStdenv, noSysDirs, gccWithCC, gccWithProfiling , config, crossSystem, platform, lib -, pkgsWithOverrides, stdenvAdapters +, pkgsWithOverrides , ... }: self: pkgs: @@ -74,7 +74,7 @@ in ### Helper functions. - inherit lib config stdenvAdapters; + inherit lib config; inherit (lib) lowPrio hiPrio appendToName makeOverridable; inherit (misc) versionedDerivation; diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 58b2a75f0d25..0e9f7ecf056f 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -114,14 +114,16 @@ let pkgsWithOverrides = overrider: let stdenvAdapters = - import ../stdenv/adapters.nix pkgs; + let res = import ../stdenv/adapters.nix pkgs; in res // { + stdenvAdapters = res; + }; trivialBuilders = (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; - selfArgs = topLevelArguments // { inherit pkgsWithOverrides stdenvAdapters; }; + selfArgs = topLevelArguments // { inherit pkgsWithOverrides; }; self = (import ./all-packages.nix selfArgs) self pkgs; aliases = import ./aliases.nix self; From f8dedbb10108898672dce84386b4c9f675c3a82a Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 18:02:28 +0000 Subject: [PATCH 34/44] Build aliases based on the previous set including all-packages, instead of only using all-packages. --- pkgs/top-level/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 0e9f7ecf056f..ae0d38fc7afb 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -126,13 +126,13 @@ let selfArgs = topLevelArguments // { inherit pkgsWithOverrides; }; self = (import ./all-packages.nix selfArgs) self pkgs; - aliases = import ./aliases.nix self; + aliases = super: import ./aliases.nix super; pkgs_2 = stdenvAdapters; pkgs_3 = pkgs_2 // trivialBuilders; pkgs_4 = pkgs_3 // stdenvDefault; pkgs_5 = pkgs_4 // self; - pkgs_6 = pkgs_5 // aliases; + pkgs_6 = pkgs_5 // aliases pkgs_5; pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; From 5783f66bc838317bbd6b78e22eb12bac958c25b1 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 18:17:35 +0000 Subject: [PATCH 35/44] Internalize the recursion over the set of all packages. --- pkgs/top-level/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index ae0d38fc7afb..6370bf57e139 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -124,7 +124,9 @@ let stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; selfArgs = topLevelArguments // { inherit pkgsWithOverrides; }; - self = (import ./all-packages.nix selfArgs) self pkgs; + self = + let res = import ./all-packages.nix selfArgs res pkgs; + in res; aliases = super: import ./aliases.nix super; From a190baa4791d4b29bfe51f2e21894454940d480c Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 18:18:39 +0000 Subject: [PATCH 36/44] In top-level/default.nix, rename self to allPackages. --- pkgs/top-level/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 6370bf57e139..36f0ce0ab3b0 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -123,9 +123,9 @@ let stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; - selfArgs = topLevelArguments // { inherit pkgsWithOverrides; }; - self = - let res = import ./all-packages.nix selfArgs res pkgs; + allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; }; + allPackages = + let res = import ./all-packages.nix allPackagesArgs res pkgs; in res; aliases = super: import ./aliases.nix super; @@ -133,7 +133,7 @@ let pkgs_2 = stdenvAdapters; pkgs_3 = pkgs_2 // trivialBuilders; pkgs_4 = pkgs_3 // stdenvDefault; - pkgs_5 = pkgs_4 // self; + pkgs_5 = pkgs_4 // allPackages; pkgs_6 = pkgs_5 // aliases pkgs_5; pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; From 598ed874df099987545bfb96fe0f8d076321bdea Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 18:23:29 +0000 Subject: [PATCH 37/44] Add extra argument to better identity with the extend function later. --- pkgs/top-level/default.nix | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 36f0ce0ab3b0..f1082226d76c 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -104,7 +104,7 @@ let # We don't want stdenv overrides in the case of cross-building, or # otherwise the basic overrided packages will not be built with the # crossStdenv adapter. - stdenvOverrides = pkgs: + stdenvOverrides = self: pkgs: lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) (pkgs.stdenv.overrides pkgs); @@ -113,33 +113,34 @@ let # function is very expensive! pkgsWithOverrides = overrider: let - stdenvAdapters = + stdenvAdapters = self: super: let res = import ../stdenv/adapters.nix pkgs; in res // { stdenvAdapters = res; }; - trivialBuilders = + trivialBuilders = self: super: (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); - stdenvDefault = (import ./stdenv.nix topLevelArguments) {} pkgs; + stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs; allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; }; - allPackages = + allPackages = self: super: let res = import ./all-packages.nix allPackagesArgs res pkgs; in res; - aliases = super: import ./aliases.nix super; + aliases = self: super: import ./aliases.nix super; - pkgs_2 = stdenvAdapters; - pkgs_3 = pkgs_2 // trivialBuilders; - pkgs_4 = pkgs_3 // stdenvDefault; - pkgs_5 = pkgs_4 // allPackages; - pkgs_6 = pkgs_5 // aliases pkgs_5; + pkgs_1 = {}; + pkgs_2 = pkgs_1 // stdenvAdapters pkgs pkgs_1; + pkgs_3 = pkgs_2 // trivialBuilders pkgs pkgs_2; + pkgs_4 = pkgs_3 // stdenvDefault pkgs pkgs_3; + pkgs_5 = pkgs_4 // allPackages pkgs pkgs_4; + pkgs_6 = pkgs_5 // aliases pkgs pkgs_5; pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; # The overriden, final packages. - pkgs = pkgs_7 // stdenvOverrides pkgs_6; + pkgs = pkgs_7 // stdenvOverrides pkgs pkgs_6; in pkgs; in From 9e8c5208a1370be720ccce8c42e17e0922ba0159 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:00:30 +0000 Subject: [PATCH 38/44] Add bootStdenv condition around the overrider. This condition used to be implicit in the sense that the stdenvOverrides uses pkgs_6, instead of pkgs_7 as its super set, and also that each stage of the compiler is build again the bootstrap packages of the previous stage, thus overriden by the stdenv.override function. --- pkgs/top-level/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index f1082226d76c..b641d54a5ae7 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -130,6 +130,9 @@ let aliases = self: super: import ./aliases.nix super; + customOverrides = self: super: + lib.optionalAttrs (bootStdenv == null) (overrider self super); + pkgs_1 = {}; pkgs_2 = pkgs_1 // stdenvAdapters pkgs pkgs_1; pkgs_3 = pkgs_2 // trivialBuilders pkgs pkgs_2; @@ -137,7 +140,7 @@ let pkgs_5 = pkgs_4 // allPackages pkgs pkgs_4; pkgs_6 = pkgs_5 // aliases pkgs pkgs_5; - pkgs_7 = pkgs_6 // overrider pkgs pkgs_6; + pkgs_7 = pkgs_6 // customOverrides pkgs pkgs_6; # The overriden, final packages. pkgs = pkgs_7 // stdenvOverrides pkgs pkgs_6; From 21b8007bcfb83db36e502efefb541a28a4571fbb Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:04:15 +0000 Subject: [PATCH 39/44] Move the customOverrides after the stdenvOverrides. This change is not backward compatible, in the sense that this allow you to override the packages which used to be overriden by the last stage of stdenv. Note, this does not mean that these packages would be used by stdenv. --- pkgs/top-level/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index b641d54a5ae7..66a99847698a 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -140,10 +140,10 @@ let pkgs_5 = pkgs_4 // allPackages pkgs pkgs_4; pkgs_6 = pkgs_5 // aliases pkgs pkgs_5; - pkgs_7 = pkgs_6 // customOverrides pkgs pkgs_6; + pkgs_7 = pkgs_6 // stdenvOverrides pkgs pkgs_6; # The overriden, final packages. - pkgs = pkgs_7 // stdenvOverrides pkgs pkgs_6; + pkgs = pkgs_7 // customOverrides pkgs pkgs_6; in pkgs; in From 800766fb0b26991a19b63487dceaf369aec92138 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:10:48 +0000 Subject: [PATCH 40/44] Change the customOverrides to use the stdenvOverrides instead of the original package set. --- pkgs/top-level/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 66a99847698a..b1d1282d3d64 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -143,7 +143,7 @@ let pkgs_7 = pkgs_6 // stdenvOverrides pkgs pkgs_6; # The overriden, final packages. - pkgs = pkgs_7 // customOverrides pkgs pkgs_6; + pkgs = pkgs_7 // customOverrides pkgs pkgs_7; in pkgs; in From 1bcefcdf5caf5f238abd9cc74f4d9738ad505f29 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:18:33 +0000 Subject: [PATCH 41/44] Under pkgsWithOverrides, replace the last uses of pkgs by the corresponding argument. --- pkgs/top-level/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index b1d1282d3d64..d335ffb8a377 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -114,18 +114,20 @@ let pkgsWithOverrides = overrider: let stdenvAdapters = self: super: - let res = import ../stdenv/adapters.nix pkgs; in res // { + let res = import ../stdenv/adapters.nix self; in res // { stdenvAdapters = res; }; trivialBuilders = self: super: - (import ../build-support/trivial-builders.nix { inherit lib; inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; }); + (import ../build-support/trivial-builders.nix { + inherit lib; inherit (self) stdenv; inherit (self.xorg) lndir; + }); stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs; allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; }; allPackages = self: super: - let res = import ./all-packages.nix allPackagesArgs res pkgs; + let res = import ./all-packages.nix allPackagesArgs res self; in res; aliases = self: super: import ./aliases.nix super; From 5ae7356d4292ba48ca0e3945a829adda93f64b8b Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:23:08 +0000 Subject: [PATCH 42/44] Replace the merge operators by the fix' and extends functions. --- pkgs/top-level/default.nix | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index d335ffb8a377..2d0915719736 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -134,19 +134,15 @@ let customOverrides = self: super: lib.optionalAttrs (bootStdenv == null) (overrider self super); - - pkgs_1 = {}; - pkgs_2 = pkgs_1 // stdenvAdapters pkgs pkgs_1; - pkgs_3 = pkgs_2 // trivialBuilders pkgs pkgs_2; - pkgs_4 = pkgs_3 // stdenvDefault pkgs pkgs_3; - pkgs_5 = pkgs_4 // allPackages pkgs pkgs_4; - pkgs_6 = pkgs_5 // aliases pkgs pkgs_5; - - pkgs_7 = pkgs_6 // stdenvOverrides pkgs pkgs_6; - - # The overriden, final packages. - pkgs = pkgs_7 // customOverrides pkgs pkgs_7; - in pkgs; - + in + lib.fix' ( + lib.extends customOverrides ( + lib.extends stdenvOverrides ( + lib.extends aliases ( + lib.extends allPackages ( + lib.extends stdenvDefault ( + lib.extends trivialBuilders ( + lib.extends stdenvAdapters ( + self: {})))))))); in pkgs From aa7f0fc21435c253a7fb0c9e3ab1840c2f60c5be Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 19:26:57 +0000 Subject: [PATCH 43/44] Move stdenvOverrides under pkgsWithOverrides. --- pkgs/top-level/default.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 2d0915719736..61fd39f8ca5e 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -97,17 +97,6 @@ let # ... pkgs.foo ..."). pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); - # stdenvOverrides is used to avoid circular dependencies for building the - # standard build environment. This mechanism use the override mechanism to - # implement some staged compilation of the stdenv. - # - # We don't want stdenv overrides in the case of cross-building, or - # otherwise the basic overrided packages will not be built with the - # crossStdenv adapter. - stdenvOverrides = self: pkgs: - lib.optionalAttrs (crossSystem == null && pkgs.stdenv ? overrides) - (pkgs.stdenv.overrides pkgs); - # Return the complete set of packages, after applying the overrides # returned by the `overrider' function (see above). Warning: this # function is very expensive! @@ -132,6 +121,17 @@ let aliases = self: super: import ./aliases.nix super; + # stdenvOverrides is used to avoid circular dependencies for building + # the standard build environment. This mechanism use the override + # mechanism to implement some staged compilation of the stdenv. + # + # We don't want stdenv overrides in the case of cross-building, or + # otherwise the basic overrided packages will not be built with the + # crossStdenv adapter. + stdenvOverrides = self: super: + lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides) + (super.stdenv.overrides super); + customOverrides = self: super: lib.optionalAttrs (bootStdenv == null) (overrider self super); in From 87ad35e336bcaefc0254c01d76c5e2356c315e43 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sun, 20 Mar 2016 20:03:18 +0000 Subject: [PATCH 44/44] Fix comments typos. --- pkgs/top-level/aliases.nix | 2 +- pkgs/top-level/default.nix | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index c0b93335c80d..b9f072e6ca6b 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -3,7 +3,7 @@ self: with self; let - # Removind recurseForDerivation prevents derivations of aliased attribute + # Removing recurseForDerivation prevents derivations of aliased attribute # set to appear while listing all the packages available. removeRecurseForDerivations = _n: alias: with lib; if alias.recurseForDerivations or false then diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 61fd39f8ca5e..4de75c2ed57e 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -88,11 +88,11 @@ let crossSystem platform lib; }; - # Allow packages to be overriden globally via the `packageOverrides' + # Allow packages to be overridden globally via the `packageOverrides' # configuration option, which must be a function that takes `pkgs' - # as an argument and returns a set of new or overriden packages. + # as an argument and returns a set of new or overridden packages. # The `packageOverrides' function is called with the *original* - # (un-overriden) set of packages, allowing packageOverrides + # (un-overridden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); @@ -122,11 +122,11 @@ let aliases = self: super: import ./aliases.nix super; # stdenvOverrides is used to avoid circular dependencies for building - # the standard build environment. This mechanism use the override + # the standard build environment. This mechanism uses the override # mechanism to implement some staged compilation of the stdenv. # # We don't want stdenv overrides in the case of cross-building, or - # otherwise the basic overrided packages will not be built with the + # otherwise the basic overridden packages will not be built with the # crossStdenv adapter. stdenvOverrides = self: super: lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides)