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