···21062106 <literal>ghc810</literal>. Those attributes point to the same
21072107 compilers and packagesets but have the advantage that e.g.
21082108 <literal>ghc92</literal> stays stable when we update from
21092109- <literal>ghc924</literal> to <literal>ghc925</literal>.
21092109+ <literal>ghc925</literal> to <literal>ghc926</literal>.
21102110 </para>
21112111 </listitem>
21122112 </itemizedlist>
···952952 </listitem>
953953 <listitem>
954954 <para>
955955+ <literal>obs-studio</literal> hase been updated to version 28.
956956+ If you have packaged custom plugins, check if they are
957957+ compatible. <literal>obs-websocket</literal> has been
958958+ integrated into <literal>obs-studio</literal>.
959959+ </para>
960960+ </listitem>
961961+ <listitem>
962962+ <para>
955963 <literal>signald</literal> has been bumped to
956964 <literal>0.23.0</literal>. For the upgrade, a migration
957965 process is necessary. It can be done by running a command like
+1-1
nixos/doc/manual/release-notes/rl-2111.section.md
···576576577577- More jdk and jre versions are now exposed via `java-packages.compiler`.
578578579579-- The sets `haskell.packages` and `haskell.compiler` now contain for every ghc version an attribute with the minor version dropped. E.g. for `ghc8107` there also now exists `ghc810`. Those attributes point to the same compilers and packagesets but have the advantage that e.g. `ghc92` stays stable when we update from `ghc924` to `ghc925`.
579579+- The sets `haskell.packages` and `haskell.compiler` now contain for every ghc version an attribute with the minor version dropped. E.g. for `ghc8107` there also now exists `ghc810`. Those attributes point to the same compilers and packagesets but have the advantage that e.g. `ghc92` stays stable when we update from `ghc925` to `ghc926`.
+2
nixos/doc/manual/release-notes/rl-2211.section.md
···288288289289- `percona-server56` has been removed. Please migrate to `mysql` or `mariadb` if possible.
290290291291+- `obs-studio` hase been updated to version 28. If you have packaged custom plugins, check if they are compatible. `obs-websocket` has been integrated into `obs-studio`.
292292+291293- `signald` has been bumped to `0.23.0`. For the upgrade, a migration process is necessary. It can be
292294 done by running a command like this before starting `signald.service`:
293295
-3
nixos/lib/testing-python.nix
···99 # Modules to add to each VM
1010, extraConfigurations ? [ ]
1111}:
1212-1313-with pkgs;
1414-1512let
1613 nixos-lib = import ./default.nix { inherit (pkgs) lib; };
1714in
···33 * where GSettings system could look for schemas, we need to point the software to a correct location somehow.
44 * For executables, we handle this using wrappers but this is not an option for libraries like e-d-s.
55 * Instead, we hardcode the schema path when creating the settings.
66+ * A schema path (ie org.gnome.evolution) can be replaced by @EVOLUTION_SCHEMA_PATH@
77+ * which is then replaced at build time by substituteAll.
88+ * The mapping is provided in a json file ./glib-schema-to-var.json
69 */
710811@initialize:python@
912@@
1313+import json
10141115cpp_constants = {}
1216···1620def resolve_cpp_constant(const_name):
1721 return cpp_constants.get(const_name, const_name)
18221919-e_s_d_schema_constants = [
2020- # The following are actually part of e-d-s, despite the name.
2121- # We rename the old ambiguos constant name in ./prepare-for-gsettings-patching.patch
2222- "\"org.gnome.Evolution.DefaultSources\"",
2323- "\"org.gnome.evolution.shell.network-config\"",
2424-]
2525-2626-g_d_s_schema_constants = [
2727-]
2323+with open("./glib-schema-to-var.json") as mapping_file:
2424+ schema_to_var = json.load(mapping_file);
28252926def get_schema_directory(schema_path):
3027 # Sometimes the schema id is referenced using C preprocessor #define constant in the same file
3128 # let’s try to resolve it first.
3232- schema_path = resolve_cpp_constant(schema_path.strip())
3333- if schema_path.startswith("\"org.gnome.evolution-data-server") or schema_path in e_s_d_schema_constants:
3434- return "\"@EDS_GSETTINGS_PATH@\""
3535- elif schema_path in g_d_s_schema_constants:
3636- return "\"@GDS_GSETTINGS_PATH@\""
3737- raise Exception(f"Unknown schema path {schema_path}")
2929+ schema_path = resolve_cpp_constant(schema_path.strip()).strip('"')
3030+ if schema_path in schema_to_var:
3131+ return f'"@{schema_to_var[schema_path]}@"'
3232+ raise Exception(f"Unknown schema path {schema_path!r}, please add it to ./glib-schema-to-var.json")
383339344035@find_cpp_constants@
···11+{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
22+33+# build-tools
44+, bootPkgs
55+, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
66+, xattr, autoSignDarwinBinariesHook
77+, bash
88+99+, libiconv ? null, ncurses
1010+, glibcLocales ? null
1111+1212+, # GHC can be built with system libffi or a bundled one.
1313+ libffi ? null
1414+1515+, useLLVM ? !(stdenv.targetPlatform.isx86
1616+ || stdenv.targetPlatform.isPower
1717+ || stdenv.targetPlatform.isSparc
1818+ || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
1919+, # LLVM is conceptually a run-time-only depedendency, but for
2020+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
2121+ # build-time dependency too.
2222+ buildTargetLlvmPackages, llvmPackages
2323+2424+, # If enabled, GHC will be built with the GPL-free but slightly slower native
2525+ # bignum backend instead of the faster but GPLed gmp backend.
2626+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2727+, gmp
2828+2929+, # If enabled, use -fPIC when compiling static libs.
3030+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
3131+3232+ # aarch64 outputs otherwise exceed 2GB limit
3333+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
3434+3535+, # Whether to build dynamic libs for the standard library (on the target
3636+ # platform). Static libs are always built.
3737+ enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
3838+3939+, # Whether to build terminfo.
4040+ enableTerminfo ? !stdenv.targetPlatform.isWindows
4141+4242+, # What flavour to build. An empty string indicates no
4343+ # specific flavour and falls back to ghc default values.
4444+ ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
4545+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
4646+4747+, # Whether to build sphinx documentation.
4848+ enableDocs ? (
4949+ # Docs disabled for musl and cross because it's a large task to keep
5050+ # all `sphinx` dependencies building in those environments.
5151+ # `sphinx` pulls in among others:
5252+ # Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
5353+ (stdenv.targetPlatform == stdenv.hostPlatform)
5454+ && !stdenv.hostPlatform.isMusl
5555+ )
5656+5757+, enableHaddockProgram ?
5858+ # Disabled for cross; see note [HADDOCK_DOCS].
5959+ (stdenv.targetPlatform == stdenv.hostPlatform)
6060+6161+, # Whether to disable the large address space allocator
6262+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
6363+ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
6464+}:
6565+6666+assert !enableNativeBignum -> gmp != null;
6767+6868+# Cross cannot currently build the `haddock` program for silly reasons,
6969+# see note [HADDOCK_DOCS].
7070+assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
7171+7272+let
7373+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
7474+7575+ inherit (bootPkgs) ghc;
7676+7777+ # TODO(@Ericson2314) Make unconditional
7878+ targetPrefix = lib.optionalString
7979+ (targetPlatform != hostPlatform)
8080+ "${targetPlatform.config}-";
8181+8282+ buildMK = ''
8383+ BuildFlavour = ${ghcFlavour}
8484+ ifneq \"\$(BuildFlavour)\" \"\"
8585+ include mk/flavours/\$(BuildFlavour).mk
8686+ endif
8787+ BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
8888+ BUILD_SPHINX_PDF = NO
8989+ '' +
9090+ # Note [HADDOCK_DOCS]:
9191+ # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
9292+ # program is built (which we generally always want to have a complete GHC install)
9393+ # and whether it is run on the GHC sources to generate hyperlinked source code
9494+ # (which is impossible for cross-compilation); see:
9595+ # https://gitlab.haskell.org/ghc/ghc/-/issues/20077
9696+ # This implies that currently a cross-compiled GHC will never have a `haddock`
9797+ # program, so it can never generate haddocks for any packages.
9898+ # If this is solved in the future, we'd like to unconditionally
9999+ # build the haddock program (removing the `enableHaddockProgram` option).
100100+ ''
101101+ HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
102102+ # Build haddocks for boot packages with hyperlinking
103103+ EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
104104+105105+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
106106+ BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
107107+ '' + lib.optionalString (targetPlatform != hostPlatform) ''
108108+ Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
109109+ CrossCompilePrefix = ${targetPrefix}
110110+ '' + lib.optionalString (!enableProfiledLibs) ''
111111+ GhcLibWays = "v dyn"
112112+ '' +
113113+ # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
114114+ # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
115115+ # This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
116116+ lib.optionalString enableRelocatedStaticLibs ''
117117+ GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
118118+ GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
119119+ '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
120120+ EXTRA_CC_OPTS += -std=gnu99
121121+ '';
122122+123123+ # Splicer will pull out correct variations
124124+ libDeps = platform: lib.optional enableTerminfo ncurses
125125+ ++ [libffi]
126126+ ++ lib.optional (!enableNativeBignum) gmp
127127+ ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
128128+129129+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
130130+ # GHC doesn't seem to have {LLC,OPT}_HOST
131131+ toolsForTarget = [
132132+ pkgsBuildTarget.targetPackages.stdenv.cc
133133+ ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
134134+135135+ targetCC = builtins.head toolsForTarget;
136136+137137+ # Sometimes we have to dispatch between the bintools wrapper and the unwrapped
138138+ # derivation for certain tools depending on the platform.
139139+ bintoolsFor = {
140140+ # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
141141+ # part of the bintools wrapper (due to codesigning requirements), but not on
142142+ # x86_64-darwin.
143143+ install_name_tool =
144144+ if stdenv.targetPlatform.isAarch64
145145+ then targetCC.bintools
146146+ else targetCC.bintools.bintools;
147147+ # Same goes for strip.
148148+ strip =
149149+ # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
150150+ if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
151151+ then targetCC.bintools
152152+ else targetCC.bintools.bintools;
153153+ };
154154+155155+ # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
156156+ # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
157157+ # see #84670 and #49071 for more background.
158158+ useLdGold = targetPlatform.linker == "gold" ||
159159+ (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
160160+161161+ # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
162162+ variantSuffix = lib.concatStrings [
163163+ (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
164164+ (lib.optionalString enableNativeBignum "-native-bignum")
165165+ ];
166166+167167+in
168168+169169+# C compiler, bintools and LLVM are used at build time, but will also leak into
170170+# the resulting GHC's settings file and used at runtime. This means that we are
171171+# currently only able to build GHC if hostPlatform == buildPlatform.
172172+assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
173173+assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
174174+assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
175175+176176+stdenv.mkDerivation (rec {
177177+ version = "9.2.5";
178178+ pname = "${targetPrefix}ghc${variantSuffix}";
179179+180180+ src = fetchurl {
181181+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
182182+ sha256 = "0606797d1b38e2d88ee2243f38ec6b9a1aa93e9b578e95f0de9a9c0a4144021c";
183183+ };
184184+185185+ enableParallelBuilding = true;
186186+187187+ outputs = [ "out" "doc" ];
188188+189189+ patches = [
190190+ # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
191191+ (fetchpatch {
192192+ url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
193193+ sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
194194+ extraPrefix = "utils/haddock/";
195195+ stripLen = 1;
196196+ })
197197+ ];
198198+199199+ postPatch = "patchShebangs .";
200200+201201+ # GHC needs the locale configured during the Haddock phase.
202202+ LANG = "en_US.UTF-8";
203203+204204+ # GHC is a bit confused on its cross terminology.
205205+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
206206+ preConfigure = ''
207207+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
208208+ export "''${env#TARGET_}=''${!env}"
209209+ done
210210+ # GHC is a bit confused on its cross terminology, as these would normally be
211211+ # the *host* tools.
212212+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
213213+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
214214+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
215215+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
216216+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
217217+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
218218+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
219219+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
220220+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
221221+ export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
222222+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
223223+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
224224+ export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
225225+ '' + lib.optionalString useLLVM ''
226226+ export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
227227+ export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
228228+ '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
229229+ # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
230230+ export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
231231+ '' + ''
232232+ echo -n "${buildMK}" > mk/build.mk
233233+ '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
234234+ export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
235235+ '' + lib.optionalString (!stdenv.isDarwin) ''
236236+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
237237+ '' + lib.optionalString stdenv.isDarwin ''
238238+ export NIX_LDFLAGS+=" -no_dtrace_dof"
239239+240240+ # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
241241+ export XATTR=${lib.getBin xattr}/bin/xattr
242242+ '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
243243+ 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
244244+ '' + lib.optionalString targetPlatform.isMusl ''
245245+ echo "patching llvm-targets for musl targets..."
246246+ echo "Cloning these existing '*-linux-gnu*' targets:"
247247+ grep linux-gnu llvm-targets | sed 's/^/ /'
248248+ echo "(go go gadget sed)"
249249+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
250250+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
251251+ grep linux-musl llvm-targets | sed 's/^/ /'
252252+253253+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
254254+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
255255+ for x in configure aclocal.m4; do
256256+ substituteInPlace $x \
257257+ --replace '*-android*|*-gnueabi*)' \
258258+ '*-android*|*-gnueabi*|*-musleabi*)'
259259+ done
260260+ '';
261261+262262+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
263263+ configurePlatforms = [ "build" "host" ]
264264+ ++ lib.optional (targetPlatform != hostPlatform) "target";
265265+266266+ # `--with` flags for libraries needed for RTS linker
267267+ configureFlags = [
268268+ "--datadir=$doc/share/doc/ghc"
269269+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
270270+ ] ++ lib.optionals (libffi != null) [
271271+ "--with-system-libffi"
272272+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
273273+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
274274+ ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
275275+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
276276+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
277277+ ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
278278+ "--with-iconv-includes=${libiconv}/include"
279279+ "--with-iconv-libraries=${libiconv}/lib"
280280+ ] ++ lib.optionals (targetPlatform != hostPlatform) [
281281+ "--enable-bootstrap-with-devel-snapshot"
282282+ ] ++ lib.optionals useLdGold [
283283+ "CFLAGS=-fuse-ld=gold"
284284+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
285285+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
286286+ ] ++ lib.optionals (disableLargeAddressSpace) [
287287+ "--disable-large-address-space"
288288+ ];
289289+290290+ # Make sure we never relax`$PATH` and hooks support for compatibility.
291291+ strictDeps = true;
292292+293293+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
294294+ dontAddExtraLibs = true;
295295+296296+ nativeBuildInputs = [
297297+ perl autoconf automake m4 python3
298298+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
299299+ ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
300300+ autoSignDarwinBinariesHook
301301+ ] ++ lib.optionals enableDocs [
302302+ sphinx
303303+ ];
304304+305305+ # For building runtime libs
306306+ depsBuildTarget = toolsForTarget;
307307+308308+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
309309+310310+ depsTargetTarget = map lib.getDev (libDeps targetPlatform);
311311+ depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
312312+313313+ # required, because otherwise all symbols from HSffi.o are stripped, and
314314+ # that in turn causes GHCi to abort
315315+ stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
316316+317317+ checkTarget = "test";
318318+319319+ hardeningDisable =
320320+ [ "format" ]
321321+ # In nixpkgs, musl based builds currently enable `pie` hardening by default
322322+ # (see `defaultHardeningFlags` in `make-derivation.nix`).
323323+ # But GHC cannot currently produce outputs that are ready for `-pie` linking.
324324+ # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
325325+ # See:
326326+ # * https://github.com/NixOS/nixpkgs/issues/129247
327327+ # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
328328+ ++ lib.optional stdenv.targetPlatform.isMusl "pie";
329329+330330+ # big-parallel allows us to build with more than 2 cores on
331331+ # Hydra which already warrants a significant speedup
332332+ requiredSystemFeatures = [ "big-parallel" ];
333333+334334+ postInstall = ''
335335+ # Install the bash completion file.
336336+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
337337+ '';
338338+339339+ passthru = {
340340+ inherit bootPkgs targetPrefix;
341341+342342+ inherit llvmPackages;
343343+ inherit enableShared;
344344+345345+ # This is used by the haskell builder to query
346346+ # the presence of the haddock program.
347347+ hasHaddock = enableHaddockProgram;
348348+349349+ # Our Cabal compiler name
350350+ haskellCompilerName = "ghc-${version}";
351351+ };
352352+353353+ meta = {
354354+ homepage = "http://haskell.org/ghc";
355355+ description = "The Glasgow Haskell Compiler";
356356+ maintainers = with lib.maintainers; [
357357+ guibou
358358+ ] ++ lib.teams.haskell.members;
359359+ timeout = 24 * 3600;
360360+ inherit (ghc.meta) license platforms;
361361+ };
362362+363363+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
364364+ dontStrip = true;
365365+ dontPatchELF = true;
366366+ noAuditTmpdir = true;
367367+})
+370
pkgs/development/compilers/ghc/9.4.3.nix
···11+# DO NOT port this expression to hadrian. It is not possible to build a GHC
22+# cross compiler with 9.4.* and hadrian.
33+{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
44+55+# build-tools
66+, bootPkgs
77+, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
88+, xattr, autoSignDarwinBinariesHook
99+, bash
1010+1111+, libiconv ? null, ncurses
1212+, glibcLocales ? null
1313+1414+, # GHC can be built with system libffi or a bundled one.
1515+ libffi ? null
1616+1717+, useLLVM ? !(stdenv.targetPlatform.isx86
1818+ || stdenv.targetPlatform.isPower
1919+ || stdenv.targetPlatform.isSparc
2020+ || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
2121+, # LLVM is conceptually a run-time-only depedendency, but for
2222+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
2323+ # build-time dependency too.
2424+ buildTargetLlvmPackages, llvmPackages
2525+2626+, # If enabled, GHC will be built with the GPL-free but slightly slower native
2727+ # bignum backend instead of the faster but GPLed gmp backend.
2828+ enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
2929+, gmp
3030+3131+, # If enabled, use -fPIC when compiling static libs.
3232+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
3333+3434+ # aarch64 outputs otherwise exceed 2GB limit
3535+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
3636+3737+, # Whether to build dynamic libs for the standard library (on the target
3838+ # platform). Static libs are always built.
3939+ enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
4040+4141+, # Whether to build terminfo.
4242+ enableTerminfo ? !stdenv.targetPlatform.isWindows
4343+4444+, # What flavour to build. An empty string indicates no
4545+ # specific flavour and falls back to ghc default values.
4646+ ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
4747+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
4848+4949+, # Whether to build sphinx documentation.
5050+ enableDocs ? (
5151+ # Docs disabled for musl and cross because it's a large task to keep
5252+ # all `sphinx` dependencies building in those environments.
5353+ # `sphinx` pulls in among others:
5454+ # Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
5555+ (stdenv.targetPlatform == stdenv.hostPlatform)
5656+ && !stdenv.hostPlatform.isMusl
5757+ )
5858+5959+, enableHaddockProgram ?
6060+ # Disabled for cross; see note [HADDOCK_DOCS].
6161+ (stdenv.targetPlatform == stdenv.hostPlatform)
6262+6363+, # Whether to disable the large address space allocator
6464+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
6565+ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
6666+}:
6767+6868+assert !enableNativeBignum -> gmp != null;
6969+7070+# Cross cannot currently build the `haddock` program for silly reasons,
7171+# see note [HADDOCK_DOCS].
7272+assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
7373+7474+let
7575+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
7676+7777+ inherit (bootPkgs) ghc;
7878+7979+ # TODO(@Ericson2314) Make unconditional
8080+ targetPrefix = lib.optionalString
8181+ (targetPlatform != hostPlatform)
8282+ "${targetPlatform.config}-";
8383+8484+ buildMK = ''
8585+ BuildFlavour = ${ghcFlavour}
8686+ ifneq \"\$(BuildFlavour)\" \"\"
8787+ include mk/flavours/\$(BuildFlavour).mk
8888+ endif
8989+ BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
9090+ BUILD_SPHINX_PDF = NO
9191+ '' +
9292+ # Note [HADDOCK_DOCS]:
9393+ # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
9494+ # program is built (which we generally always want to have a complete GHC install)
9595+ # and whether it is run on the GHC sources to generate hyperlinked source code
9696+ # (which is impossible for cross-compilation); see:
9797+ # https://gitlab.haskell.org/ghc/ghc/-/issues/20077
9898+ # This implies that currently a cross-compiled GHC will never have a `haddock`
9999+ # program, so it can never generate haddocks for any packages.
100100+ # If this is solved in the future, we'd like to unconditionally
101101+ # build the haddock program (removing the `enableHaddockProgram` option).
102102+ ''
103103+ HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
104104+ # Build haddocks for boot packages with hyperlinking
105105+ EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
106106+107107+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
108108+ BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
109109+ '' + lib.optionalString (targetPlatform != hostPlatform) ''
110110+ Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
111111+ CrossCompilePrefix = ${targetPrefix}
112112+ '' + lib.optionalString (!enableProfiledLibs) ''
113113+ GhcLibWays = "v dyn"
114114+ '' +
115115+ # -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
116116+ # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
117117+ # This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
118118+ lib.optionalString enableRelocatedStaticLibs ''
119119+ GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
120120+ GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
121121+ '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
122122+ EXTRA_CC_OPTS += -std=gnu99
123123+ '';
124124+125125+ # Splicer will pull out correct variations
126126+ libDeps = platform: lib.optional enableTerminfo ncurses
127127+ ++ [libffi]
128128+ ++ lib.optional (!enableNativeBignum) gmp
129129+ ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
130130+131131+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
132132+ # GHC doesn't seem to have {LLC,OPT}_HOST
133133+ toolsForTarget = [
134134+ pkgsBuildTarget.targetPackages.stdenv.cc
135135+ ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
136136+137137+ targetCC = builtins.head toolsForTarget;
138138+139139+ # Sometimes we have to dispatch between the bintools wrapper and the unwrapped
140140+ # derivation for certain tools depending on the platform.
141141+ bintoolsFor = {
142142+ # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
143143+ # part of the bintools wrapper (due to codesigning requirements), but not on
144144+ # x86_64-darwin.
145145+ install_name_tool =
146146+ if stdenv.targetPlatform.isAarch64
147147+ then targetCC.bintools
148148+ else targetCC.bintools.bintools;
149149+ # Same goes for strip.
150150+ strip =
151151+ # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
152152+ if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
153153+ then targetCC.bintools
154154+ else targetCC.bintools.bintools;
155155+ };
156156+157157+ # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
158158+ # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
159159+ # see #84670 and #49071 for more background.
160160+ useLdGold = targetPlatform.linker == "gold" ||
161161+ (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
162162+163163+ # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
164164+ variantSuffix = lib.concatStrings [
165165+ (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
166166+ (lib.optionalString enableNativeBignum "-native-bignum")
167167+ ];
168168+169169+in
170170+171171+# C compiler, bintools and LLVM are used at build time, but will also leak into
172172+# the resulting GHC's settings file and used at runtime. This means that we are
173173+# currently only able to build GHC if hostPlatform == buildPlatform.
174174+assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
175175+assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
176176+assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
177177+178178+stdenv.mkDerivation (rec {
179179+ version = "9.4.3";
180180+ pname = "${targetPrefix}ghc${variantSuffix}";
181181+182182+ src = fetchurl {
183183+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
184184+ sha256 = "eaf63949536ede50ee39179f2299d5094eb9152d87cc6fb2175006bc98e8905a";
185185+ };
186186+187187+ enableParallelBuilding = true;
188188+189189+ outputs = [ "out" "doc" ];
190190+191191+192192+ postPatch = "patchShebangs .";
193193+194194+ # GHC needs the locale configured during the Haddock phase.
195195+ LANG = "en_US.UTF-8";
196196+197197+ # GHC is a bit confused on its cross terminology.
198198+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
199199+ preConfigure = ''
200200+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
201201+ export "''${env#TARGET_}=''${!env}"
202202+ done
203203+ # GHC is a bit confused on its cross terminology, as these would normally be
204204+ # the *host* tools.
205205+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
206206+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
207207+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
208208+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
209209+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
210210+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
211211+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
212212+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
213213+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
214214+ export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
215215+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
216216+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
217217+ export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
218218+ '' + lib.optionalString useLLVM ''
219219+ export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
220220+ export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
221221+ '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
222222+ # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
223223+ export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
224224+ '' + ''
225225+226226+ echo -n "${buildMK}" > mk/build.mk
227227+228228+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
229229+ '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
230230+ export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
231231+ '' + lib.optionalString (!stdenv.isDarwin) ''
232232+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
233233+ '' + lib.optionalString stdenv.isDarwin ''
234234+ export NIX_LDFLAGS+=" -no_dtrace_dof"
235235+236236+ # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
237237+ export XATTR=${lib.getBin xattr}/bin/xattr
238238+ '' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
239239+ 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
240240+ '' + lib.optionalString targetPlatform.isMusl ''
241241+ echo "patching llvm-targets for musl targets..."
242242+ echo "Cloning these existing '*-linux-gnu*' targets:"
243243+ grep linux-gnu llvm-targets | sed 's/^/ /'
244244+ echo "(go go gadget sed)"
245245+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
246246+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
247247+ grep linux-musl llvm-targets | sed 's/^/ /'
248248+249249+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
250250+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
251251+ for x in configure aclocal.m4; do
252252+ substituteInPlace $x \
253253+ --replace '*-android*|*-gnueabi*)' \
254254+ '*-android*|*-gnueabi*|*-musleabi*)'
255255+ done
256256+ ''
257257+ # HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
258258+ # binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
259259+ + ''
260260+ substituteInPlace configure --replace \
261261+ 'MinBootGhcVersion="9.0"' \
262262+ 'MinBootGhcVersion="8.10"'
263263+ '';
264264+265265+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
266266+ configurePlatforms = [ "build" "host" ]
267267+ ++ lib.optional (targetPlatform != hostPlatform) "target";
268268+269269+ # `--with` flags for libraries needed for RTS linker
270270+ configureFlags = [
271271+ "--datadir=$doc/share/doc/ghc"
272272+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
273273+ ] ++ lib.optionals (libffi != null) [
274274+ "--with-system-libffi"
275275+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
276276+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
277277+ ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
278278+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
279279+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
280280+ ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
281281+ "--with-iconv-includes=${libiconv}/include"
282282+ "--with-iconv-libraries=${libiconv}/lib"
283283+ ] ++ lib.optionals (targetPlatform != hostPlatform) [
284284+ "--enable-bootstrap-with-devel-snapshot"
285285+ ] ++ lib.optionals useLdGold [
286286+ "CFLAGS=-fuse-ld=gold"
287287+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
288288+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
289289+ ] ++ lib.optionals (disableLargeAddressSpace) [
290290+ "--disable-large-address-space"
291291+ ];
292292+293293+ # Make sure we never relax`$PATH` and hooks support for compatibility.
294294+ strictDeps = true;
295295+296296+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
297297+ dontAddExtraLibs = true;
298298+299299+ nativeBuildInputs = [
300300+ perl autoconf automake m4 python3
301301+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
302302+ ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
303303+ autoSignDarwinBinariesHook
304304+ ] ++ lib.optionals enableDocs [
305305+ sphinx
306306+ ];
307307+308308+ # For building runtime libs
309309+ depsBuildTarget = toolsForTarget;
310310+311311+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
312312+313313+ depsTargetTarget = map lib.getDev (libDeps targetPlatform);
314314+ depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
315315+316316+ # required, because otherwise all symbols from HSffi.o are stripped, and
317317+ # that in turn causes GHCi to abort
318318+ stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
319319+320320+ checkTarget = "test";
321321+322322+ hardeningDisable =
323323+ [ "format" ]
324324+ # In nixpkgs, musl based builds currently enable `pie` hardening by default
325325+ # (see `defaultHardeningFlags` in `make-derivation.nix`).
326326+ # But GHC cannot currently produce outputs that are ready for `-pie` linking.
327327+ # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
328328+ # See:
329329+ # * https://github.com/NixOS/nixpkgs/issues/129247
330330+ # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
331331+ ++ lib.optional stdenv.targetPlatform.isMusl "pie";
332332+333333+ # big-parallel allows us to build with more than 2 cores on
334334+ # Hydra which already warrants a significant speedup
335335+ requiredSystemFeatures = [ "big-parallel" ];
336336+337337+ postInstall = ''
338338+ # Install the bash completion file.
339339+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
340340+ '';
341341+342342+ passthru = {
343343+ inherit bootPkgs targetPrefix;
344344+345345+ inherit llvmPackages;
346346+ inherit enableShared;
347347+348348+ # This is used by the haskell builder to query
349349+ # the presence of the haddock program.
350350+ hasHaddock = enableHaddockProgram;
351351+352352+ # Our Cabal compiler name
353353+ haskellCompilerName = "ghc-${version}";
354354+ };
355355+356356+ meta = {
357357+ homepage = "http://haskell.org/ghc";
358358+ description = "The Glasgow Haskell Compiler";
359359+ maintainers = with lib.maintainers; [
360360+ guibou
361361+ ] ++ lib.teams.haskell.members;
362362+ timeout = 24 * 3600;
363363+ inherit (ghc.meta) license platforms;
364364+ };
365365+366366+} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
367367+ dontStrip = true;
368368+ dontPatchELF = true;
369369+ noAuditTmpdir = true;
370370+})
+1-1
pkgs/development/compilers/ghc/common-hadrian.nix
···158158159159assert stdenv.hostPlatform == stdenv.targetPlatform || throw ''
160160 hadrian doesn't support building an installable GHC cross-compiler at the moment.
161161- Consider using GHC 9.4.2 or lower which support this via the make build system.
161161+ Consider using GHC 9.4 or lower which support this via the make build system.
162162 See also: https://gitlab.haskell.org/ghc/ghc/-/issues/22090
163163'';
164164
···2020 # The websites yt-dlp deals with are a very moving target. That means that
2121 # downloads break constantly. Because of that, updates should always be backported
2222 # to the latest stable release.
2323- version = "2022.10.4";
2323+ version = "2022.11.11";
24242525 src = fetchPypi {
2626 inherit pname version;
2727- sha256 = "sha256-F3Ki5vMrlxtNAm3q4wRPV2uAUgNSVco0DzRc/pDTjTg=";
2727+ sha256 = "sha256-9rliAjwXp3FRR28Pbtcb6H0Bdim6XZmUUovFSFIRkbY=";
2828 };
29293030 propagatedBuildInputs = [ brotli certifi mutagen pycryptodomex websockets ];