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