Skip to content

Commit 3e15ac5

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into circuithub
2 parents 0a0021d + ef40c28 commit 3e15ac5

File tree

502 files changed

+15441
-13281
lines changed

Some content is hidden

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

502 files changed

+15441
-13281
lines changed

builder/make-config-files.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ let
160160
fi
161161
''}
162162
done
163-
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do
163+
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
164164
if [ -e $ghcDeps/envDeps/$p ]; then
165165
cat $ghcDeps/envDeps/$p >> $configFiles/ghc-environment
166166
fi

changelog.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
This file contains a summary of changes to Haskell.nix and `nix-tools`
22
that will impact users.
33

4+
## Jun 5, 2024
5+
6+
Haskell.nix now respects the `pre-existing` packages selected
7+
by the cabal planner. The selection made by the planner
8+
is used to set `nonReinstallablePkgs`.
9+
10+
Instead setting `nonReinstallablePkgs` and `reinstallableLibGhc`
11+
haskell.nix projects should add `constraints` to the cabal project.
12+
13+
For instance to force the use of the `pre-exising` `text`
14+
package add:
15+
16+
```
17+
constraints: text installed
18+
```
19+
20+
To make sure `text` is reinstalled use:
21+
22+
```
23+
constraints: text source
24+
```
25+
26+
The `pre-existing` `ghc` will now be used by default as
27+
that is what `cabal` will choose (haskell.nix used to choose
28+
`reinstallableLibGhc=true` by default).
29+
30+
To allow cabal to choose reinstalling `ghc` add:
31+
32+
```
33+
allow-boot-library-installs: True
34+
```
35+
36+
To force cabal to choose reinstalling:
37+
38+
```
39+
constraints: ghc source
40+
allow-boot-library-installs: True
41+
```
42+
43+
It may also need `allow-newer: ghc:Cabal`
44+
445
## Mar 27, 2023
546

647
Haskell.nix will no longer parse the `cabal.project` file to

ci.nix

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@
5656
# cabal-install and nix-tools plans. When removing a ghc version
5757
# from here (so that is no longer cached) also remove ./materialized/ghcXXX.
5858
# Update supported-ghc-versions.md to reflect any changes made here.
59-
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2305") {
60-
ghc810 = false;
61-
ghc90 = false;
62-
ghc92 = false;
63-
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "R2311") {
59+
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2311") {
6460
ghc94 = false;
6561
ghc96 = false;
6662
ghc98 = false;
@@ -88,8 +84,8 @@
8884
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
8985
)) {
9086
inherit (lib.systems.examples) ghcjs;
91-
} // lib.optionalAttrs (nixpkgsName != "unstable"
92-
&& (__match ".*llvm" compiler-nix-name == null)
87+
} // lib.optionalAttrs (
88+
(__match ".*llvm" compiler-nix-name == null)
9389
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884"])
9490
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
9591
inherit (lib.systems.examples) mingwW64;

compiler/ghc/default.nix

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,15 @@ let self =
6767
, useLdGold ?
6868
# might be better check to see if cc is clang/llvm?
6969
# use gold as the linker on linux to improve link times
70-
# do not use it on musl due to a ld.gold bug. See: <https://sourceware.org/bugzilla/show_bug.cgi?id=22266>.
71-
(stdenv.targetPlatform.isLinux && !stdenv.targetPlatform.isAndroid && !stdenv.targetPlatform.isMusl)
70+
# do not use ld.gold 2.3 with musl due to a ld.gold bug.
71+
# See: <https://sourceware.org/bugzilla/show_bug.cgi?id=22266>.
72+
# Note that this bug was resolved in 2017.
73+
( stdenv.targetPlatform.isLinux
74+
# don't use gold on android.
75+
&& !stdenv.targetPlatform.isAndroid
76+
# don't use gold with with musl. Still seems to be
77+
# affected by 22266.
78+
&& !stdenv.targetPlatform.isMusl)
7279

