Skip to content

Commit 89f50a9

Browse files
authored
Use pkgs.lib instead of stdenv.lib (#1031)
Fixes: Warning: `stdenv.lib` is deprecated and will be removed in the next release. Please use `pkgs.lib` instead. For more information see NixOS/nixpkgs#108938
1 parent 1498e70 commit 89f50a9

File tree

62 files changed

+270
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+270
-233
lines changed

build.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ in rec {
3333
# are not pure).
3434
maintainer-scripts = pkgs.dontRecurseIntoAttrs {
3535
update-hackage = import ./scripts/update-hackage.nix {
36-
inherit (pkgs) stdenv writeScript coreutils glibc git
36+
inherit (pkgs) stdenv lib writeScript coreutils glibc git
3737
openssh nix-prefetch-git gawk bash curl findutils;
3838
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
3939
nix-tools = haskell.internal-nix-tools;
4040
cabal-install = haskell.internal-cabal-install;
4141
inherit (haskell) update-index-state-hashes;
4242
};
4343
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
44-
inherit (pkgs) stdenv writeScript coreutils glibc git
44+
inherit (pkgs) stdenv lib writeScript coreutils glibc git
4545
openssh nix-prefetch-git gawk bash curl findutils;
4646
# Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version)
4747
nix-tools = haskell.internal-nix-tools;

builder/comp-builder.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ let
296296
homepage = package.homepage or "";
297297
description = package.synopsis or "";
298298
license = haskellLib.cabalToNixpkgsLicense package.license;
299-
platforms = if platforms == null then stdenv.lib.platforms.all else platforms;
299+
platforms = if platforms == null then lib.platforms.all else platforms;
300300
};
301301

302302
propagatedBuildInputs =

builder/setup-builder.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let
5656
homepage = package.homepage or "";
5757
description = package.synopsis or "";
5858
license = haskellLib.cabalToNixpkgsLicense package.license;
59-
platforms = if component.platforms == null then stdenv.lib.platforms.all else component.platforms;
59+
platforms = if component.platforms == null then lib.platforms.all else component.platforms;
6060
};
6161

6262
phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"];

compiler/bootstrap/cabal-install.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ fetchurl, hackage, stdenv, ghc, zlib, src, version }:
1+
{ fetchurl, hackage, stdenv, lib, ghc, zlib, src, version }:
22
let dependencies =
33
[ { name = "deepseq"; version = "1.4.3.0"; }
44
{ name = "binary"; version = "0.8.5.1"; }
@@ -42,7 +42,7 @@ in stdenv.mkDerivation ({
4242
};
4343

4444
meta = {
45-
platforms = stdenv.lib.platforms.all;
45+
platforms = lib.platforms.all;
4646
};
4747

4848
nativeBuildInputs = [ ghc zlib ];

compiler/ghc/configured-src.nix

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, fetchurl
1+
{ stdenv, lib, fetchurl
22
, ghc-version, ghc-version-date, ghc-patches, src-spec
33
, targetPrefix
44
, targetPlatform, hostPlatform
@@ -25,18 +25,18 @@ stdenv.mkDerivation (rec {
2525
nativeBuildInputs = [
2626
perl autoconf automake m4 python3 sphinx
2727
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
28-
] ++ stdenv.lib.optional (patches != []) autoreconfHook;
28+
] ++ lib.optional (patches != []) autoreconfHook;
2929

3030
# For building runtime libs
3131
depsBuildTarget = toolsForTarget;
3232

3333
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
3434

3535
propagatedBuildInputs = [ targetPackages.stdenv.cc ]
36-
++ stdenv.lib.optional useLLVM llvmPackages.llvm;
36+
++ lib.optional useLLVM llvmPackages.llvm;
3737

38-
depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
39-
depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
38+
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
39+
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
4040

4141
postPatch = "patchShebangs .";
4242

@@ -54,7 +54,7 @@ stdenv.mkDerivation (rec {
5454
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
5555
export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
5656
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
57-
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}"
57+
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString targetPlatform.isAarch32 ".gold"}"
5858
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
5959
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
6060
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
@@ -64,13 +64,13 @@ stdenv.mkDerivation (rec {
6464
6565
echo -n "${buildMK}" > mk/build.mk
6666
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
67-
'' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
67+
'' + lib.optionalString (!stdenv.isDarwin) ''
6868
export NIX_LDFLAGS+=" -rpath $out/lib/${targetPrefix}ghc-${version}"
69-
'' + stdenv.lib.optionalString stdenv.isDarwin ''
69+
'' + lib.optionalString stdenv.isDarwin ''
7070
export NIX_LDFLAGS+=" -no_dtrace_dof"
71-
'' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
71+
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
7272
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
73-
'' + stdenv.lib.optionalString targetPlatform.isMusl ''
73+
'' + lib.optionalString targetPlatform.isMusl ''
7474
echo "patching llvm-targets for musl targets..."
7575
echo "Cloning these existing '*-linux-gnu*' targets:"
7676
grep linux-gnu llvm-targets | sed 's/^/ /'
@@ -86,10 +86,10 @@ stdenv.mkDerivation (rec {
8686
--replace '*-android*|*-gnueabi*)' \
8787
'*-android*|*-gnueabi*|*-musleabi*)'
8888
done
89-
'' + stdenv.lib.optionalString (src-spec.version != ghc-version) ''
89+
'' + lib.optionalString (src-spec.version != ghc-version) ''
9090
substituteInPlace configure --replace 'RELEASE=YES' 'RELEASE=NO'
9191
echo '${ghc-version}' > VERSION
92-
'' + stdenv.lib.optionalString (ghc-version-date != null) ''
92+
'' + lib.optionalString (ghc-version-date != null) ''
9393
substituteInPlace configure --replace 'RELEASE=YES' 'RELEASE=NO'
9494
echo '${ghc-version-date}' > VERSION_DATE
9595
'';
@@ -99,24 +99,24 @@ stdenv.mkDerivation (rec {
9999
configureFlags = [
100100
"--datadir=$doc/share/doc/ghc"
101101
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
102-
] ++ stdenv.lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
103-
] ++ stdenv.lib.optional (!enableIntegerSimple) [
102+
] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
103+
] ++ lib.optional (!enableIntegerSimple) [
104104
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
105-
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
105+
] ++ lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
106106
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
107-
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
107+
] ++ lib.optionals (targetPlatform != hostPlatform) [
108108
"--enable-bootstrap-with-devel-snapshot"
109-
] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
109+
] ++ lib.optionals (disableLargeAddressSpace) [
110110
"--disable-large-address-space"
111-
] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [
111+
] ++ lib.optionals (targetPlatform.isAarch32) [
112112
"CFLAGS=-fuse-ld=gold"
113113
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
114114
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
115115
] ;
116116

117117
outputs = [ "out" ];
118118
phases = [ "unpackPhase" "patchPhase" ]
119-
++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
119+
++ lib.optional (ghc-patches != []) "autoreconfPhase"
120120
++ [ "configurePhase" "installPhase" ];
121121
installPhase = "cp -r . $out";
122122
})

compiler/ghc/default.nix

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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,22 +212,22 @@ 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;
219219

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;

compiler/old-ghc-nix/default.nix

Lines changed: 0 additions & 10 deletions
This file was deleted.

compiler/old-ghc-nix/old-ghc-nix.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/tutorials/cross-compilation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ executables you must add package overrides to:
9090
```nix
9191
{
9292
packages.bench.components.exes.bench.configureFlags =
93-
stdenv.lib.optionals stdenv.hostPlatform.isMusl [
93+
lib.optionals stdenv.hostPlatform.isMusl [
9494
"--disable-executable-dynamic"
9595
"--disable-shared"
9696
"--ghc-option=-optl=-pthread"

nix/sources.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
},
120120
"nixpkgs-unstable": {
121121
"branch": "nixpkgs-unstable",
122+
"builtin": false,
122123
"description": "Nix Packages collection",
123124
"homepage": "",
124125
"owner": "NixOS",
@@ -128,5 +129,18 @@
128129
"type": "tarball",
129130
"url": "https://github.com/NixOS/nixpkgs/archive/410bbd828cdc6156aecd5bc91772ad3a6b1099c7.tar.gz",
130131
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
132+
},
133+
"old-ghc-nix": {
134+
"branch": "master",
135+
"builtin": false,
136+
"description": "Old and New GHC",
137+
"homepage": null,
138+
"owner": "angerman",
139+
"repo": "old-ghc-nix",
140+
"rev": "131ce9ae27d7b7afdd1d3ce8c3a74483e60b91bb",
141+
"sha256": "0n62qr7hrqmy6h80736ji47ln759sk845g43f9cprpmcs9m4wl9i",
142+
"type": "tarball",
143+
"url": "https://github.com/angerman/old-ghc-nix/archive/131ce9ae27d7b7afdd1d3ce8c3a74483e60b91bb.tar.gz",
144+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
131145
}
132146
}

0 commit comments

Comments
 (0)