From 4751d9e5ad124284dbd719d3a58f42d56f1b9514 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 30 Nov 2016 18:51:13 -0500 Subject: [PATCH] top-level: turn the screw - Non-cross stdenvs are honest and assert that `crossSystem` is null - `crossSystem` is a mandatory argument to top-level/stage.nix, just like `system` and `platform` - Broken default arguments on stdenvs for testing are gone. - All stdenvs (but little-used stdenvNix) take the same arguments for easy testing. --- pkgs/stdenv/custom/default.nix | 2 ++ pkgs/stdenv/darwin/default.nix | 10 +++++----- pkgs/stdenv/default.nix | 16 ++++++++-------- pkgs/stdenv/freebsd/default.nix | 8 ++++---- pkgs/stdenv/linux/default.nix | 10 +++++----- pkgs/stdenv/native/default.nix | 8 ++++++-- pkgs/top-level/stage.nix | 2 +- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/pkgs/stdenv/custom/default.nix b/pkgs/stdenv/custom/default.nix index 174b8593c0aa..188d00277731 100644 --- a/pkgs/stdenv/custom/default.nix +++ b/pkgs/stdenv/custom/default.nix @@ -2,6 +2,8 @@ , system, platform, crossSystem, config }: +assert crossSystem == null; + rec { vanillaStdenv = import ../. { inherit lib allPackages system platform crossSystem; diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 6182c8cc0c74..b9044f25cd7a 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -1,7 +1,5 @@ -{ system ? builtins.currentSystem -, allPackages ? import ../../.. -, platform ? null -, config ? {} +{ lib, allPackages +, system, platform, crossSystem, config # Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools , bootstrapFiles ? let @@ -17,6 +15,8 @@ } }: +assert crossSystem == null; + let libSystemProfile = '' (import "${./standard-sandbox.sb}") @@ -100,7 +100,7 @@ in rec { }; thisPkgs = allPackages { - inherit system platform config; + inherit system platform crossSystem config; allowCustomOverrides = false; stdenv = thisStdenv; }; diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 246e656f33bf..3b49d0de8306 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -9,7 +9,7 @@ lib, allPackages # Args to pass on to `allPacakges` too , system, platform, crossSystem, config -}: +} @ args: let # The native (i.e., impure) build environment. This one uses the @@ -17,7 +17,7 @@ let # i.e., the stuff in /bin, /usr/bin, etc. This environment should # be used with care, since many Nix packages will not build properly # with it (e.g., because they require GNU Make). - inherit (import ./native { inherit system allPackages config; }) stdenvNative; + inherit (import ./native args) stdenvNative; stdenvNativePkgs = allPackages { inherit system platform crossSystem config; @@ -28,22 +28,22 @@ let # The Nix build environment. - stdenvNix = import ./nix { + stdenvNix = assert crossSystem == null; import ./nix { inherit config lib; stdenv = stdenvNative; pkgs = stdenvNativePkgs; }; - inherit (import ./freebsd { inherit system allPackages platform config; }) stdenvFreeBSD; + inherit (import ./freebsd args) stdenvFreeBSD; # Linux standard environment. - inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux; + inherit (import ./linux args) stdenvLinux; - inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin; + inherit (import ./darwin args) stdenvDarwin; - inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross stdenvCrossiOS; + inherit (import ./cross args) stdenvCross stdenvCrossiOS; - inherit (import ./custom { inherit system allPackages platform crossSystem config lib; }) stdenvCustom; + inherit (import ./custom args) stdenvCustom; # Select the appropriate stdenv for the platform `system'. in diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix index 13cb21fe1d88..ea2ebcc7917a 100644 --- a/pkgs/stdenv/freebsd/default.nix +++ b/pkgs/stdenv/freebsd/default.nix @@ -1,9 +1,9 @@ -{ system ? builtins.currentSystem -, allPackages ? import ../../.. -, platform ? null -, config ? {} +{ lib, allPackages +, system, platform, crossSystem, config }: +assert crossSystem == null; + rec { inherit allPackages; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index e4bf87c52024..34196359f525 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -3,11 +3,9 @@ # external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C # compiler and linker that do not search in default locations, # ensuring purity of components produced by it. +{ lib, allPackages +, system, platform, crossSystem, config -# The function defaults are for easy testing. -{ system ? builtins.currentSystem -, allPackages ? import ../../.. -, platform ? null, config ? {}, lib ? (import ../../../lib) , bootstrapFiles ? if system == "i686-linux" then import ./bootstrap/i686.nix else if system == "x86_64-linux" then import ./bootstrap/x86_64.nix @@ -18,6 +16,8 @@ else abort "unsupported platform for the pure Linux stdenv" }: +assert crossSystem == null; + rec { commonPreHook = @@ -106,7 +106,7 @@ rec { }; thisPkgs = allPackages { - inherit system platform config; + inherit system platform crossSystem config; allowCustomOverrides = false; stdenv = thisStdenv; }; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 0f9aee214b30..8396bd0cb017 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -1,4 +1,8 @@ -{ system, allPackages ? import ../../.., config }: +{ lib, allPackages +, system, platform, crossSystem, config +}: + +assert crossSystem == null; rec { @@ -126,7 +130,7 @@ rec { } // {inherit fetchurl;}; stdenvBoot1Pkgs = allPackages { - inherit system platform config; + inherit system platform crossSystem config; allowCustomOverrides = false; stdenv = stdenvBoot1; }; diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 0c621b81c7ed..1d6305151ca6 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -30,7 +30,7 @@ , # The configuration attribute set config -, crossSystem ? null +, crossSystem , platform , lib , nixpkgsFun