2 , localSystem, crossSystem, config, overlays, crossOverlays ? []
5 assert crossSystem == localSystem;
8 inherit (localSystem) system;
11 if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
15 (lib.optionals (system == "i686-solaris") [ "/usr/gnu" ]) ++
16 (lib.optionals (system == "i686-netbsd") [ "/usr/pkg" ]) ++
17 (lib.optionals (system == "x86_64-solaris") [ "/opt/local/gnu" ]) ++
18 ["/" "/usr" "/usr/local"];
21 # Disable purity tests; it's allowed (even needed) to link to
22 # libraries outside the Nix store (like the C library).
23 export NIX_ENFORCE_PURITY=
24 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
34 shopt -s expand_aliases
48 shopt -s expand_aliases
58 shopt -s expand_aliases
61 # prevent libtool from failing to find dynamic libraries
65 shopt -s expand_aliases
66 export lt_cv_deplibs_check_method=pass_all
69 extraNativeBuildInputsCygwin = [
70 ../cygwin/all-buildinputs-as-runtimedep.sh
71 ../cygwin/wrap-exes-to-find-dlls.sh
72 ] ++ (if system == "i686-cygwin" then [
73 ../cygwin/rebase-i686.sh
74 ] else if system == "x86_64-cygwin" then [
75 ../cygwin/rebase-x86_64.sh
78 # A function that builds a "native" stdenv (one that uses tools in
81 { cc, fetchurl, extraPath ? [], overrides ? (self: super: { }), extraNativeBuildInputs ? [] }:
84 buildPlatform = localSystem;
85 hostPlatform = localSystem;
86 targetPlatform = localSystem;
89 if system == "i686-freebsd" then prehookFreeBSD else
90 if system == "x86_64-freebsd" then prehookFreeBSD else
91 if system == "i686-openbsd" then prehookOpenBSD else
92 if system == "i686-netbsd" then prehookNetBSD else
93 if system == "i686-cygwin" then prehookCygwin else
94 if system == "x86_64-cygwin" then prehookCygwin else
97 extraNativeBuildInputs = extraNativeBuildInputs ++
98 (if system == "i686-cygwin" then extraNativeBuildInputsCygwin else
99 if system == "x86_64-cygwin" then extraNativeBuildInputsCygwin else
102 initialPath = extraPath ++ path;
104 fetchurlBoot = fetchurl;
106 inherit shell cc overrides config;
116 stdenv = makeStdenv {
123 nativePrefix = { # switch
124 i686-solaris = "/usr/gnu";
125 x86_64-solaris = "/opt/local/gcc47";
126 }.${system} or "/usr";
128 import ../../build-support/cc-wrapper {
132 inherit lib nativePrefix;
133 bintools = import ../../build-support/bintools-wrapper {
135 inherit lib stdenvNoCC nativePrefix;
142 fetchurl = import ../../build-support/fetchurl {
143 inherit lib stdenvNoCC;
144 # Curl should be in /usr/bin or so.
150 # First build a stdenv based only on tools outside the store.
152 inherit config overlays;
153 stdenv = makeStdenv {
154 inherit (prevStage) cc fetchurl;
155 overrides = self: super: { inherit (prevStage) fetchurl; };
157 inherit (prevStage) fetchurl;
161 # Using that, build a stdenv that adds the ‘xz’ command (which most systems
162 # don't have, so we mustn't rely on the native environment providing it).
164 inherit config overlays;
165 stdenv = makeStdenv {
166 inherit (prevStage.stdenv) cc fetchurl;
167 extraPath = [ prevStage.xz ];
168 overrides = self: super: { inherit (prevStage) fetchurl xz; };
169 extraNativeBuildInputs = if localSystem.isLinux then [ prevStage.patchelf ] else [];