···1{ lib, stdenv
2, fetchurl, perl, gcc
3-, ncurses6, gmp, glibc, libiconv, numactl
04, llvmPackages
56 # minimal = true; will remove files that aren't strictly necessary for
···14assert stdenv.targetPlatform == stdenv.hostPlatform;
1516let
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017 useLLVM = !stdenv.targetPlatform.isx86;
1819- libPath = lib.makeLibraryPath ([
20- ncurses6 gmp
21- ] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv
22- ++ lib.optional (stdenv.hostPlatform.isAarch64) numactl);
00002324 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
25 + "LD_LIBRARY_PATH";
2627- glibcDynLinker = assert stdenv.isLinux;
28- if stdenv.hostPlatform.libc == "glibc" then
29- # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
30- ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
31- else
32- "${lib.getLib glibc}/lib/ld-linux*";
33-34- downloadsUrl = "https://downloads.haskell.org/ghc";
35-36in
3738stdenv.mkDerivation rec {
39- version = "8.10.2";
4041 name = "ghc-${version}-binary";
4243- # https://downloads.haskell.org/~ghc/8.10.2/
44- src = fetchurl ({
45- i686-linux = {
46- url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
47- sha256 = "0bvwisl4w0z5z8z0da10m9sv0mhm9na2qm43qxr8zl23mn32mblx";
48- };
49- x86_64-linux = {
50- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
51- sha256 = "0chnzy9j23b2wa8clx5arwz8wnjfxyjmz9qkj548z14cqf13slcl";
52- };
53- armv7l-linux = {
54- url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
55- sha256 = "1j41cq5d3rmlgz7hzw8f908fs79gc5mn3q5wz277lk8zdf19g75v";
56- };
57- aarch64-linux = {
58- url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
59- sha256 = "14smwl3741ixnbgi0l51a7kh7xjkiannfqx15b72svky0y4l3wjw";
60- };
61- x86_64-darwin = {
62- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
63- sha256 = "1hngyq14l4f950hzhh2d204ca2gfc98pc9xdasxihzqd1jq75dzd";
64- };
65- }.${stdenv.hostPlatform.system}
66- or (throw "cannot bootstrap GHC on this platform"));
6768 nativeBuildInputs = [ perl ];
69- propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ];
0000000000000700071 # Cannot patchelf beforehand due to relative RPATHs that anticipate
72- # the final install location/
73 ${libEnvVar} = libPath;
7475 postUnpack =
000000000000000000000000000000000076 # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
77 # during linking
78- lib.optionalString stdenv.isDarwin ''
79 export NIX_LDFLAGS+=" -no_dtrace_dof"
80 # not enough room in the object files for the full path to libiconv :(
81 for exe in $(find . -type f -executable); do
···91 patchShebangs ghc-${version}/configure
92 '' +
93 # We have to patch the GMP paths for the integer-gmp package.
00094 ''
95 find . -name integer-gmp.buildinfo \
96 -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
···106 '' +
107 # Rename needed libraries and binaries, fix interpreter
108 lib.optionalString stdenv.isLinux ''
109- find . -type f -perm -0100 -exec patchelf \
110- --replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.6 libncurses.so \
111- --interpreter ${glibcDynLinker} {} \;
112-113- sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
114- sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
115- '' +
116- # We're kludging a glibc bindist into working with non-glibc...
117- # Here we patch up the use of `__strdup` (part of glibc binary ABI)
118- # to instead use `strdup` since musl doesn't provide __strdup
119- # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
120- # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
121- # Use objcopy magic to make the change:
122- lib.optionalString stdenv.hostPlatform.isMusl ''
123- find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
124 '';
125126 # fix for `configure: error: Your linker is affected by binutils #16177`
···130131 configurePlatforms = [ ];
132 configureFlags = [
133- "--with-gmp-libraries=${lib.getLib gmp}/lib"
134 "--with-gmp-includes=${lib.getDev gmp}/include"
00135 ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
0136 ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
137138 # No building is necessary, but calling make without flags ironically
139 # calls install-strip ...
140 dontBuild = true;
1410000000000000000142 # On Linux, use patchelf to modify the executables so that they can
143 # find editline/gmp.
144 postFixup = lib.optionalString stdenv.isLinux
···186 find $out -type f -name '*.p_o' -delete
187 find $out -type f -name '*.p_hi' -delete
188 find $out -type f -name '*_p.a' -delete
189- rm $out/lib/ghc-*/bin/ghc-iserv-prof
0190 # Hydra will redistribute this derivation, so we have to keep the docs for
191 # legal reasons (retaining the legal notices etc)
192 # As a last resort we could unpack the docs separately and symlink them in.
193 # They're in $out/share/{doc,man}.
194 '';
195000000000196 doInstallCheck = true;
197 installCheckPhase = ''
198 unset ${libEnvVar}
···221 homepage = "http://haskell.org/ghc";
222 description = "The Glasgow Haskell Compiler";
223 license = lib.licenses.bsd3;
224- platforms = ["x86_64-linux" "armv7l-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
000000000225 hydraPlatforms = builtins.filter (p: minimal || p != "aarch64-linux") platforms;
226 maintainers = with lib.maintainers; [ lostnet ];
227 };
···1{ lib, stdenv
2, fetchurl, perl, gcc
3+, ncurses5
4+, ncurses6, gmp, libiconv, numactl
5, llvmPackages
67 # minimal = true; will remove files that aren't strictly necessary for
···15assert stdenv.targetPlatform == stdenv.hostPlatform;
1617let
18+ downloadsUrl = "https://downloads.haskell.org/ghc";
19+20+ version = "8.10.2";
21+22+ # Information about available bindists that we use in the build.
23+ #
24+ # # Bindist library checking
25+ #
26+ # The field `archSpecificLibraries` also provides a way for us get notified
27+ # early when the upstream bindist changes its dependencies (e.g. because a
28+ # newer Debian version is used that uses a new `ncurses` version).
29+ #
30+ # Usage:
31+ #
32+ # * You can find the `fileToCheckFor` of libraries by running `readelf -d`
33+ # on the compiler binary (`exePathForLibraryCheck`).
34+ # * To skip library checking for an architecture,
35+ # set `exePathForLibraryCheck = null`.
36+ # * To skip file checking for a specific arch specfic library,
37+ # set `fileToCheckFor = null`.
38+ ghcBinDists = {
39+ # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
40+ # nixpkgs uses for the respective system.
41+ defaultLibc = {
42+ i686-linux = {
43+ src = {
44+ url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
45+ sha256 = "0bvwisl4w0z5z8z0da10m9sv0mhm9na2qm43qxr8zl23mn32mblx";
46+ };
47+ exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
48+ archSpecificLibraries = [
49+ # The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
50+ # which link it against `libtinfo.so.5` (ncurses 5).
51+ # Other bindists are linked `libtinfo.so.6` (ncurses 6).
52+ { nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
53+ ];
54+ };
55+ x86_64-linux = {
56+ src = {
57+ url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
58+ sha256 = "0chnzy9j23b2wa8clx5arwz8wnjfxyjmz9qkj548z14cqf13slcl";
59+ };
60+ exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
61+ archSpecificLibraries = [
62+ { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
63+ ];
64+ };
65+ armv7l-linux = {
66+ src = {
67+ url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
68+ sha256 = "1j41cq5d3rmlgz7hzw8f908fs79gc5mn3q5wz277lk8zdf19g75v";
69+ };
70+ exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
71+ archSpecificLibraries = [
72+ { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
73+ ];
74+ };
75+ aarch64-linux = {
76+ src = {
77+ url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
78+ sha256 = "14smwl3741ixnbgi0l51a7kh7xjkiannfqx15b72svky0y4l3wjw";
79+ };
80+ exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
81+ archSpecificLibraries = [
82+ { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
83+ { nixPackage = numactl; fileToCheckFor = null; }
84+ ];
85+ };
86+ x86_64-darwin = {
87+ src = {
88+ url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
89+ sha256 = "1hngyq14l4f950hzhh2d204ca2gfc98pc9xdasxihzqd1jq75dzd";
90+ };
91+ exePathForLibraryCheck = null; # we don't have a library check for darwin yet
92+ archSpecificLibraries = [
93+ { nixPackage = ncurses6; fileToCheckFor = null; }
94+ { nixPackage = libiconv; fileToCheckFor = null; }
95+ ];
96+ };
97+ };
98+ # Binary distributions for the musl libc for the respective system.
99+ musl = {
100+ x86_64-linux = {
101+ src = {
102+ url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
103+ sha256 = "0xpcbyaxqyhbl6f0i3s4rp2jm67nqpkfh2qlbj3i2fiaix89ml0l";
104+ };
105+ exePathForLibraryCheck = "bin/ghc";
106+ archSpecificLibraries = [
107+ # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
108+ # instead of `libtinfo.so.*.`
109+ { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
110+ ];
111+ };
112+ };
113+ };
114+115+ distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
116+117+ binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
118+ or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
119+120 useLLVM = !stdenv.targetPlatform.isx86;
121122+ libPath =
123+ lib.makeLibraryPath (
124+ [
125+ gmp
126+ ]
127+ # Add arch-specific libraries.
128+ ++ map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
129+ );
130131 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
132 + "LD_LIBRARY_PATH";
133000000000134in
135136stdenv.mkDerivation rec {
137+ inherit version;
138139 name = "ghc-${version}-binary";
140141+ src = fetchurl binDistUsed.src;
00000000000000000000000142143 nativeBuildInputs = [ perl ];
144+ propagatedBuildInputs =
145+ lib.optionals useLLVM [ llvmPackages.llvm ]
146+ # Because musl bindists currently provide no way to tell where
147+ # libgmp is (see not [musl bindists have no .buildinfo]), we need
148+ # to propagate `gmp`, otherwise programs built by this ghc will
149+ # fail linking with `cannot find -lgmp` errors.
150+ # Also, as of writing, the release pages of musl bindists claim
151+ # that they use `integer-simple` and do not require `gmp`; however
152+ # that is incorrect, so `gmp` is required until a release has been
153+ # made that includes https://gitlab.haskell.org/ghc/ghc/-/issues/20059.
154+ # (Note that for packaging the `-binary` compiler, nixpkgs does not care
155+ # about whether or not `gmp` is used; this comment is just here to explain
156+ # why the `gmp` dependency exists despite what the release page says.)
157+ ++ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this
158159+ # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
160+ # of the bindist installer can find the libraries they expect.
161 # Cannot patchelf beforehand due to relative RPATHs that anticipate
162+ # the final install location.
163 ${libEnvVar} = libPath;
164165 postUnpack =
166+ # Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
167+ # so that we know when ghc bindists upgrade that and we need to update the
168+ # version used in `libPath`.
169+ lib.optionalString
170+ (binDistUsed.exePathForLibraryCheck != null)
171+ # Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
172+ # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
173+ # As a result, don't shell-quote this glob when splicing the string.
174+ (let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
175+ lib.concatStringsSep "\n" [
176+ (''
177+ echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
178+ if ! test -e ${buildExeGlob}; then
179+ echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
180+ fi
181+ '')
182+ (lib.concatMapStringsSep
183+ "\n"
184+ ({ fileToCheckFor, nixPackage }:
185+ lib.optionalString (fileToCheckFor != null) ''
186+ echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
187+ if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
188+ echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
189+ fi
190+191+ echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
192+ if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
193+ echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
194+ fi
195+ ''
196+ )
197+ binDistUsed.archSpecificLibraries
198+ )
199+ ])
200 # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
201 # during linking
202+ + lib.optionalString stdenv.isDarwin ''
203 export NIX_LDFLAGS+=" -no_dtrace_dof"
204 # not enough room in the object files for the full path to libiconv :(
205 for exe in $(find . -type f -executable); do
···215 patchShebangs ghc-${version}/configure
216 '' +
217 # We have to patch the GMP paths for the integer-gmp package.
218+ # Note [musl bindists have no .buildinfo]
219+ # Note that musl bindists do not contain them; unclear if that's intended;
220+ # see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
221 ''
222 find . -name integer-gmp.buildinfo \
223 -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
···233 '' +
234 # Rename needed libraries and binaries, fix interpreter
235 lib.optionalString stdenv.isLinux ''
236+ find . -type f -executable -exec patchelf \
237+ --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
0000000000000238 '';
239240 # fix for `configure: error: Your linker is affected by binutils #16177`
···244245 configurePlatforms = [ ];
246 configureFlags = [
0247 "--with-gmp-includes=${lib.getDev gmp}/include"
248+ # Note `--with-gmp-libraries` does nothing for GHC bindists:
249+ # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
250 ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
251+ # From: https://github.com/NixOS/nixpkgs/pull/43369/commits
252 ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
253254 # No building is necessary, but calling make without flags ironically
255 # calls install-strip ...
256 dontBuild = true;
257258+ # Apparently necessary for the ghc Alpine (musl) bindist:
259+ # When we strip, and then run the
260+ # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
261+ # below, running ghc (e.g. during `installCheckPhase)` gives some apparently
262+ # corrupted rpath or whatever makes the loader work on nonsensical strings:
263+ # running install tests
264+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
265+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
266+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
267+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
268+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found
269+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found
270+ # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
271+ # This is extremely bogus and should be investigated.
272+ dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
273+274 # On Linux, use patchelf to modify the executables so that they can
275 # find editline/gmp.
276 postFixup = lib.optionalString stdenv.isLinux
···318 find $out -type f -name '*.p_o' -delete
319 find $out -type f -name '*.p_hi' -delete
320 find $out -type f -name '*_p.a' -delete
321+ # `-f` because e.g. musl bindist does not have this file.
322+ rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
323 # Hydra will redistribute this derivation, so we have to keep the docs for
324 # legal reasons (retaining the legal notices etc)
325 # As a last resort we could unpack the docs separately and symlink them in.
326 # They're in $out/share/{doc,man}.
327 '';
328329+ # In nixpkgs, musl based builds currently enable `pie` hardening by default
330+ # (see `defaultHardeningFlags` in `make-derivation.nix`).
331+ # But GHC cannot currently produce outputs that are ready for `-pie` linking.
332+ # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
333+ # See:
334+ # * https://github.com/NixOS/nixpkgs/issues/129247
335+ # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
336+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
337+338 doInstallCheck = true;
339 installCheckPhase = ''
340 unset ${libEnvVar}
···363 homepage = "http://haskell.org/ghc";
364 description = "The Glasgow Haskell Compiler";
365 license = lib.licenses.bsd3;
366+ # HACK: since we can't encode the libc / abi in platforms, we need
367+ # to make the platform list dependent on the evaluation platform
368+ # in order to avoid eval errors with musl which supports less
369+ # platforms than the default libcs (i. e. glibc / libSystem).
370+ # This is done for the benefit of Hydra, so `packagePlatforms`
371+ # won't return any platforms that would cause an evaluation
372+ # failure for `pkgsMusl.haskell.compiler.ghc8102Binary`, as
373+ # long as the evaluator runs on a platform that supports
374+ # `pkgsMusl`.
375+ platforms = builtins.attrNames ghcBinDists.${distSetName};
376 hydraPlatforms = builtins.filter (p: minimal || p != "aarch64-linux") platforms;
377 maintainers = with lib.maintainers; [ lostnet ];
378 };
···121122 configurePlatforms = [ ];
123 configureFlags = [
0124 "--with-gmp-includes=${lib.getDev gmp}/include"
125+ # Note `--with-gmp-libraries` does nothing for GHC bindists:
126+ # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
127 ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
128 ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
129···153 done
154 '';
155156+ # In nixpkgs, musl based builds currently enable `pie` hardening by default
157+ # (see `defaultHardeningFlags` in `make-derivation.nix`).
158+ # But GHC cannot currently produce outputs that are ready for `-pie` linking.
159+ # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
160+ # See:
161+ # * https://github.com/NixOS/nixpkgs/issues/129247
162+ # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
163+ hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
164+165 doInstallCheck = true;
166 installCheckPhase = ''
167 unset ${libEnvVar}
···190 license = lib.licenses.bsd3;
191 platforms = ["x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
192 hydraPlatforms = builtins.filter (p: p != "aarch64-linux") platforms;
193+ # build segfaults, use ghc8102Binary which has proper musl support instead
194+ broken = stdenv.hostPlatform.isMusl;
195 };
196}
+53-9
pkgs/development/compilers/ghc/8.8.4.nix
···38 ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
39 (if useLLVM then "perf-cross" else "perf-cross-ncg")
400000000000000041, # Whether to disable the large address space allocator
42 # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
43 disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
···4546assert !enableIntegerSimple -> gmp != null;
47000048let
49 inherit (stdenv) buildPlatform hostPlatform targetPlatform;
50···60 ifneq \"\$(BuildFlavour)\" \"\"
61 include mk/flavours/\$(BuildFlavour).mk
62 endif
00000000000000063 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
64 INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
65 ''
···72 + lib.optionalString (targetPlatform != hostPlatform) ''
73 Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
74 CrossCompilePrefix = ${targetPrefix}
75- HADDOCK_DOCS = NO
76- BUILD_SPHINX_HTML = NO
77- BUILD_SPHINX_PDF = NO
78 '' + lib.optionalString dontStrip ''
79 STRIP_CMD = :
80 '' + lib.optionalString (!enableProfiledLibs) ''
···142 postPatch = "patchShebangs .";
143144 # GHC is a bit confused on its cross terminology.
145- preConfigure = lib.optionalString stdenv.isAarch64 ''
146 # Aarch64 allow backward bootstrapping since earlier versions are unstable.
147- find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
148- -exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
149- '' + ''
000150 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
151 export "''${env#TARGET_}=''${!env}"
152 done
···224 dontAddExtraLibs = true;
225226 nativeBuildInputs = [
227- perl autoconf automake m4 python3 sphinx
228 ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
00229 ];
230231 # For building runtime libs
···245246 checkTarget = "test";
247248- hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie";
000000000249250 postInstall = ''
251 # Install the bash completion file.
···38 ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
39 (if useLLVM then "perf-cross" else "perf-cross-ncg")
4041+, # Whether to build sphinx documentation.
42+ enableDocs ? (
43+ # Docs disabled for musl and cross because it's a large task to keep
44+ # all `sphinx` dependencies building in those environments.
45+ # `sphinx` pullls in among others:
46+ # Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
47+ (stdenv.targetPlatform == stdenv.hostPlatform)
48+ && !stdenv.hostPlatform.isMusl
49+ )
50+51+, enableHaddockProgram ?
52+ # Disabled for cross; see note [HADDOCK_DOCS].
53+ (stdenv.targetPlatform == stdenv.hostPlatform)
54+55, # Whether to disable the large address space allocator
56 # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
57 disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
···5960assert !enableIntegerSimple -> gmp != null;
6162+# Cross cannot currently build the `haddock` program for silly reasons,
63+# see note [HADDOCK_DOCS].
64+assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
65+66let
67 inherit (stdenv) buildPlatform hostPlatform targetPlatform;
68···78 ifneq \"\$(BuildFlavour)\" \"\"
79 include mk/flavours/\$(BuildFlavour).mk
80 endif
81+ BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
82+ BUILD_SPHINX_PDF = NO
83+ '' +
84+ # Note [HADDOCK_DOCS]:
85+ # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
86+ # program is built (which we generally always want to have a complete GHC install)
87+ # and whether it is run on the GHC sources to generate hyperlinked source code
88+ # (which is impossible for cross-compilation); see:
89+ # https://gitlab.haskell.org/ghc/ghc/-/issues/20077
90+ # This implies that currently a cross-compiled GHC will never have a `haddock`
91+ # program, so it can never generate haddocks for any packages.
92+ # If this is solved in the future, we'd like to unconditionally
93+ # build the haddock program (removing the `enableHaddockProgram` option).
94+ ''
95+ HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
96 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
97 INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
98 ''
···105 + lib.optionalString (targetPlatform != hostPlatform) ''
106 Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
107 CrossCompilePrefix = ${targetPrefix}
000108 '' + lib.optionalString dontStrip ''
109 STRIP_CMD = :
110 '' + lib.optionalString (!enableProfiledLibs) ''
···172 postPatch = "patchShebangs .";
173174 # GHC is a bit confused on its cross terminology.
175+ preConfigure =
176 # Aarch64 allow backward bootstrapping since earlier versions are unstable.
177+ # Same for musl, as earlier versions do not provide a musl bindist for bootstrapping.
178+ lib.optionalString (stdenv.isAarch64 || stdenv.hostPlatform.isMusl) ''
179+ find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
180+ -exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
181+ ''
182+ + ''
183 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
184 export "''${env#TARGET_}=''${!env}"
185 done
···257 dontAddExtraLibs = true;
258259 nativeBuildInputs = [
260+ perl autoconf automake m4 python3
261 ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
262+ ] ++ lib.optionals enableDocs [
263+ sphinx
264 ];
265266 # For building runtime libs
···280281 checkTarget = "test";
282283+ hardeningDisable =
284+ [ "format" ]
285+ # In nixpkgs, musl based builds currently enable `pie` hardening by default
286+ # (see `defaultHardeningFlags` in `make-derivation.nix`).
287+ # But GHC cannot currently produce outputs that are ready for `-pie` linking.
288+ # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
289+ # See:
290+ # * https://github.com/NixOS/nixpkgs/issues/129247
291+ # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
292+ ++ lib.optional stdenv.targetPlatform.isMusl "pie";
293294 postInstall = ''
295 # Install the bash completion file.
···914915 cachix = generateOptparseApplicativeCompletion "cachix" super.cachix;
916917+ # Enable extra optimisations which increase build time, but also
918+ # later compiler performance, so we should do this for user's benefit.
919+ # Flag added in Agda 2.6.2
920+ Agda = appendConfigureFlag super.Agda "-foptimise-heavily";
921+922}
···3435 patchFlags = lib.optional stdenv.hostPlatform.isDarwin "-p0";
3637+ # For currently unknown reason, `-fPIC` has to be passed explicitly, otherwise
38+ # downstream software like `elfutils` will get `recompile errors like:
39+ # libargp.a(argp-help.o): relocation R_X86_64_PC32 against symbol `program_invocation_short_name' can not be used when making a shared object; recompile with -fPIC
40+ # It seems that nixpkgs's on-by-default `-fPIC` is not in effect here.
41+ preConfigure = lib.optionalString stdenv.hostPlatform.isLinux "export CFLAGS='-fgnu89-inline -fPIC'";
4243 postInstall = ''
44 mkdir -p $out/lib $out/include
+20-20
pkgs/misc/vscode-extensions/default.nix
···205 mktplcRef = {
206 name = "vscode-tailwindcss";
207 publisher = "bradlc";
208- version = "0.6.6";
209- sha256 = "sha256-CRd+caKHFOXBnePr/LqNkzw0kRGYvNSkf4ecNgedpdA=";
210 };
211 meta = with lib; {
212 license = licenses.mpl20;
···270 mktplcRef = {
271 name = "bracket-pair-colorizer-2";
272 publisher = "CoenraadS";
273- version = "0.2.0";
274- sha256 = "0nppgfbmw0d089rka9cqs3sbd5260dhhiipmjfga3nar9vp87slh";
275 };
276 meta = with lib; {
277 license = licenses.mit;
···454 mktplcRef = {
455 name = "vscode-great-icons";
456 publisher = "emmanuelbeziat";
457- version = "2.1.64";
458- sha256 = "sha256-qsL1vWiEAYeWkMDNSrr1yzg0QxroEQQeznoDL3Ujy/o=";
459 };
460 meta = with lib; {
461 license = licenses.mit;
···474 mktplcRef = {
475 name = "prettier-vscode";
476 publisher = "esbenp";
477- version = "5.8.0";
478- sha256 = "0h7wc4pffyq1i8vpj4a5az02g2x04y7y1chilmcfmzg2w42xpby7";
479 };
480 };
481···776 mktplcRef = {
777 name = "svg";
778 publisher = "jock";
779- version = "1.4.4";
780- sha256 = "0kn2ic7pgbd4rbvzpsxfwyiwxa1iy92l0h3jsppxc8gk8xbqm2nc";
781 };
782 meta = with lib; {
783 license = licenses.mit;
···824 mktplcRef = {
825 name = "magit";
826 publisher = "kahole";
827- version = "0.6.15";
828- sha256 = "sha256-fRXm70FXnHduoywI4YC9ya6/J7wyd6EBzbnrcijBIbA=";
829 };
830 meta = {
831 license = lib.licenses.mit;
···1096 mktplcRef = {
1097 name = "crates";
1098 publisher = "serayuzgur";
1099- version = "0.5.3";
1100- sha256 = "1xk7ayv590hsm3scqpyh6962kvgdlinnpkx0vapr7vs4y08dx72f";
1101 };
1102 meta = {
1103 license = lib.licenses.mit;
···1198 mktplcRef = {
1199 name = "svelte-vscode";
1200 publisher = "svelte";
1201- version = "105.0.0";
1202- sha256 = "sha256-my3RzwUW5MnajAbEnqxtrIR701XH+AKYLbnKD7ivASE=";
1203 };
1204 meta = {
1205 license = lib.licenses.mit;
···1252 mktplcRef = {
1253 name = "shellcheck";
1254 publisher = "timonwong";
1255- version = "0.14.1";
1256- sha256 = "sha256-X3ihMxANcqNLWl9oTZjCgwRt1uBsSN2BmC2D4dPRFLE=";
1257 };
1258 nativeBuildInputs = [ jq ];
1259 postInstall = ''
···1323 mktplcRef = {
1324 name = "vim";
1325 publisher = "vscodevim";
1326- version = "1.11.3";
1327- sha256 = "1smzsgcrkhghbnpy51gp28kh74l7y4s2m8pfxabb4ffb751254j0";
1328 };
1329 meta = {
1330 license = lib.licenses.mit;
···205 mktplcRef = {
206 name = "vscode-tailwindcss";
207 publisher = "bradlc";
208+ version = "0.6.13";
209+ sha256 = "098vrm28b7jpzk0c2d0cgxvdw4jsswzf18cx1m9jwsm1j40fp5f4";
210 };
211 meta = with lib; {
212 license = licenses.mpl20;
···270 mktplcRef = {
271 name = "bracket-pair-colorizer-2";
272 publisher = "CoenraadS";
273+ version = "0.2.1";
274+ sha256 = "0bfvzs4ac537zqhnqaa38jf4lhiy1fmqcv6lq89nnx8k963380z7";
275 };
276 meta = with lib; {
277 license = licenses.mit;
···454 mktplcRef = {
455 name = "vscode-great-icons";
456 publisher = "emmanuelbeziat";
457+ version = "2.1.79";
458+ sha256 = "1cr1pxgxlfr643sfxbcr2xd53s1dnzcpacjj0ffkgizfda2psy78";
459 };
460 meta = with lib; {
461 license = licenses.mit;
···474 mktplcRef = {
475 name = "prettier-vscode";
476 publisher = "esbenp";
477+ version = "8.0.1";
478+ sha256 = "017lqpmzjxq5f1zr49akcm9gfki0qq8v7pj7gks6a3szjdx16mnl";
479 };
480 };
481···776 mktplcRef = {
777 name = "svg";
778 publisher = "jock";
779+ version = "1.4.7";
780+ sha256 = "04ghqg4s7g7yylmvbxzwzpnyy4zin2bwlgvflh18m77w4j0ckpiq";
781 };
782 meta = with lib; {
783 license = licenses.mit;
···824 mktplcRef = {
825 name = "magit";
826 publisher = "kahole";
827+ version = "0.6.18";
828+ sha256 = "0sqzz5bbqqg60aypvwxcqnxrr72gmwfj9sv0amgkyaf60zg5sf7w";
829 };
830 meta = {
831 license = lib.licenses.mit;
···1096 mktplcRef = {
1097 name = "crates";
1098 publisher = "serayuzgur";
1099+ version = "0.5.9";
1100+ sha256 = "0l26pyvw7n3bszf97yx6qps72acq112akg3q4jq5mvlibng1nwk0";
1101 };
1102 meta = {
1103 license = lib.licenses.mit;
···1198 mktplcRef = {
1199 name = "svelte-vscode";
1200 publisher = "svelte";
1201+ version = "105.3.0";
1202+ sha256 = "11plqsj3c4dv0xg2d76pxrcn382qr9wbh1lhln2x8mzv840icvwr";
1203 };
1204 meta = {
1205 license = lib.licenses.mit;
···1252 mktplcRef = {
1253 name = "shellcheck";
1254 publisher = "timonwong";
1255+ version = "0.14.4";
1256+ sha256 = "05z314sw9nqym3qlj7dcwm0fz1hb23xppzqn3nr2wcj17hs8zz4m";
1257 };
1258 nativeBuildInputs = [ jq ];
1259 postInstall = ''
···1323 mktplcRef = {
1324 name = "vim";
1325 publisher = "vscodevim";
1326+ version = "1.21.5";
1327+ sha256 = "1v1xs1wcigisr6xip31i02cfryxrb157sla34y59pwlnhc5x1gny";
1328 };
1329 meta = {
1330 license = lib.licenses.mit;
···1+# Wrap only the haskell-related tests from tests.writers
2+# in their own derivation for Hydra CI in the haskell-updates
3+# jobset. Can presumably removed as soon as tests.writers is
4+# always green on darwin as well:
5+# https://github.com/NixOS/nixpkgs/issues/126182
6+{ runCommand, tests }:
7+8+let
9+ inherit (tests.writers)
10+ writeTest
11+ bin
12+ simple
13+ path
14+ ;
15+in
16+17+runCommand "test-haskell-writers" {
18+ meta = {
19+ inherit (tests.writers.meta) platforms;
20+ };
21+} ''
22+ ${writeTest "success" "test-haskell-bin-writer" "${bin.haskell}/bin/${bin.haskell.name}"}
23+ ${writeTest "success" "test-haskell-simple-writer" simple.haskell}
24+ ${writeTest "success" "test-haskell-path-writer" path.haskell}
25+ touch $out
26+''
+4-2
pkgs/top-level/haskell-packages.nix
···5758 ghc884 = callPackage ../development/compilers/ghc/8.8.4.nix {
59 # aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar
60- bootPkgs = if stdenv.isAarch64 then
061 packages.ghc8102BinaryMinimal
62 else
63 packages.ghc865Binary;
···67 };
68 ghc8104 = callPackage ../development/compilers/ghc/8.10.4.nix {
69 # aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar
70- bootPkgs = if stdenv.isAarch64 || stdenv.isAarch32 then
071 packages.ghc8102BinaryMinimal
72 else
73 packages.ghc865Binary;
···5758 ghc884 = callPackage ../development/compilers/ghc/8.8.4.nix {
59 # aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar
60+ # Musl bindists do not exist for ghc 8.6.5, so we use 8.10.* for them
61+ bootPkgs = if stdenv.isAarch64 || stdenv.targetPlatform.isMusl then
62 packages.ghc8102BinaryMinimal
63 else
64 packages.ghc865Binary;
···68 };
69 ghc8104 = callPackage ../development/compilers/ghc/8.10.4.nix {
70 # aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar
71+ # Musl bindists do not exist for ghc 8.6.5, so we use 8.10.* for them
72+ bootPkgs = if stdenv.isAarch64 || stdenv.isAarch32 || stdenv.targetPlatform.isMusl then
73 packages.ghc8102BinaryMinimal
74 else
75 packages.ghc865Binary;
+26-10
pkgs/top-level/release-haskell.nix
···89 haskellPackages = packagePlatforms pkgs.haskellPackages;
90 haskell.compiler = packagePlatforms pkgs.haskell.compiler;
9192- tests = let
93- testPlatforms = packagePlatforms pkgs.tests;
94- in {
95- haskell = testPlatforms.haskell;
96- writers = testPlatforms.writers;
0097 };
9899 # test some statically linked packages to catch regressions
···247 };
248 constituents = accumulateDerivations [
249 # haskell specific tests
250- jobs.tests.haskell
251- # writeHaskell and writeHaskellBin
252- # TODO: writeHaskell currently fails on darwin
253- jobs.tests.writers.x86_64-linux
254- jobs.tests.writers.aarch64-linux
255 # important top-level packages
256 jobs.cabal-install
257 jobs.cabal2nix
···307 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.lens.aarch64-linux
308 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.random.x86_64-linux
309 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.random.aarch64-linux
000000000000000310 ];
311 };
312 }
···89 haskellPackages = packagePlatforms pkgs.haskellPackages;
90 haskell.compiler = packagePlatforms pkgs.haskell.compiler;
9192+ tests.haskell = packagePlatforms pkgs.tests.haskell;
93+94+ pkgsMusl.haskell.compiler = packagePlatforms pkgs.pkgsMusl.haskell.compiler // {
95+ # remove musl ghc865Binary since it is known to be broken and
96+ # causes an evaluation error on darwin.
97+ # TODO: remove ghc865Binary altogether and use ghc8102Binary
98+ ghc865Binary = {};
99 };
100101 # test some statically linked packages to catch regressions
···249 };
250 constituents = accumulateDerivations [
251 # haskell specific tests
252+ #
253+ # TODO: The writers test appears to be failing on darwin for unknown
254+ # reasons. See https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881307871.
255+ (lib.recursiveUpdate jobs.tests.haskell { writers.x86_64-darwin = null; })
0256 # important top-level packages
257 jobs.cabal-install
258 jobs.cabal2nix
···308 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.lens.aarch64-linux
309 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.random.x86_64-linux
310 jobs.pkgsStatic.haskell.packages.integer-simple.ghc8104.random.aarch64-linux
311+ ];
312+ };
313+ muslGHCs = pkgs.releaseTools.aggregate {
314+ name = "haskell-pkgsMusl-ghcs";
315+ meta = {
316+ description = "GHCs built with musl";
317+ maintainers = with lib.maintainers; [
318+ nh2
319+ ];
320+ };
321+ constituents = accumulateDerivations [
322+ jobs.pkgsMusl.haskell.compiler.ghc8102Binary
323+ jobs.pkgsMusl.haskell.compiler.ghc884
324+ jobs.pkgsMusl.haskell.compiler.ghc8104
325+ jobs.pkgsMusl.haskell.compiler.ghc901
326 ];
327 };
328 }