3
3
# haskell.nix ships its own version of the ghc expression as it needs more
4
4
# control over the expression to isolate it against varying <nixpkgs> and
5
5
# allow us to customize it to the way haskell.nix works.
6
- { stdenv , haskell-nix , targetPackages
6
+ { stdenv , lib , haskell-nix , targetPackages
7
7
8
8
# build-tools
9
9
, bootPkgs
26
26
27
27
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
28
28
# library instead of the faster but GPLed integer-gmp library.
29
- enableIntegerSimple ? ! ( stdenv . lib . any ( stdenv . lib . meta . platformMatch stdenv . hostPlatform ) gmp . meta . platforms ) , gmp
29
+ enableIntegerSimple ? ! ( lib . any ( lib . meta . platformMatch stdenv . hostPlatform ) gmp . meta . platforms ) , gmp
30
30
31
31
, # If enabled, use -fPIC when compiling static libs.
32
32
enableRelocatedStaticLibs ? stdenv . targetPlatform != stdenv . hostPlatform && ! stdenv . targetPlatform . isAarch32
42
42
43
43
, # What flavour to build. An empty string indicates no
44
44
# specific flavour and falls back to ghc default values.
45
- ghcFlavour ? stdenv . lib . optionalString haskell-nix . haskellLib . isCrossTarget (
45
+ ghcFlavour ? lib . optionalString haskell-nix . haskellLib . isCrossTarget (
46
46
if useLLVM
47
47
then "perf-cross"
48
48
else "perf-cross-ncg"
82
82
targetGmp = targetPackages . gmp or gmp ;
83
83
84
84
# TODO(@Ericson2314) Make unconditional
85
- targetPrefix = stdenv . lib . optionalString
85
+ targetPrefix = lib . optionalString
86
86
( targetPlatform != hostPlatform )
87
87
"${ targetPlatform . config } -" ;
88
88
93
93
endif
94
94
DYNAMIC_GHC_PROGRAMS = ${ if enableShared then "YES" else "NO" }
95
95
INTEGER_LIBRARY = ${ if enableIntegerSimple then "integer-simple" else "integer-gmp" }
96
- '' + stdenv . lib . optionalString ( targetPlatform != hostPlatform ) ''
96
+ '' + lib . optionalString ( targetPlatform != hostPlatform ) ''
97
97
CrossCompilePrefix = ${ targetPrefix }
98
- '' + stdenv . lib . optionalString isCrossTarget ''
98
+ '' + lib . optionalString isCrossTarget ''
99
99
Stage1Only = ${ if targetPlatform . system == hostPlatform . system then "NO" else "YES" }
100
100
HADDOCK_DOCS = NO
101
101
BUILD_SPHINX_HTML = NO
102
102
BUILD_SPHINX_PDF = NO
103
- '' + stdenv . lib . optionalString enableRelocatedStaticLibs ''
103
+ '' + lib . optionalString enableRelocatedStaticLibs ''
104
104
GhcLibHcOpts += -fPIC
105
105
GhcRtsHcOpts += -fPIC
106
- '' + stdenv . lib . optionalString targetPlatform . useAndroidPrebuilt ''
106
+ '' + lib . optionalString targetPlatform . useAndroidPrebuilt ''
107
107
EXTRA_CC_OPTS += -std=gnu99
108
- '' + stdenv . lib . optionalString ( ! enableTerminfo ) ''
108
+ '' + lib . optionalString ( ! enableTerminfo ) ''
109
109
WITH_TERMINFO=NO
110
110
''
111
111
# musl doesn't have a system-linker. Only on x86, and on x86 we need it, as
112
112
# our elf linker for x86_64 is broken.
113
- + stdenv . lib . optionalString ( targetPlatform . isMusl && ! targetPlatform . isx86 ) ''
113
+ + lib . optionalString ( targetPlatform . isMusl && ! targetPlatform . isx86 ) ''
114
114
compiler_CONFIGURE_OPTS += --flags=-dynamic-system-linker
115
115
''
116
116
# While split sections are now enabled by default in ghc 8.8 for windows,
117
117
# the seem to lead to `too many sections` errors when building base for
118
118
# profiling.
119
- + stdenv . lib . optionalString targetPlatform . isWindows ''
119
+ + lib . optionalString targetPlatform . isWindows ''
120
120
SplitSections = NO
121
- '' + stdenv . lib . optionalString ( ! enableLibraryProfiling ) ''
121
+ '' + lib . optionalString ( ! enableLibraryProfiling ) ''
122
122
BUILD_PROF_LIBS = NO
123
123
'' ;
124
124
125
125
# Splicer will pull out correct variations
126
- libDeps = platform : stdenv . lib . optional enableTerminfo [ ncurses ]
126
+ libDeps = platform : lib . optional enableTerminfo [ ncurses ]
127
127
++ [ targetLibffi ]
128
- ++ stdenv . lib . optional ( ! enableIntegerSimple ) gmp
129
- ++ stdenv . lib . optional ( platform . libc != "glibc" && ! targetPlatform . isWindows ) libiconv
130
- ++ stdenv . lib . optional ( platform . isLinux && ! platform . isAarch32 ) numactl ;
128
+ ++ lib . optional ( ! enableIntegerSimple ) gmp
129
+ ++ lib . optional ( platform . libc != "glibc" && ! targetPlatform . isWindows ) libiconv
130
+ ++ lib . optional ( platform . isLinux && ! platform . isAarch32 ) numactl ;
131
131
132
132
toolsForTarget =
133
133
if hostPlatform == buildPlatform then
134
- [ targetPackages . stdenv . cc ] ++ stdenv . lib . optional useLLVM llvmPackages . llvm
134
+ [ targetPackages . stdenv . cc ] ++ lib . optional useLLVM llvmPackages . llvm
135
135
else assert targetPlatform == hostPlatform ; # build != host == target
136
- [ stdenv . cc ] ++ stdenv . lib . optional useLLVM buildLlvmPackages . llvm ;
136
+ [ stdenv . cc ] ++ lib . optional useLLVM buildLlvmPackages . llvm ;
137
137
138
138
targetCC = builtins . head toolsForTarget ;
139
139
140
140
configured-src = import ./configured-src.nix {
141
- inherit stdenv fetchurl
141
+ inherit stdenv lib fetchurl
142
142
ghc-version ghc-version-date ghc-patches src-spec
143
143
targetPrefix
144
144
targetPlatform hostPlatform
@@ -212,22 +212,22 @@ stdenv.mkDerivation (rec {
212
212
nativeBuildInputs = [
213
213
perl autoconf automake m4 python3 sphinx
214
214
ghc bootPkgs . alex bootPkgs . happy bootPkgs . hscolour
215
- ] ++ stdenv . lib . optional ( patches != [ ] ) autoreconfHook ;
215
+ ] ++ lib . optional ( patches != [ ] ) autoreconfHook ;
216
216
217
217
# For building runtime libs
218
218
depsBuildTarget = toolsForTarget ;
219
219
220
220
buildInputs = [ perl bash ] ++ ( libDeps hostPlatform ) ;
221
221
222
222
propagatedBuildInputs = [ targetPackages . stdenv . cc ]
223
- ++ stdenv . lib . optional useLLVM llvmPackages . llvm ;
223
+ ++ lib . optional useLLVM llvmPackages . llvm ;
224
224
225
- depsTargetTarget = map stdenv . lib . getDev ( libDeps targetPlatform ) ;
226
- depsTargetTargetPropagated = map ( stdenv . lib . getOutput "out" ) ( libDeps targetPlatform ) ;
225
+ depsTargetTarget = map lib . getDev ( libDeps targetPlatform ) ;
226
+ depsTargetTargetPropagated = map ( lib . getOutput "out" ) ( libDeps targetPlatform ) ;
227
227
228
228
# required, because otherwise all symbols from HSffi.o are stripped, and
229
229
# that in turn causes GHCi to abort
230
- stripDebugFlags = [ "-S" ] ++ stdenv . lib . optional ( ! targetPlatform . isDarwin ) "--keep-file-symbols" ;
230
+ stripDebugFlags = [ "-S" ] ++ lib . optional ( ! targetPlatform . isDarwin ) "--keep-file-symbols" ;
231
231
232
232
# See #63511 - the only unstripped file is the debug rts which isn't meant to
233
233
# be stripped.
@@ -236,8 +236,8 @@ stdenv.mkDerivation (rec {
236
236
checkTarget = "test" ;
237
237
238
238
hardeningDisable = [ "format" ]
239
- ++ stdenv . lib . optional stdenv . targetPlatform . isAarch32 "pic"
240
- ++ stdenv . lib . optional stdenv . targetPlatform . isMusl "pie" ;
239
+ ++ lib . optional stdenv . targetPlatform . isAarch32 "pic"
240
+ ++ lib . optional stdenv . targetPlatform . isMusl "pie" ;
241
241
242
242
postInstall = ''
243
243
# Install the bash completion file.
@@ -250,7 +250,7 @@ stdenv.mkDerivation (rec {
250
250
# The ghcprog fixup is for musl (where runhaskell script just needs to point to the correct
251
251
# ghc program to work).
252
252
sed -i \
253
- -e '2i export PATH="$PATH:${ stdenv . lib . makeBinPath [ targetPackages . stdenv . cc . bintools coreutils ] } "' \
253
+ -e '2i export PATH="$PATH:${ lib . makeBinPath [ targetPackages . stdenv . cc . bintools coreutils ] } "' \
254
254
-e 's/ghcprog="ghc-/ghcprog="${ targetPrefix } ghc-/' \
255
255
$i
256
256
done
@@ -324,7 +324,7 @@ stdenv.mkDerivation (rec {
324
324
inherit ( ghc . meta ) license platforms ;
325
325
} ;
326
326
327
- } // stdenv . lib . optionalAttrs targetPlatform . useAndroidPrebuilt {
327
+ } // lib . optionalAttrs targetPlatform . useAndroidPrebuilt {
328
328
dontStrip = true ;
329
329
dontPatchELF = true ;
330
330
noAuditTmpdir = true ;
0 commit comments