tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
new darwin stdenv
Eric Seidel
11 years ago
92188d9d
6f7632a7
+198
-53
3 changed files
expand all
collapse all
unified
split
pkgs
stdenv
darwin
default.nix
trivialBootstrap.sh
default.nix
+130
-32
pkgs/stdenv/darwin/default.nix
···
1
1
-
{ stdenv, pkgs, config
2
2
-
, haveLibCxx ? true
3
3
-
, useClang33 ? true }:
1
1
+
{ system ? builtins.currentSystem
2
2
+
, allPackages ? import ../../top-level/all-packages.nix
3
3
+
, platform ? null
4
4
+
, config ? {}
5
5
+
}:
6
6
+
7
7
+
rec {
8
8
+
allPackages = import ../../top-level/all-packages.nix;
4
9
5
5
-
import ../generic rec {
6
6
-
inherit config;
10
10
+
bootstrapTools = derivation {
11
11
+
inherit system;
7
12
8
8
-
preHook =
9
9
-
''
10
10
-
export NIX_ENFORCE_PURITY=
11
11
-
export NIX_IGNORE_LD_THROUGH_GCC=1
12
12
-
export NIX_DONT_SET_RPATH=1
13
13
-
export NIX_NO_SELF_RPATH=1
14
14
-
${import ./prehook.nix}
15
15
-
'';
13
13
+
name = "trivial-bootstrap-tools";
14
14
+
builder = "/bin/sh";
15
15
+
args = [ ./trivialBootstrap.sh ];
16
16
17
17
-
initialPath = (import ../common-path.nix) {pkgs = pkgs;};
17
17
+
mkdir = "/bin/mkdir";
18
18
+
ln = "/bin/ln";
19
19
+
};
18
20
19
19
-
system = stdenv.system;
21
21
+
# The simplest stdenv possible to run fetchadc and get the Apple command-line tools
22
22
+
stage0 = rec {
23
23
+
fetchurl = import ../../build-support/fetchurl {
24
24
+
inherit stdenv;
25
25
+
curl = bootstrapTools;
26
26
+
};
20
27
21
21
-
cc = import ../../build-support/cc-wrapper {
22
22
-
nativeTools = false;
23
23
-
nativeLibc = true;
24
24
-
inherit stdenv;
25
25
-
extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx;
26
26
-
binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;};
27
27
-
cc = if useClang33 then pkgs.clang_33.cc else pkgs.clang.cc;
28
28
-
coreutils = pkgs.coreutils;
29
29
-
shell = pkgs.bash + "/bin/sh";
28
28
+
stdenv = import ../generic {
29
29
+
inherit system config;
30
30
+
name = "stdenv-darwin-boot-0";
31
31
+
shell = "/bin/bash";
32
32
+
initialPath = [ bootstrapTools ];
33
33
+
fetchurlBoot = fetchurl;
34
34
+
cc = "/no-such-path";
35
35
+
};
30
36
};
31
37
32
32
-
shell = pkgs.bash + "/bin/sh";
38
38
+
buildTools = import ../../os-specific/darwin/command-line-tools {
39
39
+
inherit (stage0) stdenv fetchurl;
40
40
+
xar = bootstrapTools;
41
41
+
gzip = bootstrapTools;
42
42
+
cpio = bootstrapTools;
43
43
+
};
33
44
34
34
-
fetchurlBoot = stdenv.fetchurlBoot;
45
45
+
preHook = ''
46
46
+
export NIX_IGNORE_LD_THROUGH_GCC=1
47
47
+
export NIX_DONT_SET_RPATH=1
48
48
+
export NIX_NO_SELF_RPATH=1
49
49
+
dontFixLibtool=1
50
50
+
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
51
51
+
xargsFlags=" "
52
52
+
export MACOSX_DEPLOYMENT_TARGET=10.7
53
53
+
export SDKROOT=
54
54
+
export SDKROOT_X=/ # FIXME: impure!
55
55
+
export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT_X/usr/include -F$SDKROOT_X/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
56
56
+
export NIX_LDFLAGS_AFTER+=" -L$SDKROOT_X/usr/lib"
57
57
+
export CMAKE_OSX_ARCHITECTURES=x86_64
58
58
+
'';
35
59
36
36
-
overrides = pkgs_: {
37
37
-
inherit cc;
38
38
-
inherit (cc) binutils;
39
39
-
inherit (pkgs)
40
40
-
gzip bzip2 xz bash coreutils diffutils findutils gawk
41
41
-
gnumake gnused gnutar gnugrep gnupatch perl libcxx libcxxabi;
60
60
+
# A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
61
61
+
stage1 = rec {
62
62
+
nativePrefix = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
63
63
+
64
64
+
stdenv = import ../generic {
65
65
+
name = "stdenv-darwin-boot-1";
66
66
+
67
67
+
inherit system config;
68
68
+
inherit (stage0.stdenv) shell initialPath fetchurlBoot;
69
69
+
70
70
+
preHook = preHook + "\n" + ''
71
71
+
export NIX_LDFLAGS_AFTER+=" -L/usr/lib"
72
72
+
export NIX_ENFORCE_PURITY=
73
73
+
export NIX_CFLAGS_COMPILE+=" -isystem ${nativePrefix}/include/c++/v1 -stdlib=libc++"
74
74
+
export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,${nativePrefix}/lib"
75
75
+
'';
76
76
+
77
77
+
cc = import ../../build-support/cc-wrapper {
78
78
+
nativeTools = true;
79
79
+
nativePrefix = nativePrefix;
80
80
+
nativeLibc = true;
81
81
+
stdenv = stage0.stdenv;
82
82
+
shell = "/bin/bash";
83
83
+
cc = {
84
84
+
name = "clang-9.9.9";
85
85
+
cc = "/usr";
86
86
+
outPath = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
87
87
+
};
88
88
+
};
89
89
+
};
90
90
+
pkgs = allPackages {
91
91
+
inherit system platform;
92
92
+
bootStdenv = stdenv;
93
93
+
};
94
94
+
};
95
95
+
96
96
+
stage2 = rec {
97
97
+
stdenv = import ../generic {
98
98
+
name = "stdenv-darwin-boot-2";
99
99
+
100
100
+
inherit system config;
101
101
+
inherit (stage1.stdenv) shell fetchurlBoot preHook cc;
102
102
+
103
103
+
initialPath = [ stage1.pkgs.xz ] ++ stage1.stdenv.initialPath;
104
104
+
};
105
105
+
pkgs = allPackages {
106
106
+
inherit system platform;
107
107
+
bootStdenv = stdenv;
108
108
+
};
42
109
};
110
110
+
111
111
+
# Use stage1 to build a whole set of actual tools so we don't have to rely on the Apple prebuilt ones or
112
112
+
# the ugly symlinked bootstrap tools anymore.
113
113
+
stage3 = with stage2; import ../generic {
114
114
+
name = "stdenv-darwin-boot-3";
115
115
+
116
116
+
inherit system config;
117
117
+
inherit (stdenv) fetchurlBoot;
118
118
+
119
119
+
initialPath = (import ../common-path.nix) { inherit pkgs; };
120
120
+
121
121
+
preHook = preHook + "\n" + ''
122
122
+
export NIX_ENFORCE_PURITY=1
123
123
+
'';
124
124
+
125
125
+
cc = import ../../build-support/cc-wrapper {
126
126
+
inherit stdenv;
127
127
+
nativeTools = false;
128
128
+
nativeLibc = true;
129
129
+
binutils = pkgs.darwin.cctools_native;
130
130
+
cc = pkgs.llvmPackages.clang;
131
131
+
coreutils = pkgs.coreutils;
132
132
+
shell = "${pkgs.bash}/bin/bash";
133
133
+
};
134
134
+
135
135
+
extraBuildInputs = [ pkgs.libcxx ];
136
136
+
137
137
+
shell = "${pkgs.bash}/bin/bash";
138
138
+
};
139
139
+
140
140
+
stdenvDarwin = stage3;
43
141
}
+66
pkgs/stdenv/darwin/trivialBootstrap.sh
···
1
1
+
2
2
+
# Building bootstrap tools
3
3
+
echo Building the trivial bootstrap environment...
4
4
+
$mkdir -p $out/bin
5
5
+
6
6
+
$ln -s $ln $out/bin/ln
7
7
+
8
8
+
PATH=$out/bin/
9
9
+
10
10
+
cd $out/bin
11
11
+
12
12
+
ln -s $mkdir
13
13
+
ln -s /bin/sh
14
14
+
ln -s /bin/cp
15
15
+
ln -s /bin/mv
16
16
+
ln -s /bin/rm
17
17
+
ln -s /bin/ls
18
18
+
ln -s /bin/ps
19
19
+
ln -s /bin/cat
20
20
+
ln -s /bin/bash
21
21
+
ln -s /bin/echo
22
22
+
ln -s /bin/expr
23
23
+
ln -s /bin/test
24
24
+
ln -s /bin/date
25
25
+
ln -s /bin/chmod
26
26
+
ln -s /bin/rmdir
27
27
+
ln -s /bin/sleep
28
28
+
ln -s /bin/hostname
29
29
+
30
30
+
ln -s /usr/bin/id
31
31
+
ln -s /usr/bin/od
32
32
+
ln -s /usr/bin/tr
33
33
+
ln -s /usr/bin/wc
34
34
+
ln -s /usr/bin/cut
35
35
+
ln -s /usr/bin/cmp
36
36
+
ln -s /usr/bin/sed
37
37
+
ln -s /usr/bin/tar
38
38
+
ln -s /usr/bin/xar
39
39
+
ln -s /usr/bin/awk
40
40
+
ln -s /usr/bin/env
41
41
+
ln -s /usr/bin/tee
42
42
+
ln -s /usr/bin/comm
43
43
+
ln -s /usr/bin/cpio
44
44
+
ln -s /usr/bin/curl
45
45
+
ln -s /usr/bin/find
46
46
+
ln -s /usr/bin/grep
47
47
+
ln -s /usr/bin/gzip
48
48
+
ln -s /usr/bin/head
49
49
+
ln -s /usr/bin/tail
50
50
+
ln -s /usr/bin/sort
51
51
+
ln -s /usr/bin/uniq
52
52
+
ln -s /usr/bin/less
53
53
+
ln -s /usr/bin/true
54
54
+
ln -s /usr/bin/diff
55
55
+
ln -s /usr/bin/egrep
56
56
+
ln -s /usr/bin/fgrep
57
57
+
ln -s /usr/bin/patch
58
58
+
ln -s /usr/bin/uname
59
59
+
ln -s /usr/bin/touch
60
60
+
ln -s /usr/bin/split
61
61
+
ln -s /usr/bin/xargs
62
62
+
ln -s /usr/bin/which
63
63
+
ln -s /usr/bin/install
64
64
+
ln -s /usr/bin/basename
65
65
+
ln -s /usr/bin/dirname
66
66
+
ln -s /usr/bin/readlink
+2
-21
pkgs/stdenv/default.nix
···
33
33
pkgs = stdenvNativePkgs;
34
34
};
35
35
36
36
-
stdenvDarwin = import ./darwin {
37
37
-
inherit config;
38
38
-
stdenv = stdenvNative;
39
39
-
pkgs = stdenvNativePkgs;
40
40
-
};
41
41
-
42
42
-
stdenvDarwinNaked = import ./darwin {
43
43
-
inherit config;
44
44
-
stdenv = stdenvNative;
45
45
-
pkgs = stdenvNativePkgs;
46
46
-
haveLibCxx = false;
47
47
-
};
48
48
-
49
49
-
stdenvDarwin33 = import ./darwin {
50
50
-
inherit config;
51
51
-
stdenv = stdenvNative;
52
52
-
pkgs = stdenvNativePkgs;
53
53
-
useClang33 = true;
54
54
-
};
55
55
-
56
56
-
57
36
# Linux standard environment.
58
37
stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
59
38
39
39
+
# Darwin standard environment.
40
40
+
stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
60
41
61
42
# Select the appropriate stdenv for the platform `system'.
62
43
stdenv =