@@ -3,7 +3,7 @@
33# haskell.nix ships its own version of the ghc expression as it needs more
44# control over the expression to isolate it against varying <nixpkgs> and
55# allow us to customize it to the way haskell.nix works.
6−{ stdenv, haskell-nix, targetPackages
6+{ stdenv, lib, haskell-nix, targetPackages
77
88# build-tools
99, bootPkgs
@@ -26,7 +26,7 @@
2626
2727, # If enabled, GHC will be built with the GPL-free but slower integer-simple
2828 # 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
3030
3131, # If enabled, use -fPIC when compiling static libs.
3232 enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform && !stdenv.targetPlatform.isAarch32
@@ -42,7 +42,7 @@
4242
4343, # What flavour to build. An empty string indicates no
4444 # 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 (
4646 if useLLVM
4747 then "perf-cross"
4848 else "perf-cross-ncg"
@@ -82,7 +82,7 @@ let
8282 targetGmp = targetPackages.gmp or gmp;
8383
8484 # TODO(@Ericson2314) Make unconditional
85− targetPrefix = stdenv.lib.optionalString
85+ targetPrefix = lib.optionalString
8686 (targetPlatform != hostPlatform)
8787 "${targetPlatform.config}-";
8888
@@ -93,52 +93,52 @@ let
9393 endif
9494 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
9595 INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
96− '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
96+ '' + lib.optionalString (targetPlatform != hostPlatform) ''
9797 CrossCompilePrefix = ${targetPrefix}
98− '' + stdenv.lib.optionalString isCrossTarget ''
98+ '' + lib.optionalString isCrossTarget ''
9999 Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
100100 HADDOCK_DOCS = NO
101101 BUILD_SPHINX_HTML = NO
102102 BUILD_SPHINX_PDF = NO
103− '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
103+ '' + lib.optionalString enableRelocatedStaticLibs ''
104104 GhcLibHcOpts += -fPIC
105105 GhcRtsHcOpts += -fPIC
106− '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
106+ '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
107107 EXTRA_CC_OPTS += -std=gnu99
108− '' + stdenv.lib.optionalString (!enableTerminfo) ''
108+ '' + lib.optionalString (!enableTerminfo) ''
109109 WITH_TERMINFO=NO
110110 ''
111111 # musl doesn't have a system-linker. Only on x86, and on x86 we need it, as
112112 # our elf linker for x86_64 is broken.
113− + stdenv.lib.optionalString (targetPlatform.isMusl && !targetPlatform.isx86) ''
113+ + lib.optionalString (targetPlatform.isMusl && !targetPlatform.isx86) ''
114114 compiler_CONFIGURE_OPTS += --flags=-dynamic-system-linker
115115 ''
116116 # While split sections are now enabled by default in ghc 8.8 for windows,
117117 # the seem to lead to `too many sections` errors when building base for
118118 # profiling.
119− + stdenv.lib.optionalString targetPlatform.isWindows ''
119+ + lib.optionalString targetPlatform.isWindows ''
120120 SplitSections = NO
121− '' + stdenv.lib.optionalString (!enableLibraryProfiling) ''
121+ '' + lib.optionalString (!enableLibraryProfiling) ''
122122 BUILD_PROF_LIBS = NO
123123 '';
124124
125125 # Splicer will pull out correct variations
126− libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
126+ libDeps = platform: lib.optional enableTerminfo [ ncurses ]
127127 ++ [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;
131131
132132 toolsForTarget =
133133 if hostPlatform == buildPlatform then
134− [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm
134+ [ targetPackages.stdenv.cc ] ++ lib.optional useLLVM llvmPackages.llvm
135135 else assert targetPlatform == hostPlatform; # build != host == target
136− [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
136+ [ stdenv.cc ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
137137
138138 targetCC = builtins.head toolsForTarget;
139139
140140 configured-src = import ./configured-src.nix {
141− inherit stdenv fetchurl
141+ inherit stdenv lib fetchurl
142142 ghc-version ghc-version-date ghc-patches src-spec
143143 targetPrefix
144144 targetPlatform hostPlatform
@@ -212,7 +212,7 @@ stdenv.mkDerivation (rec {
212212 nativeBuildInputs = [
213213 perl autoconf automake m4 python3 sphinx
214214 ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
215− ] ++ stdenv.lib.optional (patches != []) autoreconfHook;
215+ ] ++ lib.optional (patches != []) autoreconfHook;
216216
217217 # For building runtime libs
218218 depsBuildTarget = toolsForTarget;
@@ -220,14 +220,14 @@ stdenv.mkDerivation (rec {
220220 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
221221
222222 propagatedBuildInputs = [ targetPackages.stdenv.cc ]
223− ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
223+ ++ lib.optional useLLVM llvmPackages.llvm;
224224
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);
227227
228228 # required, because otherwise all symbols from HSffi.o are stripped, and
229229 # 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";
231231
232232 # See #63511 - the only unstripped file is the debug rts which isn't meant to
233233 # be stripped.
@@ -236,8 +236,8 @@ stdenv.mkDerivation (rec {
236236 checkTarget = "test";
237237
238238 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";
241241
242242 postInstall = ''
243243 # Install the bash completion file.
@@ -250,7 +250,7 @@ stdenv.mkDerivation (rec {
250250 # The ghcprog fixup is for musl (where runhaskell script just needs to point to the correct
251251 # ghc program to work).
252252 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 ]}"' \
254254 -e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \
255255 $i
256256 done
@@ -324,7 +324,7 @@ stdenv.mkDerivation (rec {
324324 inherit (ghc.meta) license platforms;
325325 };
326326
327−} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
327+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
328328 dontStrip = true;
329329 dontPatchELF = true;
330330 noAuditTmpdir = true;