git.iko.soy/typeable/nixpkgs
on master help sign in
stdenv-darwin: kill old impure Darwin stdenv

I'll be moving the other one over it next commit (I split it into two to improve git's rename detection)

commit01b0b3cec0139cc47acca8109fdb4bdbd1734c45 authorDan Peebles <pumpkin@me.com> dateSun 3 Jan 2016, 21:06 (11 years ago) parente81ae8e
5 files changed−557
pkgs/stdenv/darwin/default.nix−149 pkgs/stdenv/darwin/make-bootstrap-tools.nix−284 pkgs/stdenv/darwin/trivial-bootstrap.sh−67 pkgs/stdenv/darwin/unpack-bootstrap-tools.sh−54 pkgs/stdenv/default.nix−3
pkgs/stdenv/darwin/default.nixdeleted−149
@@ -1,149 +0,0 @@
1−{ system ? builtins.currentSystem
2−, allPackages ? import ../../top-level/all-packages.nix
3−, platform ? null
4−, config ? {}
5−}:
6−
7−rec {
8− allPackages = import ../../top-level/all-packages.nix;
9−
10− bootstrapTools = derivation {
11− inherit system;
12−
13− name = "trivial-bootstrap-tools";
14− builder = "/bin/sh";
15− args = [ ./trivial-bootstrap.sh ];
16−
17− mkdir = "/bin/mkdir";
18− ln = "/bin/ln";
19− };
20−
21− # The simplest stdenv possible to run fetchadc and get the Apple command-line tools
22− stage0 = rec {
23− fetchurl = import ../../build-support/fetchurl {
24− inherit stdenv;
25− curl = bootstrapTools;
26− };
27−
28− stdenv = import ../generic {
29− inherit system config;
30− name = "stdenv-darwin-boot-0";
31− shell = "/bin/bash";
32− initialPath = [ bootstrapTools ];
33− fetchurlBoot = fetchurl;
34− cc = null;
35− };
36− };
37−
38− buildTools = import ../../os-specific/darwin/command-line-tools {
39− inherit (stage0) stdenv fetchurl;
40− xar = bootstrapTools;
41− gzip = bootstrapTools;
42− cpio = bootstrapTools;
43− };
44−
45− preHook = ''
46− export NIX_IGNORE_LD_THROUGH_GCC=1
47− export NIX_DONT_SET_RPATH=1
48− export NIX_NO_SELF_RPATH=1
49− dontFixLibtool=1
50− stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
51− xargsFlags=" "
52− export MACOSX_DEPLOYMENT_TARGET=10.7
53− # Use the 10.9 SDK if we're running on 10.9, and 10.10 if we're
54− # running on 10.10. We need to use the 10.10 headers for functions
55− # like readlinkat() that are dynamically detected by configure
56− # scripts. Very impure, obviously.
57− export SDKROOT=$(/usr/bin/xcrun --sdk macosx"$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d. -f1,2)" --show-sdk-path 2> /dev/null || echo /)
58− export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
59− export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib"
60− export CMAKE_OSX_ARCHITECTURES=x86_64
61− # Workaround for https://openradar.appspot.com/22671534 on 10.11.
62− export gl_cv_func_getcwd_abort_bug=no
63− '';
64−
65− # A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
66− stage1 = rec {
67− nativePrefix = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
68−
69− stdenv = import ../generic {
70− name = "stdenv-darwin-boot-1";
71−
72− inherit system config;
73− inherit (stage0.stdenv) shell fetchurlBoot;
74−
75− initialPath = stage0.stdenv.initialPath ++ [ nativePrefix ];
76−
77− preHook = preHook + "\n" + ''
78− export NIX_LDFLAGS_AFTER+=" -L/usr/lib"
79− export NIX_ENFORCE_PURITY=
80− export NIX_CFLAGS_COMPILE+=" -isystem ${nativePrefix}/include/c++/v1 -stdlib=libc++"
81− export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,${nativePrefix}/lib"
82− '';
83−
84− cc = import ../../build-support/cc-wrapper {
85− nativeTools = true;
86− nativePrefix = nativePrefix;
87− nativeLibc = true;
88− stdenv = stage0.stdenv;
89− shell = "/bin/bash";
90− cc = {
91− name = "clang-9.9.9";
92− cc = "/usr";
93− outPath = nativePrefix;
94− };
95− isClang = true;
96− };
97− };
98− pkgs = allPackages {
99− inherit system platform;
100− bootStdenv = stdenv;
101− };
102− };
103−
104− stage2 = rec {
105− stdenv = import ../generic {
106− name = "stdenv-darwin-boot-2";
107−
108− inherit system config;
109− inherit (stage1.stdenv) shell fetchurlBoot preHook cc;
110−
111− initialPath = [ stage1.pkgs.xz stage1.pkgs.gnused ] ++ stage1.stdenv.initialPath;
112− };
113− pkgs = allPackages {
114− inherit system platform;
115− bootStdenv = stdenv;
116− };
117− };
118−
119− # Use stage1 to build a whole set of actual tools so we don't have to rely on the Apple prebuilt ones or
120− # the ugly symlinked bootstrap tools anymore.
121− stage3 = with stage2; import ../generic {
122− name = "stdenv-darwin-boot-3";
123−
124− inherit system config;
125− inherit (stdenv) fetchurlBoot;
126−
127− initialPath = (import ../common-path.nix) { inherit pkgs; };
128−
129− preHook = preHook + "\n" + ''
130− export NIX_ENFORCE_PURITY=1
131− '';
132−
133− cc = import ../../build-support/cc-wrapper {
134− inherit stdenv;
135− nativeTools = false;
136− nativeLibc = true;
137− binutils = pkgs.darwin.cctools;
138− cc = pkgs.llvmPackages.clang-unwrapped;
139− coreutils = pkgs.coreutils;
140− shell = "${pkgs.bash}/bin/bash";
141− extraPackages = [ pkgs.libcxx ];
142− isClang = true;
143− };
144−
145− shell = "${pkgs.bash}/bin/bash";
146− };
147−
148− stdenvDarwin = stage3;
149−}
pkgs/stdenv/darwin/make-bootstrap-tools.nixdeleted−284
@@ -1,284 +0,0 @@
1−{system ? builtins.currentSystem}:
2−
3−with import ../../top-level/all-packages.nix {inherit system;};
4−
5−rec {
6− # We want coreutils without ACL support.
7− coreutils_ = coreutils.override (orig: {
8− aclSupport = false;
9− });
10−
11− build = stdenv.mkDerivation {
12− name = "build";
13−
14− buildInputs = [nukeReferences cpio];
15−
16− buildCommand = ''
17− mkdir -p $out/bin $out/lib
18−
19− # Our (fake) loader
20− cp -d ${darwin.dyld}/lib/dyld $out/lib/
21−
22− # C standard library stuff
23− cp -d ${darwin.Libsystem}/lib/*.o $out/lib/
24− cp -d ${darwin.Libsystem}/lib/*.dylib $out/lib/
25− cp -d ${darwin.Libsystem}/lib/system/*.dylib $out/lib/
26−
27− # Resolv is actually a link to another package, so let's copy it properly
28− rm $out/lib/libresolv.9.dylib
29− cp -L ${darwin.Libsystem}/lib/libresolv.9.dylib $out/lib
30−
31− cp -rL ${darwin.Libsystem}/include $out
32− chmod -R u+w $out/include
33− cp -rL ${icu}/include* $out/include
34− cp -rL ${libiconv}/include/* $out/include
35− cp -rL ${gnugrep.pcre}/include/* $out/include
36− mv $out/include $out/include-Libsystem
37−
38− # Copy coreutils, bash, etc.
39− cp ${coreutils_}/bin/* $out/bin
40− (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
41−
42− cp ${bash}/bin/bash $out/bin
43− cp ${findutils}/bin/find $out/bin
44− cp ${findutils}/bin/xargs $out/bin
45− cp -d ${diffutils}/bin/* $out/bin
46− cp -d ${gnused}/bin/* $out/bin
47− cp -d ${gnugrep}/bin/grep $out/bin
48− cp ${gawk}/bin/gawk $out/bin
49− cp -d ${gawk}/bin/awk $out/bin
50− cp ${gnutar}/bin/tar $out/bin
51− cp ${gzip}/bin/gzip $out/bin
52− cp ${bzip2}/bin/bzip2 $out/bin
53− cp -d ${gnumake}/bin/* $out/bin
54− cp -d ${patch}/bin/* $out/bin
55− cp -d ${xz}/bin/xz $out/bin
56−
57− # This used to be in-nixpkgs, but now is in the bundle
58− # because I can't be bothered to make it partially static
59− cp ${curl}/bin/curl $out/bin
60− cp -d ${curl}/lib/libcurl*.dylib $out/lib
61− cp -d ${libssh2}/lib/libssh*.dylib $out/lib
62− cp -d ${openssl}/lib/*.dylib $out/lib
63−
64− cp -d ${gnugrep.pcre}/lib/libpcre*.dylib $out/lib
65− cp -d ${libiconv}/lib/libiconv*.dylib $out/lib
66−
67− # Copy what we need of clang
68− cp -d ${llvmPackages.clang}/bin/clang $out/bin
69− cp -d ${llvmPackages.clang}/bin/clang++ $out/bin
70− cp -d ${llvmPackages.clang}/bin/clang-3.5 $out/bin
71−
72− cp -rL ${llvmPackages.clang}/lib/clang $out/lib
73−
74− cp -d ${libcxx}/lib/libc++*.dylib $out/lib
75− cp -d ${libcxxabi}/lib/libc++abi*.dylib $out/lib
76−
77− mkdir $out/include
78− cp -rd ${libcxx}/include/c++ $out/include
79−
80− cp -d ${icu}/lib/libicu*.dylib $out/lib
81− cp -d ${zlib}/lib/libz.* $out/lib
82− cp -d ${gmpxx}/lib/libgmp*.* $out/lib
83− cp -d ${xz}/lib/liblzma*.* $out/lib
84−
85− # Copy binutils.
86− for i in as ld ar ranlib nm strip otool install_name_tool dsymutil; do
87− cp ${darwin.cctools}/bin/$i $out/bin
88− done
89−
90− cp -rd ${pkgs.darwin.CF}/Library $out
91−
92− chmod -R u+w $out
93−
94− nuke-refs $out/bin/*
95−
96− rpathify() {
97− local libs=$(${darwin.cctools}/bin/otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
98− for lib in $libs; do
99− ${darwin.cctools}/bin/install_name_tool -change $lib "@rpath/$(basename $lib)" "$1"
100− done
101− }
102−
103− fix_dyld() {
104− # This is clearly a hack. Once we have an install_name_tool-alike that can patch dyld, this will be nicer.
105− ${perl}/bin/perl -i -0777 -pe 's/\/nix\/store\/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-dyld-239\.4\/lib\/dyld/\/usr\/lib\/dyld\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00/sg' "$1"
106− }
107−
108− # Strip executables even further
109− for i in $out/bin/*; do
110− if test -x $i -a ! -L $i; then
111− chmod +w $i
112−
113− fix_dyld $i
114− strip $i || true
115− fi
116− done
117−
118− for i in $out/bin/* $out/lib/*.dylib $out/lib/clang/3.5.0/lib/darwin/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do
119− if test -x $i -a ! -L $i; then
120− echo "Adding rpath to $i"
121− rpathify $i
122− fi
123− done
124−
125− nuke-refs $out/lib/*
126− nuke-refs $out/lib/clang/3.5.0/lib/darwin/*
127− nuke-refs $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
128−
129− mkdir $out/.pack
130− mv $out/* $out/.pack
131− mv $out/.pack $out/pack
132−
133− mkdir $out/on-server
134− (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2
135−
136− mkdir $out/in-nixpkgs
137− cp ${stdenv.shell} $out/in-nixpkgs/sh
138− cp ${cpio}/bin/cpio $out/in-nixpkgs
139− cp ${coreutils_}/bin/mkdir $out/in-nixpkgs
140− cp ${bzip2}/bin/bzip2 $out/in-nixpkgs
141−
142− chmod u+w $out/in-nixpkgs/*
143− strip $out/in-nixpkgs/*
144− nuke-refs $out/in-nixpkgs/*
145−
146− for i in $out/in-nixpkgs/*; do
147− fix_dyld $i
148− done
149− '';
150−
151− allowedReferences = [];
152− };
153−
154− host = stdenv.mkDerivation {
155− name = "host";
156−
157− buildCommand = ''
158− mkdir -p $out/nix-support
159−
160− for i in "${build}/on-server/"*; do
161− echo "file binary-dist $i" >> $out/nix-support/hydra-build-products
162− done
163−
164− echo "darwin-bootstrap-tools-$(date +%Y.%m.%d)" >> $out/nix-support/hydra-release-name
165− '';
166−
167− allowedReferences = [ build ];
168− };
169−
170− unpack = stdenv.mkDerivation {
171− name = "unpack";
172−
173− # This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly,
174− # we can't make any changes to it due to our testing stdenv depending on it. Think of this as the
175− # unpack-bootstrap-tools.sh for the next round of bootstrap tools.
176− # TODO: think through alternate designs, such as hosting this script as an output of the process.
177− buildCommand = ''
178− # Unpack the bootstrap tools tarball.
179− echo Unpacking the bootstrap tools...
180− $mkdir $out
181− $bzip2 -d < $tarball | (cd $out && $cpio -i)
182−
183− # Set the ELF interpreter / RPATH in the bootstrap binaries.
184− echo Patching the tools...
185−
186− export PATH=$out/bin
187−
188− for i in $out/bin/*; do
189− if ! test -L $i; then
190− echo patching $i
191− install_name_tool -add_rpath $out/lib $i || true
192− fi
193− done
194−
195− for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do
196− if ! test -L $i; then
197− echo patching $i
198−
199− id=$(otool -D "$i" | tail -n 1)
200− install_name_tool -id "$(dirname $i)/$(basename $id)" $i
201−
202− libs=$(otool -L "$i" | tail -n +2 | grep -v Libsystem | cat)
203− if [ -n "$libs" ]; then
204− install_name_tool -add_rpath $out/lib $i
205− fi
206− fi
207− done
208−
209− ln -s bash $out/bin/sh
210− ln -s bzip2 $out/bin/bunzip2
211−
212− cat >$out/bin/dsymutil << EOF
213− #!$out/bin/sh
214− EOF
215− '';
216−
217− tarball = "${build}/on-server/bootstrap-tools.cpio.bz2";
218−
219− mkdir = "${build}/in-nixpkgs/mkdir";
220− bzip2 = "${build}/in-nixpkgs/bzip2";
221− cpio = "${build}/in-nixpkgs/cpio";
222−
223− allowedReferences = [ "out" ];
224− };
225−
226− test = stdenv.mkDerivation {
227− name = "test";
228−
229− realBuilder = "${unpack}/bin/bash";
230−
231− buildCommand = ''
232− export PATH=${unpack}/bin
233− ls -l
234− mkdir $out
235− mkdir $out/bin
236− sed --version
237− find --version
238− diff --version
239− patch --version
240− make --version
241− awk --version
242− grep --version
243− clang --version
244− xz --version
245−
246− # The grep will return a nonzero exit code if there is no match, and we want to assert that we have
247− # an SSL-capable curl
248− curl --version | grep SSL
249−
250− ${build}/in-nixpkgs/sh -c 'echo Hello World'
251−
252− export flags="-idirafter ${unpack}/include-Libsystem --sysroot=${unpack} -L${unpack}/lib"
253−
254− export CPP="clang -E $flags"
255− export CC="clang $flags -Wl,-rpath,${unpack}/lib -Wl,-v"
256− export CXX="clang++ $flags --stdlib=libc++ -lc++abi -isystem${unpack}/include/c++/v1 -Wl,-rpath,${unpack}/lib -Wl,-v"
257−
258− echo '#include <stdio.h>' >> foo.c
259− echo '#include <float.h>' >> foo.c
260− echo '#include <limits.h>' >> foo.c
261− echo 'int main() { printf("Hello World\n"); return 0; }' >> foo.c
262− $CC -o $out/bin/foo foo.c
263− $out/bin/foo
264−
265− echo '#include <CoreFoundation/CoreFoundation.h>' >> bar.c
266− echo 'int main() { CFShow(CFSTR("Hullo")); return 0; }' >> bar.c
267− $CC -F${unpack}/Library/Frameworks -framework CoreFoundation -o $out/bin/bar bar.c
268− $out/bin/bar
269−
270− echo '#include <iostream>' >> bar.cc
271− echo 'int main() { std::cout << "Hello World\n"; }' >> bar.cc
272− $CXX -v -o $out/bin/bar bar.cc
273− $out/bin/bar
274−
275− tar xvf ${hello.src}
276− cd hello-*
277− ./configure --prefix=$out
278− make
279− make install
280−
281− $out/bin/hello
282− '';
283− };
284−}
pkgs/stdenv/darwin/trivial-bootstrap.shdeleted−67
@@ -1,67 +0,0 @@
1−
2−# Building bootstrap tools
3−echo Building the trivial bootstrap environment...
4−$mkdir -p $out/bin
5−
6−$ln -s $ln $out/bin/ln
7−
8−PATH=$out/bin/
9−
10−cd $out/bin
11−
12−ln -s $mkdir
13−ln -s /bin/sh
14−ln -s /bin/cp
15−ln -s /bin/dd
16−ln -s /bin/mv
17−ln -s /bin/rm
18−ln -s /bin/ls
19−ln -s /bin/ps
20−ln -s /bin/cat
21−ln -s /bin/bash
22−ln -s /bin/echo
23−ln -s /bin/expr
24−ln -s /bin/test
25−ln -s /bin/date
26−ln -s /bin/chmod
27−ln -s /bin/rmdir
28−ln -s /bin/sleep
29−ln -s /bin/hostname
30−
31−ln -s /usr/bin/id
32−ln -s /usr/bin/od
33−ln -s /usr/bin/tr
34−ln -s /usr/bin/wc
35−ln -s /usr/bin/cut
36−ln -s /usr/bin/cmp
37−ln -s /usr/bin/sed
38−ln -s /usr/bin/tar
39−ln -s /usr/bin/xar
40−ln -s /usr/bin/awk
41−ln -s /usr/bin/env
42−ln -s /usr/bin/tee
43−ln -s /usr/bin/comm
44−ln -s /usr/bin/cpio
45−ln -s /usr/bin/curl
46−ln -s /usr/bin/find
47−ln -s /usr/bin/grep
48−ln -s /usr/bin/gzip
49−ln -s /usr/bin/head
50−ln -s /usr/bin/tail
51−ln -s /usr/bin/sort
52−ln -s /usr/bin/uniq
53−ln -s /usr/bin/less
54−ln -s /usr/bin/true
55−ln -s /usr/bin/diff
56−ln -s /usr/bin/egrep
57−ln -s /usr/bin/fgrep
58−ln -s /usr/bin/patch
59−ln -s /usr/bin/uname
60−ln -s /usr/bin/touch
61−ln -s /usr/bin/split
62−ln -s /usr/bin/xargs
63−ln -s /usr/bin/which
64−ln -s /usr/bin/install
65−ln -s /usr/bin/basename
66−ln -s /usr/bin/dirname
67−ln -s /usr/bin/readlink
pkgs/stdenv/darwin/unpack-bootstrap-tools.shdeleted−54
@@ -1,54 +0,0 @@
1−set -e
2−
3−# Unpack the bootstrap tools tarball.
4−echo Unpacking the bootstrap tools...
5−$mkdir $out
6−$bzip2 -d < $tarball | (cd $out && $cpio -i)
7−
8−# Set the ELF interpreter / RPATH in the bootstrap binaries.
9−echo Patching the tools...
10−
11−export PATH=$out/bin
12−
13−for i in $out/bin/*; do
14− if ! test -L $i; then
15− echo patching $i
16− install_name_tool -add_rpath $out/lib $i || true
17− fi
18−done
19−
20−for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do
21− if ! test -L $i; then
22− echo patching $i
23−
24− id=$(otool -D "$i" | tail -n 1)
25− install_name_tool -id "$(dirname $i)/$(basename $id)" $i
26−
27− libs=$(otool -L "$i" | tail -n +2 | grep -v libSystem | cat)
28− if [ -n "$libs" ]; then
29− install_name_tool -add_rpath $out/lib $i
30− fi
31− fi
32−done
33−
34−ln -s bash $out/bin/sh
35−ln -s bzip2 $out/bin/bunzip2
36−
37−# Provide a gunzip script.
38−cat > $out/bin/gunzip <<EOF
39−#!$out/bin/sh
40−exec $out/bin/gzip -d "\$@"
41−EOF
42−chmod +x $out/bin/gunzip
43−
44−# Provide fgrep/egrep.
45−echo "#! $out/bin/sh" > $out/bin/egrep
46−echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
47−echo "#! $out/bin/sh" > $out/bin/fgrep
48−echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
49−
50−cat >$out/bin/dsymutil << EOF
51−#!$out/bin/sh
52−EOF
53−
54−chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil
pkgs/stdenv/default.nix−3
@@ -36,9 +36,6 @@ rec {
3636 # Linux standard environment.
3737 stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
3838
39− # Darwin standard environment.
40− stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
41−
4239 # Pure Darwin standard environment. Allows building with the sandbox enabled. To use,
4340 # you can add this to your nixpkgs config:
4441 #