From 05977b236b2a925983224c24d6e14aed796e7a14 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 27 Oct 2016 21:01:50 -0700 Subject: [PATCH 1/6] top-level: Remove redundant parentheses --- 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 7d370bec6b5d..012db1e393b4 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -77,9 +77,9 @@ let }; trivialBuilders = self: super: - (import ../build-support/trivial-builders.nix { + import ../build-support/trivial-builders.nix { inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; - }); + }; stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) pkgs; From 68a04c1195ba8087f0f57c5b9017b38a02a8c6c1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 2 Nov 2016 18:35:03 -0400 Subject: [PATCH 2/6] top-level: Inline topLevelArugments, and make pkg named arg for stdenv [Trying my best to indent properly while avoiding excessive drift] --- pkgs/top-level/default.nix | 13 +++++++------ pkgs/top-level/stdenv.nix | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 012db1e393b4..67577aabaa4d 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -56,10 +56,6 @@ let platform = if platform_ != null then platform_ else config.platform or platformAuto; - topLevelArguments = { - inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun; - }; - # A few packages make a new package set to draw their dependencies from. # (Currently to get a cross tool chain, or forced-i686 package.) Rather than # give `all-packages.nix` all the arguments to this function, even ones that @@ -81,10 +77,15 @@ let inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; }; - stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) pkgs; + stdenvDefault = self: super: + import ./stdenv.nix { + inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun pkgs; + }; allPackages = self: super: - let res = import ./all-packages.nix topLevelArguments res self; + let res = import ./all-packages.nix + { inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun; } + res self; in res; aliases = self: super: import ./aliases.nix super; diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix index c36b0fed091a..7efbfc36b1fd 100644 --- a/pkgs/top-level/stdenv.nix +++ b/pkgs/top-level/stdenv.nix @@ -1,5 +1,4 @@ -{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, ... }: -pkgs: +{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, pkgs, ... }: rec { allStdenvs = import ../stdenv { From eed34bd214d6f513a859f3cfc52b266a9d19898b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 2 Nov 2016 17:08:39 -0400 Subject: [PATCH 3/6] top-level: Remove redundant arguments from top-level/{all-package,stdenv}.nix --- pkgs/top-level/all-packages.nix | 4 ++-- pkgs/top-level/default.nix | 4 ++-- pkgs/top-level/stdenv.nix | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fc4660108d00..8d7a5d204ed7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5,9 +5,9 @@ * to merges. Please use the full-text search of your editor. ;) * Hint: ### starts category names. */ -{ system, bootStdenv, noSysDirs, config, crossSystem, platform, lib +{ system, noSysDirs, config, crossSystem, platform, lib , nixpkgsFun -, ... }: +}: self: pkgs: with pkgs; diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 67577aabaa4d..baf314edece7 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -79,12 +79,12 @@ let stdenvDefault = self: super: import ./stdenv.nix { - inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun pkgs; + inherit system bootStdenv crossSystem config platform lib nixpkgsFun pkgs; }; allPackages = self: super: let res = import ./all-packages.nix - { inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun; } + { inherit system noSysDirs config crossSystem platform lib nixpkgsFun; } res self; in res; diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix index 7efbfc36b1fd..f9ba5e7516ef 100644 --- a/pkgs/top-level/stdenv.nix +++ b/pkgs/top-level/stdenv.nix @@ -1,4 +1,4 @@ -{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, pkgs, ... }: +{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, pkgs }: rec { allStdenvs = import ../stdenv { From e22346c35ee8cb872d0587320083ba44230bd44b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 6 Nov 2016 21:27:38 -0800 Subject: [PATCH 4/6] top-level: Make stdenvCross which appears at first glance normal... ...but actually is weird just like the original --- pkgs/stdenv/cross/default.nix | 27 +++++++++++++++++++++++++++ pkgs/stdenv/default.nix | 7 +++++-- pkgs/top-level/default.nix | 7 ++++++- pkgs/top-level/stdenv.nix | 33 ++++++++++++++------------------- 4 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 pkgs/stdenv/cross/default.nix diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix new file mode 100644 index 000000000000..d78061db712e --- /dev/null +++ b/pkgs/stdenv/cross/default.nix @@ -0,0 +1,27 @@ +{ system, allPackages, platform, crossSystem, config, ... } @ args: + +rec { + vanillaStdenv = (import ../. (args // { + crossSystem = null; + allPackages = args: allPackages ({ crossSystem = null; } // args); + })).stdenv; + + # Yeah this isn't so cleanly just build-time packages yet. Notice the + # buildPackages <-> stdenvCross cycle. Yup, it's very weird. + # + # This works because the derivation used to build `stdenvCross` are in + # fact using `forceNativeDrv` to use the `nativeDrv` attribute of the resulting + # derivation built with `vanillaStdenv` (second argument of `makeStdenvCross`). + # + # Eventually, `forceNativeDrv` should be removed and the cycle broken. + buildPackages = allPackages { + # It's OK to change the built-time dependencies + allowCustomOverrides = true; + bootStdenv = stdenvCross; + inherit system platform crossSystem config; + }; + + stdenvCross = buildPackages.makeStdenvCross + vanillaStdenv crossSystem + buildPackages.binutilsCross buildPackages.gccCrossStageFinal; +} diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 3035d87e1fc5..59088bfdf3bf 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -5,7 +5,7 @@ # Posix utilities, the GNU C compiler, and so on. On other systems, # we use the native C library. -{ system, allPackages ? import ../.., platform, config, lib }: +{ system, allPackages ? import ../.., platform, config, crossSystem, lib }: rec { @@ -36,10 +36,13 @@ rec { # Linux standard environment. inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux; - inherit (import ./darwin { inherit system allPackages platform config;}) stdenvDarwin; + inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin; + + inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross; # Select the appropriate stdenv for the platform `system'. stdenv = + if crossSystem != null then stdenvCross else if system == "i686-linux" then stdenvLinux else if system == "x86_64-linux" then stdenvLinux else if system == "armv5tel-linux" then stdenvLinux else diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index baf314edece7..73fe58ca7f34 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -12,6 +12,11 @@ # null, the default standard environment is used. bootStdenv ? null +, # This is used because stdenv replacement and the stdenvCross do benefit from + # the overridden configuration provided by the user, as opposed to the normal + # bootstrapping stdenvs. + allowCustomOverrides ? (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.) @@ -109,7 +114,7 @@ let # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). configOverrides = self: super: - lib.optionalAttrs (bootStdenv == null) + lib.optionalAttrs allowCustomOverrides ((config.packageOverrides or (super: {})) super); # The complete chain of package set builders, applied from top to bottom diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix index f9ba5e7516ef..20f201869594 100644 --- a/pkgs/top-level/stdenv.nix +++ b/pkgs/top-level/stdenv.nix @@ -2,28 +2,23 @@ rec { allStdenvs = import ../stdenv { - inherit system platform config lib; - # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR - allPackages = args: nixpkgsFun (args // { crossSystem = null; }); + inherit system platform config crossSystem lib; + allPackages = nixpkgsFun; }; defaultStdenv = allStdenvs.stdenv // { inherit platform; }; stdenv = - if bootStdenv != null then (bootStdenv // {inherit platform;}) else - if crossSystem != null then - pkgs.stdenvCross - else - let - changer = config.replaceStdenv or null; - in if changer != null then - changer { - # We import again all-packages to avoid recursivities. - pkgs = nixpkgsFun { - # We remove packageOverrides to avoid recursivities - config = removeAttrs config [ "replaceStdenv" ]; - }; - } - else - defaultStdenv; + if bootStdenv != null then + (bootStdenv // { inherit platform; }) + else if crossSystem == null && config ? replaceStdenv then + config.replaceStdenv { + # We import again all-packages to avoid recursivities. + pkgs = nixpkgsFun { + # We remove packageOverrides to avoid recursivities + config = removeAttrs config [ "replaceStdenv" ]; + }; + } + else + defaultStdenv; } From ea7bf0226825e21555eda1fd57d93762b376188d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 27 Apr 2016 08:09:12 -0700 Subject: [PATCH 5/6] top-level: `top-level/stdenv.nix` no longer needs `pkg` argument --- pkgs/top-level/default.nix | 2 +- pkgs/top-level/stdenv.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 73fe58ca7f34..831b1db0cea3 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -84,7 +84,7 @@ let stdenvDefault = self: super: import ./stdenv.nix { - inherit system bootStdenv crossSystem config platform lib nixpkgsFun pkgs; + inherit system bootStdenv crossSystem config platform lib nixpkgsFun; }; allPackages = self: super: diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix index 20f201869594..d5d9288907f7 100644 --- a/pkgs/top-level/stdenv.nix +++ b/pkgs/top-level/stdenv.nix @@ -1,4 +1,4 @@ -{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, pkgs }: +{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun }: rec { allStdenvs = import ../stdenv { From 6bfe04277f40a0da27fa6373edfb24a6b139548b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 27 Apr 2016 09:09:27 -0700 Subject: [PATCH 6/6] top-level: Make config-overriden stdenv bootstrap more normally --- pkgs/stdenv/cross/default.nix | 8 ++++++-- pkgs/stdenv/custom/default.nix | 17 +++++++++++++++++ pkgs/stdenv/default.nix | 3 +++ pkgs/top-level/stdenv.nix | 15 +++------------ 4 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 pkgs/stdenv/custom/default.nix diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index d78061db712e..93c5a21d9d5a 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -1,9 +1,13 @@ { system, allPackages, platform, crossSystem, config, ... } @ args: rec { - vanillaStdenv = (import ../. (args // { + argClobber = { crossSystem = null; - allPackages = args: allPackages ({ crossSystem = null; } // args); + # Ignore custom stdenvs when cross compiling for compatability + config = builtins.removeAttrs config [ "replaceStdenv" ]; + }; + vanillaStdenv = (import ../. (args // argClobber // { + allPackages = args: allPackages (argClobber // args); })).stdenv; # Yeah this isn't so cleanly just build-time packages yet. Notice the diff --git a/pkgs/stdenv/custom/default.nix b/pkgs/stdenv/custom/default.nix new file mode 100644 index 000000000000..2f2f495b388b --- /dev/null +++ b/pkgs/stdenv/custom/default.nix @@ -0,0 +1,17 @@ +{ system, allPackages, platform, crossSystem, config, ... } @ args: + +rec { + vanillaStdenv = (import ../. (args // { + # Remove config.replaceStdenv to ensure termination. + config = builtins.removeAttrs config [ "replaceStdenv" ]; + })).stdenv; + + buildPackages = allPackages { + # It's OK to change the built-time dependencies + allowCustomOverrides = true; + bootStdenv = vanillaStdenv; + inherit system platform crossSystem config; + }; + + stdenvCustom = config.replaceStdenv { pkgs = buildPackages; }; +} diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 59088bfdf3bf..10086ee6a853 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -40,9 +40,12 @@ rec { inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross; + inherit (import ./custom { inherit system allPackages platform crossSystem config lib; }) stdenvCustom; + # Select the appropriate stdenv for the platform `system'. stdenv = if crossSystem != null then stdenvCross else + if config ? replaceStdenv then stdenvCustom else if system == "i686-linux" then stdenvLinux else if system == "x86_64-linux" then stdenvLinux else if system == "armv5tel-linux" then stdenvLinux else diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix index d5d9288907f7..9f485b8c90ef 100644 --- a/pkgs/top-level/stdenv.nix +++ b/pkgs/top-level/stdenv.nix @@ -9,16 +9,7 @@ rec { defaultStdenv = allStdenvs.stdenv // { inherit platform; }; stdenv = - if bootStdenv != null then - (bootStdenv // { inherit platform; }) - else if crossSystem == null && config ? replaceStdenv then - config.replaceStdenv { - # We import again all-packages to avoid recursivities. - pkgs = nixpkgsFun { - # We remove packageOverrides to avoid recursivities - config = removeAttrs config [ "replaceStdenv" ]; - }; - } - else - defaultStdenv; + if bootStdenv != null + then (bootStdenv // { inherit platform; }) + else defaultStdenv; }