7380
, ghc-version ? src-spec.version
7481
, ghc-version-date ? null
@@ -246,21 +253,28 @@ let
246253
then "ghc928"
247254
else "ghc962";
248255
in
249-
buildPackages.pinned-haskell-nix.tool compiler-nix-name "hadrian" {
256+
buildPackages.haskell-nix.tool compiler-nix-name "hadrian" {
250257
compilerSelection = p: p.haskell.compiler;
251258
index-state = buildPackages.haskell-nix.internalHackageIndexState;
252259
# Verions of hadrian that comes with 9.6 depends on `time`
253260
materialized =
254261
if builtins.compareVersions ghc-version "9.4" < 0
255262
then ../../materialized/${compiler-nix-name}/hadrian-ghc92
263+
else if builtins.compareVersions ghc-version "9.4.8" < 0
264+
then ../../materialized/${compiler-nix-name}/hadrian-ghc947
256265
else if builtins.compareVersions ghc-version "9.6" < 0
257266
then ../../materialized/${compiler-nix-name}/hadrian-ghc94
267+
else if builtins.compareVersions ghc-version "9.6.5" < 0
268+
then ../../materialized/${compiler-nix-name}/hadrian-ghc964
258269
else if builtins.compareVersions ghc-version "9.8" < 0
259270
then ../../materialized/${compiler-nix-name}/hadrian-ghc96
271+
else if builtins.compareVersions ghc-version "9.8.2" < 0
272+
then ../../materialized/${compiler-nix-name}/hadrian-ghc981
260273
else if builtins.compareVersions ghc-version "9.9" < 0
261274
then ../../materialized/${compiler-nix-name}/hadrian-ghc98
262275
else ../../materialized/${compiler-nix-name}/hadrian-ghc99;
263276
modules = [{
277+
reinstallableLibGhc = false;
264278
# Apply the patches in a way that does not require using something
265279
# like `srcOnly`. The problem with `pkgs.srcOnly` was that it had to run
266280
# on a platform at eval time.
@@ -314,6 +328,11 @@ let
314328
# `-fexternal-dynamic-refs` causes `undefined reference` errors when building GHC cross compiler for windows
315329
+ lib.optionalString (enableRelocatedStaticLibs && targetPlatform.isx86_64 && !targetPlatform.isWindows)
316330
" '*.*.ghc.*.opts += -fexternal-dynamic-refs'"
331+
# The fact that we need to set this here is pretty idiotic. GHC should figure this out on it's own.
332+
# Either have a runtime flag/setting to disable it or if dlopen fails, remember that it failed and
333+
# fall back to non-dynamic. We only have dynamic linker with musl if host and target arch match.
334+
+ lib.optionalString (targetPlatform.isAndroid || (targetPlatform.isMusl && haskell-nix.haskellLib.isCrossTarget))
335+
" '*.ghc.cabal.configure.opts += --flags=-dynamic-system-linker'"
317336
# The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older
318337
# iPhones/iPads/... won't understand the compiled code, as the compiler will emit LDSETALH
319338
# + lib.optionalString (targetPlatform.???) "'*.rts.ghc.c.opts += -optc-mcpu=apple-a7 -optc-march=armv8-a+norcpc'"

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/call-cabal-project-to-nix.nix

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ let
9999
(compilerSelection pkgs)."${compiler-nix-name}";
100100

101101
in let
102-
ghc = ghc';
102+
ghc = if ghc' ? latestVersion
103+
then __trace "WARNING: ${ghc'.version} is out of date, consider using upgrading to ${ghc'.latestVersion}." ghc'
104+
else ghc';
103105
subDir' = src.origSubDir or "";
104106
subDir = pkgs.lib.strings.removePrefix "/" subDir';
105107

@@ -361,46 +363,49 @@ let
361363

362364
ghc-pkgs = [
363365
"Cabal"
364-
"Cabal-syntax"
365366
"array"
366367
"base"
367368
"binary"
368369
"bytestring"
369370
"containers"
370371
"deepseq"
371372
"directory"
372-
"exceptions"
373373
"filepath"
374-
"ghc"
375-
"ghc-bignum"
376374
"ghc-boot"
377375
"ghc-boot-th"
378376
"ghc-compact"
379-
"ghc-experimental"
380377
"ghc-heap"
381-
"ghc-internal"
382-
"ghc-platform"
383378
"ghc-prim"
384-
"ghc-toolchain"
385379
"ghci"
386-
"haskeline"
387-
"hpc"
388380
"integer-gmp"
389-
"libiserv"
390381
"mtl"
391-
"os-string"
392382
"parsec"
393383
"pretty"
394384
"process"
395385
"rts"
396-
"semaphore-compat"
397-
"stm"
398386
"template-haskell"
399-
"terminfo"
400387
"text"
401388
"time"
402389
"transformers"
390+
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [
391+
# GHCJS 8.10 does not have these
392+
"Cabal-syntax"
393+
"exceptions"
394+
"ghc"
395+
"ghc-bignum"
396+
"ghc-experimental"
397+
"ghc-internal"
398+
"ghc-platform"
399+
"ghc-toolchain"
400+
"haskeline"
401+
"hpc"
402+
"libiserv"
403+
"os-string"
404+
"semaphore-compat"
405+
"stm"
403406
"xhtml"
407+
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs) [
408+
"terminfo"
404409
] ++ (if pkgs.stdenv.targetPlatform.isWindows
405410
then [ "Win32" ]
406411
else [ "unix" ]
@@ -434,7 +439,22 @@ let
434439
cat $cabal_file | sed -e 's/@ProjectVersionMunged@/${ghc.version}/g' -e 's/default: *@[A-Za-z0-9]*@/default: False/g' -e 's/@Suffix@//g' > $fixed_cabal_file
435440
json_cabal_file=$(mktemp)
436441
cabal2json $fixed_cabal_file > $json_cabal_file
437-
EXPOSED_MODULES_${varname name}="$(jq -r '.library."exposed-modules"[]|select(type=="array")[]' $json_cabal_file | tr '\n' ' ')"
442+
443+
exposed_modules="$(jq -r '.library."exposed-modules"[]|select(type=="array")[]' $json_cabal_file)"
444+
reexported_modules="$(jq -r '.library."reexported-modules"//[]|.[]|select(type=="array")[]' $json_cabal_file)"
445+
446+
# FIXME This is a bandaid. Rather than doing this, conditionals should be interpreted.
447+
${pkgs.lib.optionalString pkgs.stdenv.targetPlatform.isGhcjs ''
448+
exposed_modules+=" $(jq -r '.library."exposed-modules"[]|select(type=="object" and .if.arch == "javascript")|.then[]' $json_cabal_file)"
449+
''}
450+
${pkgs.lib.optionalString pkgs.stdenv.targetPlatform.isWindows ''
451+
exposed_modules+=" $(jq -r '.library."exposed-modules"[]|select(type=="object" and .if.os == "windows")|.then[]' $json_cabal_file)"
452+
''}
453+
${pkgs.lib.optionalString (!pkgs.stdenv.targetPlatform.isWindows) ''
454+
exposed_modules+=" $(jq -r '.library."exposed-modules"[]|select(type=="object" and .if.not.os == "windows")|.then[]' $json_cabal_file)"
455+
''}
456+
457+
EXPOSED_MODULES_${varname name}="$(tr '\n' ' ' <<< "$exposed_modules $reexported_modules")"
438458
DEPS_${varname name}="$(jq -r '.library."build-depends"[]|select(type=="array")[],select(type=="object").then[]' $json_cabal_file | sed 's/^\([A-Za-z0-9-]*\).*$/\1/g' | sort -u | tr '\n' ' ')"
439459
VER_${varname name}="$(jq -r '.version' $json_cabal_file)"
440460
PKGS+=" ${name}"

lib/default.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,19 @@ in {
340340

341341
# Converts from a `compoent.depends` value to a library derivation.
342342
# In the case of sublibs the `depends` value should already be the derivation.
343-
dependToLib = d: d.components.library or d;
343+
dependToLib = d:
344+
# Do simplify this to `d.components.library or d`, as that
345+
# will not give a good error message if the `.library`
346+
# is missing (happens if the package is unplanned,
347+
# but has overrides).
348+
# It would be nice to put an `assert` here, but there is
349+
# currently no good way to get the name of the dependency
350+
# when it is not in the plan. The attribute path of
351+
# `d` in the `nix` error should include the name
352+
# eg. `packages.Cabal.components.library`.
353+
if d ? components
354+
then d.components.library
355+
else d;
344356

345357
projectOverlays = import ./project-overlays.nix {
346358
inherit lib haskellLib;

lib/pkgconf-nixpkgs-map.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ pkgs:
21672167
"gdkmm-3.0" = [ "gtkmm3" ];
21682168
"gtkmm-3.0" = [ "gtkmm3" ];
21692169
"gtkmm-4.0" = [ "gtkmm4" ];
2170-
"libgtkpod-1.1.0" = [ "gtkpod" ];
2170+
# "libgtkpod-1.1.0" = [ "gtkpod" ];
21712171
# "gtksourceview-3.0" = [ "gtksourceview" ];
21722172
"gtksourceview-3.0" = [ "gtksourceview3" ];
21732173
"gtksourceview-4" = [ "gtksourceview4" ];

materialized/alex-3.2.7.1/default.nix

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

materialized/ghc-boot-packages-nix/ghc8107-ghcjs/Win32.nix

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)