blob: 1def78bcd6a9902a4a017ffa41475a0106350991 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
{
lib,
localSystem,
config,
overlays,
}:
let
genericStdenv = import ../generic { defaultConfig = config; };
inherit (localSystem) system;
shell =
if system == "i686-freebsd" || system == "x86_64-freebsd" then
"/usr/local/bin/bash"
else
"/bin/bash";
path =
(lib.optionals (system == "i686-solaris") [ "/usr/gnu" ])
++ (lib.optionals (system == "i686-netbsd") [ "/usr/pkg" ])
++ (lib.optionals (system == "x86_64-solaris") [ "/opt/local/gnu" ])
++ [
"/"
"/usr"
"/usr/local"
];
prehookBase = ''
# Disable purity tests; it's allowed (even needed) to link to
# libraries outside the Nix store (like the C library).
export NIX_ENFORCE_PURITY=
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
'';
prehookFreeBSD = ''
${prehookBase}
alias make=gmake
alias tar=gtar
alias sed=gsed
export MAKE=gmake
shopt -s expand_aliases
'';
prehookOpenBSD = ''
${prehookBase}
alias make=gmake
alias grep=ggrep
alias mv=gmv
alias ln=gln
alias sed=gsed
alias tar=gtar
export MAKE=gmake
shopt -s expand_aliases
'';
prehookNetBSD = ''
${prehookBase}
alias make=gmake
alias sed=gsed
alias tar=gtar
export MAKE=gmake
shopt -s expand_aliases
'';
# prevent libtool from failing to find dynamic libraries
prehookCygwin = ''
${prehookBase}
shopt -s expand_aliases
export lt_cv_deplibs_check_method=pass_all
'';
extraNativeBuildInputsCygwin = [
../cygwin/all-buildinputs-as-runtimedep.sh
../cygwin/wrap-exes-to-find-dlls.sh
]
++ (
if system == "i686-cygwin" then
[
../cygwin/rebase-i686.sh
]
else if system == "x86_64-cygwin" then
[
../cygwin/rebase-x86_64.sh
]
else
[ ]
);
# A function that builds a "native" stdenv (one that uses tools in
# /usr etc.).
makeStdenv =
{
cc,
fetchurl,
extraPath ? [ ],
overrides ? (self: super: { }),
extraNativeBuildInputs ? [ ],
}:
genericStdenv {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
preHook =
if system == "i686-freebsd" then
prehookFreeBSD
else if system == "x86_64-freebsd" then
prehookFreeBSD
else if system == "i686-openbsd" then
prehookOpenBSD
else if system == "i686-netbsd" then
prehookNetBSD
else if system == "i686-cygwin" then
prehookCygwin
else if system == "x86_64-cygwin" then
prehookCygwin
else
prehookBase;
extraNativeBuildInputs =
extraNativeBuildInputs
++ (
if system == "i686-cygwin" then
extraNativeBuildInputsCygwin
else if system == "x86_64-cygwin" then
extraNativeBuildInputsCygwin
else
[ ]
);
initialPath = extraPath ++ path;
fetchurlBoot = fetchurl;
inherit
shell
cc
overrides
;
};
in
[
(
{ }:
rec {
__raw = true;
stdenv = makeStdenv {
cc = null;
fetchurl = null;
};
stdenvNoCC = stdenv;
cc =
let
nativePrefix =
{
# switch
i686-solaris = "/usr/gnu";
x86_64-solaris = "/opt/local/gcc47";
}
.${system} or "/usr";
in
import ../../build-support/cc-wrapper {
name = "cc-native";
nativeTools = true;
nativeLibc = true;
expand-response-params = "";
inherit lib nativePrefix;
runtimeShell = shell;
bintools = import ../../build-support/bintools-wrapper {
name = "bintools";
inherit lib stdenvNoCC nativePrefix;
nativeTools = true;
nativeLibc = true;
expand-response-params = "";
runtimeShell = shell;
};
inherit stdenvNoCC;
};
fetchurl = import ../../build-support/fetchurl {
inherit lib stdenvNoCC;
# Curl should be in /usr/bin or so.
curl = null;
inherit (config) hashedMirrors rewriteURL;
};
}
)
# First build a stdenv based only on tools outside the store.
(prevStage: {
inherit config overlays;
stdenv =
makeStdenv {
inherit (prevStage) cc fetchurl;
overrides = self: super: { inherit (prevStage) fetchurl; };
}
// {
inherit (prevStage) fetchurl;
};
})
# Using that, build a stdenv that adds the ‘xz’ command (which most systems
# don't have, so we mustn't rely on the native environment providing it).
(prevStage: {
inherit config overlays;
stdenv = makeStdenv {
inherit (prevStage.stdenv) cc fetchurl;
extraPath = [ prevStage.xz ];
overrides = self: super: { inherit (prevStage) fetchurl xz; };
extraNativeBuildInputs = if localSystem.isLinux then [ prevStage.patchelf ] else [ ];
};
})
]
|