Merge pull request #21415 from Ericson2314/normalize-boot

Normalize bootstrapping

authored by John Ericson and committed by GitHub 0b8e3898 a652099c

+489 -364
+8
nixos/doc/manual/release-notes/rl-1703.xml
··· 30 30 <itemizedlist> 31 31 <listitem> 32 32 <para> 33 + <literal>stdenv.overrides</literal> is now expected to take <literal>self</literal> 34 + and <literal>super</literal> arguments. See <literal>lib.trivial.extends</literal> 35 + for what those parameters represent. 36 + </para> 37 + </listitem> 38 + 39 + <listitem> 40 + <para> 33 41 <literal>gnome</literal> alias has been removed along with 34 42 <literal>gtk</literal>, <literal>gtkmm</literal> and several others. 35 43 Now you need to use versioned attributes, like <literal>gnome3</literal>.
+68
pkgs/stdenv/booter.nix
··· 1 + # This file defines a single function for booting a package set from a list of 2 + # stages. The exact mechanics of that function are defined below; here I 3 + # (@Ericson2314) wish to describe the purpose of the abstraction. 4 + # 5 + # The first goal is consistency across stdenvs. Regardless of what this function 6 + # does, by making every stdenv use it for bootstrapping we ensure that they all 7 + # work in a similar way. [Before this abstraction, each stdenv was its own 8 + # special snowflake due to different authors writing in different times.] 9 + # 10 + # The second goal is consistency across each stdenv's stage functions. By 11 + # writing each stage it terms of the previous stage, commonalities between them 12 + # are more easily observable. [Before, there usually was a big attribute set 13 + # with each stage, and stages would access the previous stage by name.] 14 + # 15 + # The third goal is composition. Because each stage is written in terms of the 16 + # previous, the list can be reordered or, more practically, extended with new 17 + # stages. The latter is used for cross compiling and custom 18 + # stdenvs. Additionally, certain options should by default apply only to the 19 + # last stage, whatever it may be. By delaying the creation of stage package sets 20 + # until the final fold, we prevent these options from inhibiting composition. 21 + # 22 + # The fourth and final goal is debugging. Normal packages should only source 23 + # their dependencies from the current stage. But for the sake of debugging, it 24 + # is nice that all packages still remain accessible. We make sure previous 25 + # stages are kept around with a `stdenv.__bootPackges` attribute referring the 26 + # previous stage. It is idiomatic that attributes prefixed with `__` come with 27 + # special restrictions and should not be used under normal circumstances. 28 + { lib, allPackages }: 29 + 30 + # Type: 31 + # [ pkgset -> (args to stage/default.nix) or ({ __raw = true; } // pkgs) ] 32 + # -> pkgset 33 + # 34 + # In english: This takes a list of function from the previous stage pkgset and 35 + # returns the final pkgset. Each of those functions returns, if `__raw` is 36 + # undefined or false, args for this stage's pkgset (the most complex and 37 + # important arg is the stdenv), or, if `__raw = true`, simply this stage's 38 + # pkgset itself. 39 + # 40 + # The list takes stages in order, so the final stage is last in the list. In 41 + # other words, this does a foldr not foldl. 42 + stageFuns: let 43 + 44 + # Take the list and disallow custom overrides in all but the final stage, 45 + # and allow it in the final flag. Only defaults this boolean field if it 46 + # isn't already set. 47 + withAllowCustomOverrides = lib.lists.imap 48 + (index: stageFun: prevStage: 49 + # So true by default for only the first element because one 50 + # 1-indexing. Since we reverse the list, this means this is true 51 + # for the final stage. 52 + { allowCustomOverrides = index == 1; } 53 + // (stageFun prevStage)) 54 + (lib.lists.reverseList stageFuns); 55 + 56 + # Adds the stdenv to the arguments, and sticks in it the previous stage for 57 + # debugging purposes. 58 + folder = stageFun: finalSoFar: let 59 + args = stageFun finalSoFar; 60 + stdenv = args.stdenv // { 61 + # For debugging 62 + __bootPackages = finalSoFar; 63 + }; 64 + args' = args // { inherit stdenv; }; 65 + in 66 + (if args.__raw or false then lib.id else allPackages) args'; 67 + 68 + in lib.lists.fold folder {} withAllowCustomOverrides
+35 -21
pkgs/stdenv/cross/default.nix
··· 1 - { lib, allPackages 1 + { lib 2 2 , system, platform, crossSystem, config 3 3 }: 4 4 5 - rec { 6 - vanillaStdenv = (import ../. { 7 - inherit lib allPackages system platform; 5 + let 6 + bootStages = import ../. { 7 + inherit lib system platform; 8 8 crossSystem = null; 9 9 # Ignore custom stdenvs when cross compiling for compatability 10 10 config = builtins.removeAttrs config [ "replaceStdenv" ]; 11 - }) // { 12 - # Needed elsewhere as a hacky way to pass the target 13 - cross = crossSystem; 14 11 }; 15 12 16 - # For now, this is just used to build the native stdenv. Eventually, it should 17 - # be used to build compilers and other such tools targeting the cross 13 + in bootStages ++ [ 14 + 15 + # Build Packages. 16 + # 17 + # For now, this is just used to build the native stdenv. Eventually, it 18 + # should be used to build compilers and other such tools targeting the cross 18 19 # platform. Then, `forceNativeDrv` can be removed. 19 - buildPackages = allPackages { 20 + (vanillaPackages: { 20 21 inherit system platform crossSystem config; 21 22 # It's OK to change the built-time dependencies 22 23 allowCustomOverrides = true; 23 - stdenv = vanillaStdenv; 24 - }; 24 + stdenv = vanillaPackages.stdenv // { 25 + # Needed elsewhere as a hacky way to pass the target 26 + cross = crossSystem; 27 + overrides = _: _: {}; 28 + }; 29 + }) 25 30 26 - stdenvCross = buildPackages.makeStdenvCross 27 - buildPackages.stdenv crossSystem 28 - buildPackages.binutilsCross buildPackages.gccCrossStageFinal; 31 + # Run packages 32 + (buildPackages: { 33 + inherit system platform crossSystem config; 34 + stdenv = if crossSystem.useiOSCross or false 35 + then let 36 + inherit (buildPackages.darwin.ios-cross { 37 + prefix = crossSystem.config; 38 + inherit (crossSystem) arch; 39 + simulator = crossSystem.isiPhoneSimulator or false; }) 40 + cc binutils; 41 + in buildPackages.makeStdenvCross 42 + buildPackages.stdenv crossSystem 43 + binutils cc 44 + else buildPackages.makeStdenvCross 45 + buildPackages.stdenv crossSystem 46 + buildPackages.binutilsCross buildPackages.gccCrossStageFinal; 47 + }) 29 48 30 - stdenvCrossiOS = let 31 - inherit (buildPackages.darwin.ios-cross { prefix = crossSystem.config; inherit (crossSystem) arch; simulator = crossSystem.isiPhoneSimulator or false; }) cc binutils; 32 - in buildPackages.makeStdenvCross 33 - buildPackages.stdenv crossSystem 34 - binutils cc; 35 - } 49 + ]
+11 -11
pkgs/stdenv/custom/default.nix
··· 1 - { lib, allPackages 1 + { lib 2 2 , system, platform, crossSystem, config 3 3 }: 4 4 5 5 assert crossSystem == null; 6 6 7 - rec { 8 - vanillaStdenv = import ../. { 9 - inherit lib allPackages system platform crossSystem; 7 + let 8 + bootStages = import ../. { 9 + inherit lib system platform crossSystem; 10 10 # Remove config.replaceStdenv to ensure termination. 11 11 config = builtins.removeAttrs config [ "replaceStdenv" ]; 12 12 }; 13 13 14 - buildPackages = allPackages { 14 + in bootStages ++ [ 15 + 16 + # Additional stage, built using custom stdenv 17 + (vanillaPackages: { 15 18 inherit system platform crossSystem config; 16 - # It's OK to change the built-time dependencies 17 - allowCustomOverrides = true; 18 - stdenv = vanillaStdenv; 19 - }; 19 + stdenv = config.replaceStdenv { pkgs = vanillaPackages; }; 20 + }) 20 21 21 - stdenvCustom = config.replaceStdenv { pkgs = buildPackages; }; 22 - } 22 + ]
+44 -38
pkgs/stdenv/darwin/default.nix
··· 1 - { lib, allPackages 1 + { lib 2 2 , system, platform, crossSystem, config 3 3 4 4 # Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools ··· 22 22 (import "${./standard-sandbox.sb}") 23 23 ''; 24 24 in rec { 25 - inherit allPackages; 26 - 27 25 commonPreHook = '' 28 26 export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}" 29 27 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" ··· 54 52 }; 55 53 56 54 stageFun = step: last: {shell ? "${bootstrapTools}/bin/sh", 57 - overrides ? (pkgs: {}), 55 + overrides ? (self: super: {}), 58 56 extraPreHook ? "", 59 57 extraBuildInputs, 60 58 allowedRequisites ? null}: ··· 96 94 extraSandboxProfile = binShClosure + libSystemProfile; 97 95 98 96 extraAttrs = { inherit platform; parent = last; }; 99 - overrides = pkgs: (overrides pkgs) // { fetchurl = thisStdenv.fetchurlBoot; }; 97 + overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; 100 98 }; 101 99 102 - thisPkgs = allPackages { 103 - inherit system platform crossSystem config; 104 - allowCustomOverrides = false; 105 - stdenv = thisStdenv; 106 - }; 107 - in { stdenv = thisStdenv; pkgs = thisPkgs; }; 100 + in { 101 + inherit system platform crossSystem config; 102 + stdenv = thisStdenv; 103 + }; 108 104 109 105 stage0 = stageFun 0 null { 110 - overrides = orig: with stage0; rec { 111 - darwin = orig.darwin // { 106 + overrides = self: super: with stage0; rec { 107 + darwin = super.darwin // { 112 108 Libsystem = stdenv.mkDerivation { 113 109 name = "bootstrap-Libsystem"; 114 110 buildCommand = '' ··· 145 141 extraBuildInputs = []; 146 142 }; 147 143 148 - persistent0 = _: {}; 144 + persistent0 = _: _: _: {}; 149 145 150 - stage1 = with stage0; stageFun 1 stage0 { 146 + stage1 = prevStage: with prevStage; stageFun 1 prevStage { 151 147 extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\""; 152 148 extraBuildInputs = [ pkgs.libcxx ]; 153 149 154 150 allowedRequisites = 155 151 [ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ]; 156 152 157 - overrides = persistent0; 153 + overrides = persistent0 prevStage; 158 154 }; 159 155 160 - persistent1 = orig: with stage1.pkgs; { 156 + persistent1 = prevStage: self: super: with prevStage; { 161 157 inherit 162 158 zlib patchutils m4 scons flex perl bison unifdef unzip openssl icu python 163 159 libxml2 gettext sharutils gmp libarchive ncurses pkg-config libedit groff 164 160 openssh sqlite sed serf openldap db cyrus-sasl expat apr-util subversion xz 165 161 findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils; 166 162 167 - darwin = orig.darwin // { 163 + darwin = super.darwin // { 168 164 inherit (darwin) 169 165 dyld Libsystem xnu configd libdispatch libclosure launchd; 170 166 }; 171 167 }; 172 168 173 - stage2 = with stage1; stageFun 2 stage1 { 169 + stage2 = prevStage: with prevStage; stageFun 2 prevStage { 174 170 extraPreHook = '' 175 171 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 176 172 ''; ··· 182 178 (with pkgs; [ xz.bin xz.out libcxx libcxxabi icu.out ]) ++ 183 179 (with pkgs.darwin; [ dyld Libsystem CF locale ]); 184 180 185 - overrides = persistent1; 181 + overrides = persistent1 prevStage; 186 182 }; 187 183 188 - persistent2 = orig: with stage2.pkgs; { 184 + persistent2 = prevStage: self: super: with prevStage; { 189 185 inherit 190 186 patchutils m4 scons flex perl bison unifdef unzip openssl python 191 187 gettext sharutils libarchive pkg-config groff bash subversion ··· 193 189 findfreetype libssh curl cmake autoconf automake libtool cpio 194 190 libcxx libcxxabi; 195 191 196 - darwin = orig.darwin // { 192 + darwin = super.darwin // { 197 193 inherit (darwin) 198 194 dyld Libsystem xnu configd libdispatch libclosure launchd libiconv locale; 199 195 }; 200 196 }; 201 197 202 - stage3 = with stage2; stageFun 3 stage2 { 198 + stage3 = prevStage: with prevStage; stageFun 3 prevStage { 203 199 shell = "${pkgs.bash}/bin/bash"; 204 200 205 201 # We have a valid shell here (this one has no bootstrap-tools runtime deps) so stageFun ··· 218 214 (with pkgs; [ xz.bin xz.out icu.out bash libcxx libcxxabi ]) ++ 219 215 (with pkgs.darwin; [ dyld Libsystem locale ]); 220 216 221 - overrides = persistent2; 217 + overrides = persistent2 prevStage; 222 218 }; 223 219 224 - persistent3 = orig: with stage3.pkgs; { 220 + persistent3 = prevStage: self: super: with prevStage; { 225 221 inherit 226 222 gnumake gzip gnused bzip2 gawk ed xz patch bash 227 223 libcxxabi libcxx ncurses libffi zlib gmp pcre gnugrep 228 224 coreutils findutils diffutils patchutils; 229 225 230 226 llvmPackages = let llvmOverride = llvmPackages.llvm.override { inherit libcxxabi; }; 231 - in orig.llvmPackages // { 227 + in super.llvmPackages // { 232 228 llvm = llvmOverride; 233 229 clang-unwrapped = llvmPackages.clang-unwrapped.override { llvm = llvmOverride; }; 234 230 }; 235 231 236 - darwin = orig.darwin // { 232 + darwin = super.darwin // { 237 233 inherit (darwin) dyld Libsystem libiconv locale; 238 234 }; 239 235 }; 240 236 241 - stage4 = with stage3; stageFun 4 stage3 { 237 + stage4 = prevStage: with prevStage; stageFun 4 prevStage { 242 238 shell = "${pkgs.bash}/bin/bash"; 243 239 extraBuildInputs = with pkgs; [ xz darwin.CF libcxx pkgs.bash ]; 244 240 extraPreHook = '' 245 241 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 246 242 ''; 247 - overrides = persistent3; 243 + overrides = persistent3 prevStage; 248 244 }; 249 245 250 - persistent4 = orig: with stage4.pkgs; { 246 + persistent4 = prevStage: self: super: with prevStage; { 251 247 inherit 252 248 gnumake gzip gnused bzip2 gawk ed xz patch bash 253 249 libcxxabi libcxx ncurses libffi zlib icu llvm gmp pcre gnugrep 254 250 coreutils findutils diffutils patchutils binutils binutils-raw; 255 251 256 - llvmPackages = orig.llvmPackages // { 252 + llvmPackages = super.llvmPackages // { 257 253 inherit (llvmPackages) llvm clang-unwrapped; 258 254 }; 259 255 260 - darwin = orig.darwin // { 256 + darwin = super.darwin // { 261 257 inherit (darwin) dyld Libsystem cctools libiconv; 262 258 }; 263 259 }; 264 260 265 - stage5 = with stage4; import ../generic rec { 261 + stdenvDarwin = prevStage: let pkgs = prevStage; in import ../generic rec { 266 262 inherit system config; 267 - inherit (stdenv) fetchurlBoot; 263 + inherit (pkgs.stdenv) fetchurlBoot; 268 264 269 265 name = "stdenv-darwin"; 270 266 ··· 279 275 shell = "${pkgs.bash}/bin/bash"; 280 276 281 277 cc = import ../../build-support/cc-wrapper { 282 - inherit stdenv shell; 278 + inherit (pkgs) stdenv; 279 + inherit shell; 283 280 nativeTools = false; 284 281 nativeLibc = false; 285 282 inherit (pkgs) coreutils binutils gnugrep; ··· 294 291 inherit platform bootstrapTools; 295 292 libc = pkgs.darwin.Libsystem; 296 293 shellPackage = pkgs.bash; 297 - parent = stage4; 298 294 }; 299 295 300 296 allowedRequisites = (with pkgs; [ ··· 307 303 dyld Libsystem CF cctools libiconv locale 308 304 ]); 309 305 310 - overrides = orig: persistent4 orig // { 306 + overrides = self: super: persistent4 prevStage self super // { 311 307 clang = cc; 312 308 inherit cc; 313 309 }; 314 310 }; 315 311 316 - stdenvDarwin = stage5; 312 + stagesDarwin = [ 313 + ({}: stage0) 314 + stage1 315 + stage2 316 + stage3 317 + stage4 318 + (prevStage: { 319 + inherit system crossSystem platform config; 320 + stdenv = stdenvDarwin prevStage; 321 + }) 322 + ]; 317 323 }
+2 -2
pkgs/stdenv/darwin/make-bootstrap-tools.nix
··· 334 334 # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it 335 335 test-pkgs = import test-pkgspath { 336 336 inherit system; 337 - stdenvFunc = args: let 337 + stdenvStages = args: let 338 338 args' = args // { inherit bootstrapFiles; }; 339 - in (import (test-pkgspath + "/pkgs/stdenv/darwin") args').stdenvDarwin; 339 + in (import (test-pkgspath + "/pkgs/stdenv/darwin") args').stagesDarwin; 340 340 }; 341 341 }
+33 -45
pkgs/stdenv/default.nix
··· 1 - # This file defines the various standard build environments. 1 + # This file chooses a sane default stdenv given the system, platform, etc. 2 2 # 3 - # On Linux systems, the standard build environment consists of 4 - # Nix-built instances glibc and the `standard' Unix tools, i.e., the 5 - # Posix utilities, the GNU C compiler, and so on. On other systems, 6 - # we use the native C library. 3 + # Rather than returning a stdenv, this returns a list of functions---one per 4 + # each bootstrapping stage. See `./booter.nix` for exactly what this list should 5 + # contain. 7 6 8 7 { # Args just for stdenvs' usage 9 - lib, allPackages 10 - # Args to pass on to `allPacakges` too 8 + lib 9 + # Args to pass on to the pkgset builder, too 11 10 , system, platform, crossSystem, config 12 11 } @ args: 13 12 ··· 17 16 # i.e., the stuff in /bin, /usr/bin, etc. This environment should 18 17 # be used with care, since many Nix packages will not build properly 19 18 # with it (e.g., because they require GNU Make). 20 - inherit (import ./native args) stdenvNative; 21 - 22 - stdenvNativePkgs = allPackages { 23 - inherit system platform crossSystem config; 24 - allowCustomOverrides = false; 25 - stdenv = stdenvNative; 26 - noSysDirs = false; 27 - }; 28 - 19 + stagesNative = import ./native args; 29 20 30 21 # The Nix build environment. 31 - stdenvNix = assert crossSystem == null; import ./nix { 32 - inherit config lib; 33 - stdenv = stdenvNative; 34 - pkgs = stdenvNativePkgs; 35 - }; 22 + stagesNix = import ./nix (args // { bootStages = stagesNative; }); 36 23 37 - inherit (import ./freebsd args) stdenvFreeBSD; 24 + stagesFreeBSD = import ./freebsd args; 38 25 39 - # Linux standard environment. 40 - inherit (import ./linux args) stdenvLinux; 26 + # On Linux systems, the standard build environment consists of Nix-built 27 + # instances glibc and the `standard' Unix tools, i.e., the Posix utilities, 28 + # the GNU C compiler, and so on. 29 + stagesLinux = import ./linux args; 41 30 42 - inherit (import ./darwin args) stdenvDarwin; 31 + inherit (import ./darwin args) stagesDarwin; 43 32 44 - inherit (import ./cross args) stdenvCross stdenvCrossiOS; 33 + stagesCross = import ./cross args; 45 34 46 - inherit (import ./custom args) stdenvCustom; 35 + stagesCustom = import ./custom args; 47 36 48 - # Select the appropriate stdenv for the platform `system'. 37 + # Select the appropriate stages for the platform `system'. 49 38 in 50 - if crossSystem != null then 51 - if crossSystem.useiOSCross or false then stdenvCrossiOS 52 - else stdenvCross else 53 - if config ? replaceStdenv then stdenvCustom else 54 - if system == "i686-linux" then stdenvLinux else 55 - if system == "x86_64-linux" then stdenvLinux else 56 - if system == "armv5tel-linux" then stdenvLinux else 57 - if system == "armv6l-linux" then stdenvLinux else 58 - if system == "armv7l-linux" then stdenvLinux else 59 - if system == "mips64el-linux" then stdenvLinux else 60 - if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else 61 - if system == "x86_64-darwin" then stdenvDarwin else 62 - if system == "x86_64-solaris" then stdenvNix else 63 - if system == "i686-cygwin" then stdenvNative else 64 - if system == "x86_64-cygwin" then stdenvNative else 65 - if system == "x86_64-freebsd" then stdenvFreeBSD else 66 - stdenvNative 39 + if crossSystem != null then stagesCross 40 + else if config ? replaceStdenv then stagesCustom 41 + else { # switch 42 + "i686-linux" = stagesLinux; 43 + "x86_64-linux" = stagesLinux; 44 + "armv5tel-linux" = stagesLinux; 45 + "armv6l-linux" = stagesLinux; 46 + "armv7l-linux" = stagesLinux; 47 + "mips64el-linux" = stagesLinux; 48 + "powerpc-linux" = /* stagesLinux */ stagesNative; 49 + "x86_64-darwin" = stagesDarwin; 50 + "x86_64-solaris" = stagesNix; 51 + "i686-cygwin" = stagesNative; 52 + "x86_64-cygwin" = stagesNative; 53 + "x86_64-freebsd" = stagesFreeBSD; 54 + }.${system} or stagesNative
+64 -43
pkgs/stdenv/freebsd/default.nix
··· 1 - { lib, allPackages 1 + { lib 2 2 , system, platform, crossSystem, config 3 3 }: 4 4 5 5 assert crossSystem == null; 6 6 7 - rec { 8 - inherit allPackages; 9 7 10 - bootstrapTools = derivation { 11 - inherit system; 8 + [ 12 9 13 - name = "trivial-bootstrap-tools"; 14 - builder = "/usr/local/bin/bash"; 15 - args = [ ./trivial-bootstrap.sh ]; 10 + ({}: { 11 + __raw = true; 12 + 13 + bootstrapTools = derivation { 14 + inherit system; 15 + 16 + name = "trivial-bootstrap-tools"; 17 + builder = "/usr/local/bin/bash"; 18 + args = [ ./trivial-bootstrap.sh ]; 16 19 17 - mkdir = "/bin/mkdir"; 18 - ln = "/bin/ln"; 19 - }; 20 + mkdir = "/bin/mkdir"; 21 + ln = "/bin/ln"; 22 + }; 23 + }) 20 24 21 - fetchurl = import ../../build-support/fetchurl { 25 + ({ bootstrapTools, ... }: rec { 26 + __raw = true; 27 + 28 + inherit bootstrapTools; 29 + 30 + fetchurl = import ../../build-support/fetchurl { 31 + inherit stdenv; 32 + curl = bootstrapTools; 33 + }; 34 + 22 35 stdenv = import ../generic { 23 36 name = "stdenv-freebsd-boot-1"; 24 37 inherit system config; 25 - 26 - initialPath = [ "/" "/usr" ]; 27 - shell = "${bootstrapTools}/bin/bash"; 38 + initialPath = [ "/" "/usr" ]; 39 + shell = "${bootstrapTools}/bin/bash"; 28 40 fetchurlBoot = null; 29 41 cc = null; 42 + overrides = self: super: { 43 + }; 30 44 }; 31 - curl = bootstrapTools; 32 - }; 45 + }) 46 + 47 + (prevStage: { 48 + __raw = true; 33 49 34 - stdenvFreeBSD = import ../generic { 35 - name = "stdenv-freebsd-boot-3"; 50 + stdenv = import ../generic { 51 + name = "stdenv-freebsd-boot-0"; 52 + inherit system config; 53 + initialPath = [ prevStage.bootstrapTools ]; 54 + inherit (prevStage.stdenv) shell; 55 + fetchurlBoot = prevStage.fetchurl; 56 + cc = null; 57 + }; 58 + }) 36 59 37 - inherit system config; 60 + (prevStage: { 61 + inherit system crossSystem platform config; 62 + stdenv = import ../generic { 63 + name = "stdenv-freebsd-boot-3"; 64 + inherit system config; 38 65 39 - initialPath = [ bootstrapTools ]; 40 - shell = "${bootstrapTools}/bin/bash"; 41 - fetchurlBoot = fetchurl; 66 + inherit (prevStage.stdenv) 67 + initialPath shell fetchurlBoot; 42 68 43 - cc = import ../../build-support/cc-wrapper { 44 - nativeTools = true; 45 - nativePrefix = "/usr"; 46 - nativeLibc = true; 47 - stdenv = import ../generic { 48 - inherit system config; 49 - name = "stdenv-freebsd-boot-0"; 50 - initialPath = [ bootstrapTools ]; 51 - shell = stdenvFreeBSD.shell; 52 - fetchurlBoot = fetchurl; 53 - cc = null; 54 - }; 55 - cc = { 56 - name = "clang-9.9.9"; 57 - cc = "/usr"; 58 - outPath = "/usr"; 69 + cc = import ../../build-support/cc-wrapper { 70 + nativeTools = true; 71 + nativePrefix = "/usr"; 72 + nativeLibc = true; 73 + inherit (prevStage) stdenv; 74 + cc = { 75 + name = "clang-9.9.9"; 76 + cc = "/usr"; 77 + outPath = "/usr"; 78 + }; 79 + isClang = true; 59 80 }; 60 - isClang = true; 81 + 82 + preHook = ''export NIX_NO_SELF_RPATH=1''; 61 83 }; 84 + }) 62 85 63 - preHook = ''export NIX_NO_SELF_RPATH=1''; 64 - }; 65 - } 86 + ]
+1 -1
pkgs/stdenv/generic/default.nix
··· 1 1 let lib = import ../../../lib; in lib.makeOverridable ( 2 2 3 3 { system, name ? "stdenv", preHook ? "", initialPath, cc, shell 4 - , allowedRequisites ? null, extraAttrs ? {}, overrides ? (pkgs: {}), config 4 + , allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config 5 5 6 6 , # The `fetchurl' to use for downloading curl and its dependencies 7 7 # (see all-packages.nix).
+107 -102
pkgs/stdenv/linux/default.nix
··· 3 3 # external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C 4 4 # compiler and linker that do not search in default locations, 5 5 # ensuring purity of components produced by it. 6 - { lib, allPackages 6 + { lib 7 7 , system, platform, crossSystem, config 8 8 9 9 , bootstrapFiles ? ··· 18 18 19 19 assert crossSystem == null; 20 20 21 - rec { 21 + let 22 22 23 23 commonPreHook = 24 24 '' ··· 43 43 # This function builds the various standard environments used during 44 44 # the bootstrap. In all stages, we build an stdenv and the package 45 45 # set that can be built with that stdenv. 46 - stageFun = 47 - {gccPlain, glibc, binutils, coreutils, gnugrep, name, overrides ? (pkgs: {}), extraBuildInputs ? []}: 46 + stageFun = prevStage: 47 + { name, overrides ? (self: super: {}), extraBuildInputs ? [] }: 48 48 49 49 let 50 50 ··· 65 65 inherit system; 66 66 }; 67 67 68 - cc = if isNull gccPlain 68 + cc = if isNull prevStage.gcc-unwrapped 69 69 then null 70 70 else lib.makeOverridable (import ../../build-support/cc-wrapper) { 71 71 nativeTools = false; 72 72 nativeLibc = false; 73 - cc = gccPlain; 73 + cc = prevStage.gcc-unwrapped; 74 74 isGNU = true; 75 - libc = glibc; 76 - inherit binutils coreutils gnugrep; 75 + libc = prevStage.glibc; 76 + inherit (prevStage) binutils coreutils gnugrep; 77 77 name = name; 78 - stdenv = stage0.stdenv; 78 + stdenv = prevStage.ccWrapperStdenv; 79 79 }; 80 80 81 81 extraAttrs = { ··· 85 85 86 86 # stdenv.glibc is used by GCC build to figure out the system-level 87 87 # /usr/include directory. 88 - inherit glibc; 88 + inherit (prevStage) glibc; 89 89 }; 90 - overrides = pkgs: (overrides pkgs) // { fetchurl = thisStdenv.fetchurlBoot; }; 90 + overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; 91 91 }; 92 92 93 - thisPkgs = allPackages { 94 - inherit system platform crossSystem config; 95 - allowCustomOverrides = false; 96 - stdenv = thisStdenv; 97 - }; 93 + in { 94 + inherit system platform crossSystem config; 95 + stdenv = thisStdenv; 96 + }; 97 + 98 + in 98 99 99 - in { stdenv = thisStdenv; pkgs = thisPkgs; }; 100 + [ 100 101 102 + ({}: { 103 + __raw = true; 101 104 102 - # Build a dummy stdenv with no GCC or working fetchurl. This is 103 - # because we need a stdenv to build the GCC wrapper and fetchurl. 104 - stage0 = stageFun { 105 - gccPlain = null; 105 + gcc-unwrapped = null; 106 106 glibc = null; 107 107 binutils = null; 108 108 coreutils = null; 109 109 gnugrep = null; 110 + }) 111 + 112 + # Build a dummy stdenv with no GCC or working fetchurl. This is 113 + # because we need a stdenv to build the GCC wrapper and fetchurl. 114 + (prevStage: stageFun prevStage { 110 115 name = null; 111 116 112 - overrides = pkgs: { 117 + overrides = self: super: { 118 + # We thread stage0's stdenv through under this name so downstream stages 119 + # can use it for wrapping gcc too. This way, downstream stages don't need 120 + # to refer to this stage directly, which violates the principle that each 121 + # stage should only access the stage that came before it. 122 + ccWrapperStdenv = self.stdenv; 113 123 # The Glibc include directory cannot have the same prefix as the 114 124 # GCC include directory, since GCC gets confused otherwise (it 115 125 # will search the Glibc headers before the GCC headers). So 116 126 # create a dummy Glibc here, which will be used in the stdenv of 117 127 # stage1. 118 - glibc = stage0.stdenv.mkDerivation { 128 + glibc = self.stdenv.mkDerivation { 119 129 name = "bootstrap-glibc"; 120 130 buildCommand = '' 121 131 mkdir -p $out ··· 123 133 ln -s ${bootstrapTools}/include-glibc $out/include 124 134 ''; 125 135 }; 136 + gcc-unwrapped = bootstrapTools; 137 + binutils = bootstrapTools; 138 + coreutils = bootstrapTools; 139 + gnugrep = bootstrapTools; 126 140 }; 127 - }; 141 + }) 128 142 129 143 130 144 # Create the first "real" standard environment. This one consists ··· 137 151 # If we ever need to use a package from more than one stage back, we 138 152 # simply re-export those packages in the middle stage(s) using the 139 153 # overrides attribute and the inherit syntax. 140 - stage1 = stageFun { 141 - gccPlain = bootstrapTools; 142 - inherit (stage0.pkgs) glibc; 143 - binutils = bootstrapTools; 144 - coreutils = bootstrapTools; 145 - gnugrep = bootstrapTools; 154 + (prevStage: stageFun prevStage { 146 155 name = "bootstrap-gcc-wrapper"; 147 156 148 157 # Rebuild binutils to use from stage2 onwards. 149 - overrides = pkgs: { 150 - binutils = pkgs.binutils.override { gold = false; }; 151 - inherit (stage0.pkgs) glibc; 158 + overrides = self: super: { 159 + binutils = super.binutils.override { gold = false; }; 160 + inherit (prevStage) 161 + ccWrapperStdenv 162 + glibc gcc-unwrapped coreutils gnugrep; 152 163 153 164 # A threaded perl build needs glibc/libpthread_nonshared.a, 154 165 # which is not included in bootstrapTools, so disable threading. 155 166 # This is not an issue for the final stdenv, because this perl 156 167 # won't be included in the final stdenv and won't be exported to 157 168 # top-level pkgs as an override either. 158 - perl = pkgs.perl.override { enableThreading = false; }; 169 + perl = super.perl.override { enableThreading = false; }; 159 170 }; 160 - }; 171 + }) 161 172 162 173 163 174 # 2nd stdenv that contains our own rebuilt binutils and is used for 164 175 # compiling our own Glibc. 165 - stage2 = stageFun { 166 - gccPlain = bootstrapTools; 167 - inherit (stage1.pkgs) glibc; 168 - binutils = stage1.pkgs.binutils; 169 - coreutils = bootstrapTools; 170 - gnugrep = bootstrapTools; 176 + (prevStage: stageFun prevStage { 171 177 name = "bootstrap-gcc-wrapper"; 172 178 173 - overrides = pkgs: { 174 - inherit (stage1.pkgs) perl binutils paxctl gnum4 bison; 179 + overrides = self: super: { 180 + inherit (prevStage) 181 + ccWrapperStdenv 182 + binutils gcc-unwrapped coreutils gnugrep 183 + perl paxctl gnum4 bison; 175 184 # This also contains the full, dynamically linked, final Glibc. 176 185 }; 177 - }; 186 + }) 178 187 179 188 180 189 # Construct a third stdenv identical to the 2nd, except that this 181 190 # one uses the rebuilt Glibc from stage2. It still uses the recent 182 191 # binutils and rest of the bootstrap tools, including GCC. 183 - stage3 = stageFun { 184 - gccPlain = bootstrapTools; 185 - inherit (stage2.pkgs) glibc binutils; 186 - coreutils = bootstrapTools; 187 - gnugrep = bootstrapTools; 192 + (prevStage: stageFun prevStage { 188 193 name = "bootstrap-gcc-wrapper"; 189 194 190 - overrides = pkgs: rec { 191 - inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders gnum4 bison; 195 + overrides = self: super: rec { 196 + inherit (prevStage) 197 + ccWrapperStdenv 198 + binutils glibc coreutils gnugrep 199 + perl patchelf linuxHeaders gnum4 bison; 192 200 # Link GCC statically against GMP etc. This makes sense because 193 201 # these builds of the libraries are only used by GCC, so it 194 202 # reduces the size of the stdenv closure. 195 - gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; 196 - mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; 197 - libmpc = pkgs.libmpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; 198 - isl_0_14 = pkgs.isl_0_14.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; 199 - gccPlain = pkgs.gcc.cc.override { 203 + gmp = super.gmp.override { stdenv = self.makeStaticLibraries self.stdenv; }; 204 + mpfr = super.mpfr.override { stdenv = self.makeStaticLibraries self.stdenv; }; 205 + libmpc = super.libmpc.override { stdenv = self.makeStaticLibraries self.stdenv; }; 206 + isl_0_14 = super.isl_0_14.override { stdenv = self.makeStaticLibraries self.stdenv; }; 207 + gcc-unwrapped = super.gcc-unwrapped.override { 200 208 isl = isl_0_14; 201 209 }; 202 210 }; 203 - extraBuildInputs = [ stage2.pkgs.patchelf stage2.pkgs.paxctl ]; 204 - }; 211 + extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ]; 212 + }) 205 213 206 214 207 215 # Construct a fourth stdenv that uses the new GCC. But coreutils is 208 216 # still from the bootstrap tools. 209 - stage4 = stageFun { 210 - inherit (stage3.pkgs) gccPlain glibc binutils; 211 - gnugrep = bootstrapTools; 212 - coreutils = bootstrapTools; 217 + (prevStage: stageFun prevStage { 213 218 name = ""; 214 219 215 - overrides = pkgs: { 220 + overrides = self: super: { 216 221 # Zlib has to be inherited and not rebuilt in this stage, 217 222 # because gcc (since JAR support) already depends on zlib, and 218 223 # then if we already have a zlib we want to use that for the 219 224 # other purposes (binutils and top-level pkgs) too. 220 - inherit (stage3.pkgs) gettext gnum4 bison gmp perl glibc zlib linuxHeaders; 225 + inherit (prevStage) gettext gnum4 bison gmp perl glibc zlib linuxHeaders; 221 226 222 227 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { 223 228 nativeTools = false; 224 229 nativeLibc = false; 225 230 isGNU = true; 226 - cc = stage4.stdenv.cc.cc; 227 - libc = stage4.pkgs.glibc; 228 - inherit (stage4.pkgs) binutils coreutils gnugrep; 231 + cc = prevStage.gcc-unwrapped; 232 + libc = self.glibc; 233 + inherit (self) stdenv binutils coreutils gnugrep; 229 234 name = ""; 230 - stdenv = stage4.stdenv; 231 - shell = stage4.pkgs.bash + "/bin/bash"; 235 + shell = self.bash + "/bin/bash"; 232 236 }; 233 237 }; 234 - extraBuildInputs = [ stage3.pkgs.patchelf stage3.pkgs.xz ]; 235 - }; 236 - 238 + extraBuildInputs = [ prevStage.patchelf prevStage.xz ]; 239 + }) 237 240 238 241 # Construct the final stdenv. It uses the Glibc and GCC, and adds 239 242 # in a new binutils that doesn't depend on bootstrap-tools, as well ··· 242 245 # When updating stdenvLinux, make sure that the result has no 243 246 # dependency (`nix-store -qR') on bootstrapTools or the first 244 247 # binutils built. 245 - stdenvLinux = import ../generic rec { 246 - inherit system config; 248 + (prevStage: { 249 + inherit system crossSystem platform config; 250 + stdenv = import ../generic rec { 251 + inherit system config; 247 252 248 - preHook = 249 - '' 253 + preHook = '' 250 254 # Make "strip" produce deterministic output, by setting 251 255 # timestamps etc. to a fixed value. 252 256 commonStripFlags="--enable-deterministic-archives" 253 257 ${commonPreHook} 254 258 ''; 255 259 256 - initialPath = 257 - ((import ../common-path.nix) {pkgs = stage4.pkgs;}); 260 + initialPath = 261 + ((import ../common-path.nix) {pkgs = prevStage;}); 258 262 259 - extraBuildInputs = [ stage4.pkgs.patchelf stage4.pkgs.paxctl ]; 263 + extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ]; 260 264 261 - cc = stage4.pkgs.gcc; 265 + cc = prevStage.gcc; 262 266 263 - shell = cc.shell; 267 + shell = cc.shell; 264 268 265 - inherit (stage4.stdenv) fetchurlBoot; 269 + inherit (prevStage.stdenv) fetchurlBoot; 266 270 267 - extraAttrs = { 268 - inherit (stage4.pkgs) glibc; 269 - inherit platform bootstrapTools; 270 - shellPackage = stage4.pkgs.bash; 271 - }; 271 + extraAttrs = { 272 + inherit (prevStage) glibc; 273 + inherit platform bootstrapTools; 274 + shellPackage = prevStage.bash; 275 + }; 272 276 273 - /* outputs TODO 274 - allowedRequisites = with stage4.pkgs; 275 - [ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 276 - glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl 277 - paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv 278 - ]; 279 - */ 277 + /* outputs TODO 278 + allowedRequisites = with prevStage; 279 + [ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 280 + glibc gnumake gnused gnutar gnugrep gnupatch patchelf attr acl 281 + paxctl zlib pcre linuxHeaders ed gcc gcc.cc libsigsegv 282 + ]; 283 + */ 280 284 281 - overrides = pkgs: { 282 - gcc = cc; 285 + overrides = self: super: { 286 + gcc = cc; 283 287 284 - inherit (stage4.pkgs) 285 - gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 286 - glibc gnumake gnused gnutar gnugrep gnupatch patchelf 287 - attr acl paxctl zlib pcre; 288 + inherit (prevStage) 289 + gzip bzip2 xz bash binutils coreutils diffutils findutils gawk 290 + glibc gnumake gnused gnutar gnugrep gnupatch patchelf 291 + attr acl paxctl zlib pcre; 292 + }; 288 293 }; 289 - }; 294 + }) 290 295 291 - } 296 + ]
+44 -40
pkgs/stdenv/native/default.nix
··· 1 - { lib, allPackages 1 + { lib 2 2 , system, platform, crossSystem, config 3 3 }: 4 4 5 5 assert crossSystem == null; 6 6 7 - rec { 7 + let 8 8 9 9 shell = 10 10 if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash" ··· 77 77 # A function that builds a "native" stdenv (one that uses tools in 78 78 # /usr etc.). 79 79 makeStdenv = 80 - { cc, fetchurl, extraPath ? [], overrides ? (pkgs: { }) }: 80 + { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }: 81 81 82 82 import ../generic { 83 83 preHook = ··· 101 101 inherit system shell cc overrides config; 102 102 }; 103 103 104 + in 104 105 105 - stdenvBoot0 = makeStdenv { 106 - cc = null; 107 - fetchurl = null; 108 - }; 106 + [ 109 107 108 + ({}: rec { 109 + __raw = true; 110 110 111 - cc = import ../../build-support/cc-wrapper { 112 - name = "cc-native"; 113 - nativeTools = true; 114 - nativeLibc = true; 115 - nativePrefix = if system == "i686-solaris" then "/usr/gnu" else if system == "x86_64-solaris" then "/opt/local/gcc47" else "/usr"; 116 - stdenv = stdenvBoot0; 117 - }; 111 + stdenv = makeStdenv { 112 + cc = null; 113 + fetchurl = null; 114 + }; 118 115 116 + cc = import ../../build-support/cc-wrapper { 117 + name = "cc-native"; 118 + nativeTools = true; 119 + nativeLibc = true; 120 + nativePrefix = { # switch 121 + "i686-solaris" = "/usr/gnu"; 122 + "x86_64-solaris" = "/opt/local/gcc47"; 123 + }.${system} or "/usr"; 124 + inherit stdenv; 125 + }; 119 126 120 - fetchurl = import ../../build-support/fetchurl { 121 - stdenv = stdenvBoot0; 122 - # Curl should be in /usr/bin or so. 123 - curl = null; 124 - }; 127 + fetchurl = import ../../build-support/fetchurl { 128 + inherit stdenv; 129 + # Curl should be in /usr/bin or so. 130 + curl = null; 131 + }; 125 132 133 + }) 126 134 127 135 # First build a stdenv based only on tools outside the store. 128 - stdenvBoot1 = makeStdenv { 129 - inherit cc fetchurl; 130 - } // {inherit fetchurl;}; 131 - 132 - stdenvBoot1Pkgs = allPackages { 133 - inherit system platform crossSystem config; 134 - allowCustomOverrides = false; 135 - stdenv = stdenvBoot1; 136 - }; 137 - 138 - 139 - # Using that, build a stdenv that adds the ‘xz’ command (which most 140 - # systems don't have, so we mustn't rely on the native environment 141 - # providing it). 142 - stdenvBoot2 = makeStdenv { 143 - inherit cc fetchurl; 144 - extraPath = [ stdenvBoot1Pkgs.xz ]; 145 - overrides = pkgs: { inherit (stdenvBoot1Pkgs) xz; }; 146 - }; 136 + (prevStage: { 137 + inherit system crossSystem platform config; 138 + stdenv = makeStdenv { 139 + inherit (prevStage) cc fetchurl; 140 + } // { inherit (prevStage) fetchurl; }; 141 + }) 147 142 143 + # Using that, build a stdenv that adds the ‘xz’ command (which most systems 144 + # don't have, so we mustn't rely on the native environment providing it). 145 + (prevStage: { 146 + inherit system crossSystem platform config; 147 + stdenv = makeStdenv { 148 + inherit (prevStage.stdenv) cc fetchurl; 149 + extraPath = [ prevStage.xz ]; 150 + overrides = self: super: { inherit (prevStage) xz; }; 151 + }; 152 + }) 148 153 149 - stdenvNative = stdenvBoot2; 150 - } 154 + ]
+45 -31
pkgs/stdenv/nix/default.nix
··· 1 - { stdenv, pkgs, config, lib }: 1 + { lib 2 + , crossSystem, config 3 + , bootStages 4 + , ... 5 + }: 2 6 3 - import ../generic rec { 4 - inherit config; 7 + assert crossSystem == null; 5 8 6 - preHook = 7 - '' 8 - export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}" 9 - export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" 10 - export NIX_IGNORE_LD_THROUGH_GCC=1 11 - ''; 9 + bootStages ++ [ 10 + (prevStage: let 11 + inherit (prevStage) stdenv; 12 + inherit (stdenv) system platform; 13 + in { 14 + inherit system platform crossSystem config; 12 15 13 - initialPath = (import ../common-path.nix) {pkgs = pkgs;}; 16 + stdenv = import ../generic rec { 17 + inherit config; 14 18 15 - system = stdenv.system; 19 + preHook = '' 20 + export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}" 21 + export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" 22 + export NIX_IGNORE_LD_THROUGH_GCC=1 23 + ''; 16 24 17 - cc = import ../../build-support/cc-wrapper { 18 - nativeTools = false; 19 - nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; 20 - nativeLibc = true; 21 - inherit stdenv; 22 - inherit (pkgs) binutils coreutils gnugrep; 23 - cc = pkgs.gcc.cc; 24 - isGNU = true; 25 - shell = pkgs.bash + "/bin/sh"; 26 - }; 25 + initialPath = (import ../common-path.nix) { pkgs = prevStage; }; 27 26 28 - shell = pkgs.bash + "/bin/sh"; 27 + system = stdenv.system; 29 28 30 - fetchurlBoot = stdenv.fetchurlBoot; 29 + cc = import ../../build-support/cc-wrapper { 30 + nativeTools = false; 31 + nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; 32 + nativeLibc = true; 33 + inherit stdenv; 34 + inherit (prevStage) binutils coreutils gnugrep; 35 + cc = prevStage.gcc.cc; 36 + isGNU = true; 37 + shell = prevStage.bash + "/bin/sh"; 38 + }; 31 39 32 - overrides = pkgs_: { 33 - inherit cc; 34 - inherit (cc) binutils; 35 - inherit (pkgs) 36 - gzip bzip2 xz bash coreutils diffutils findutils gawk 37 - gnumake gnused gnutar gnugrep gnupatch perl; 38 - }; 39 - } 40 + shell = prevStage.bash + "/bin/sh"; 41 + 42 + fetchurlBoot = stdenv.fetchurlBoot; 43 + 44 + overrides = self: super: { 45 + inherit cc; 46 + inherit (cc) binutils; 47 + inherit (prevStage) 48 + gzip bzip2 xz bash coreutils diffutils findutils gawk 49 + gnumake gnused gnutar gnugrep gnupatch perl; 50 + }; 51 + }; 52 + }) 53 + ]
+2 -6
pkgs/top-level/all-packages.nix
··· 5 5 * to merges. Please use the full-text search of your editor. ;) 6 6 * Hint: ### starts category names. 7 7 */ 8 - { system, noSysDirs, config, crossSystem, platform, lib 9 - , nixpkgsFun 10 - }: 8 + { lib, nixpkgsFun, noSysDirs, config}: 11 9 self: pkgs: 12 10 13 11 with pkgs; ··· 17 15 in 18 16 19 17 { 20 - 21 - # Make some arguments passed to all-packages.nix available 22 - inherit system platform; 23 18 24 19 # Allow callPackage to fill in the pkgs argument 25 20 inherit pkgs; ··· 4728 4723 gambit = callPackage ../development/compilers/gambit { }; 4729 4724 4730 4725 gcc = gcc5; 4726 + gcc-unwrapped = gcc.cc; 4731 4727 4732 4728 wrapCCMulti = cc: 4733 4729 if system == "x86_64-linux" then lowPrio (
+13 -10
pkgs/top-level/default.nix
··· 7 7 8 8 3. Defaults to no non-standard config and no cross-compilation target 9 9 10 - 4. Uses the above to infer the default standard environment (stdenv) if 11 - none is provided 10 + 4. Uses the above to infer the default standard environment's (stdenv's) 11 + stages if no stdenv's are provided 12 12 13 - 5. Builds the final stage --- a fully booted package set with the chosen 14 - stdenv 13 + 5. Folds the stages to yield the final fully booted package set for the 14 + chosen stdenv 15 15 16 16 Use `impure.nix` to also infer the `system` based on the one on which 17 17 evaluation is taking place, and the configuration from environment variables ··· 23 23 , # Allow a configuration attribute set to be passed in as an argument. 24 24 config ? {} 25 25 26 - , # The standard environment for building packages, or rather a function 27 - # providing it. See below for the arguments given to that function. 28 - stdenvFunc ? import ../stdenv 26 + , # A function booting the final package set for a specific standard 27 + # environment. See below for the arguments given to that function, 28 + # the type of list it returns. 29 + stdenvStages ? import ../stdenv 29 30 30 31 , crossSystem ? null 31 32 , platform ? assert false; null ··· 76 77 inherit lib nixpkgsFun; 77 78 } // newArgs); 78 79 79 - stdenv = stdenvFunc { 80 - inherit lib allPackages system platform crossSystem config; 80 + boot = import ../stdenv/booter.nix { inherit lib allPackages; }; 81 + 82 + stages = stdenvStages { 83 + inherit lib system platform crossSystem config; 81 84 }; 82 85 83 - pkgs = allPackages { inherit system stdenv config crossSystem platform; }; 86 + pkgs = boot stages; 84 87 85 88 in pkgs
+12 -14
pkgs/top-level/stage.nix
··· 18 18 , # This is used because stdenv replacement and the stdenvCross do benefit from 19 19 # the overridden configuration provided by the user, as opposed to the normal 20 20 # bootstrapping stdenvs. 21 - allowCustomOverrides ? true 21 + allowCustomOverrides 22 22 23 23 , # Non-GNU/Linux OSes are currently "impure" platforms, with their libc 24 24 # outside of the store. Thus, GCC, GFortran, & co. must always look for ··· 47 47 inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; 48 48 }; 49 49 50 - stdenvDefault = self: super: 51 - { stdenv = stdenv // { inherit platform; }; }; 50 + stdenvBootstappingAndPlatforms = self: super: { 51 + stdenv = stdenv // { inherit platform; }; 52 + inherit 53 + system platform crossSystem; 54 + }; 52 55 53 56 allPackages = self: super: 54 57 let res = import ./all-packages.nix 55 - { inherit system noSysDirs config crossSystem platform lib nixpkgsFun; } 58 + { inherit lib nixpkgsFun noSysDirs config; } 56 59 res self; 57 60 in res; 58 61 59 62 aliases = self: super: import ./aliases.nix super; 60 63 61 - # stdenvOverrides is used to avoid circular dependencies for building 62 - # the standard build environment. This mechanism uses the override 63 - # mechanism to implement some staged compilation of the stdenv. 64 - # 65 - # We don't want stdenv overrides in the case of cross-building, or 66 - # otherwise the basic overridden packages will not be built with the 67 - # crossStdenv adapter. 64 + # stdenvOverrides is used to avoid having multiple of versions 65 + # of certain dependencies that were used in bootstrapping the 66 + # standard environment. 68 67 stdenvOverrides = self: super: 69 - lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides) 70 - (super.stdenv.overrides super); 68 + (super.stdenv.overrides or (_: _: {})) self super; 71 69 72 70 # Allow packages to be overridden globally via the `packageOverrides' 73 71 # configuration option, which must be a function that takes `pkgs' ··· 82 80 83 81 # The complete chain of package set builders, applied from top to bottom 84 82 toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [ 85 - stdenvDefault 83 + stdenvBootstappingAndPlatforms 86 84 stdenvAdapters 87 85 trivialBuilders 88 86 allPackages