Skip to content

Commit 8f0e693

Browse files
committed
Merge remote-tracking branch 'origin/master' into hkm/ghc901
# Conflicts: # overlays/hackage-quirks.nix # release-linux-only.nix
2 parents 74f10e0 + 6c627b4 commit 8f0e693

Some content is hidden

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

42 files changed

+1434
-1340
lines changed

build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ in rec {
2323
pkgs.recurseIntoAttrs {
2424
cabal-latest = tool compiler-nix-name "cabal" "latest";
2525
hls-latest = tool compiler-nix-name "haskell-language-server" "latest";
26-
hlint-latest = tool compiler-nix-name "hlint" "latest";
26+
hlint-latest = tool compiler-nix-name "hlint" (if compiler-nix-name == "ghc865" then "3.2.7" else "latest");
2727
}
2828
);
2929

builder/comp-builder.nix

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ let self =
2323
, preInstall ? component.preInstall , postInstall ? component.postInstall
2424
, preHaddock ? component.preHaddock , postHaddock ? component.postHaddock
2525
, shellHook ? ""
26+
, configureAllComponents ? component.configureAllComponents ||
27+
# When set, configure all the components in the package
28+
# (not just the one we are building).
29+
# Enable for tests in packages that use cabal-doctest.
30+
( haskellLib.isTest componentId &&
31+
lib.any (x: x.identifier.name or "" == "cabal-doctest") package.setup-depends
32+
)
33+
, allComponent # Used when `configureAllComponents` is set to get a suitable configuration.
2634

2735
, build-tools ? component.build-tools
2836
, pkgconfig ? component.pkgconfig
@@ -47,7 +55,7 @@ let self =
4755
, doHoogle ? component.doHoogle # Also build a hoogle index
4856
, hyperlinkSource ? component.doHyperlinkSource # Link documentation to the source code
4957
, quickjump ? component.doQuickjump # Generate an index for interactive documentation navigation
50-
, keepSource ? component.keepSource # Build from `source` output in the store then delete `dist`
58+
, keepSource ? component.keepSource || configureAllComponents # Build from `source` output in the store then delete `dist`
5159
, setupHaddockFlags ? component.setupHaddockFlags
5260

5361
# Profiling
@@ -77,6 +85,11 @@ let self =
7785
}@drvArgs:
7886

7987
let
88+
componentForSetup =
89+
if configureAllComponents
90+
then allComponent
91+
else component;
92+
8093
# Ignore attempts to include DWARF info when it is not possible
8194
enableDWARF = drvArgs.enableDWARF or false
8295
&& stdenv.hostPlatform.isLinux
@@ -96,7 +109,7 @@ let
96109
# is the sub directory in that root path that contains the package.
97110
# `cleanSrc.subDir` is used in `prePatch` and `lib/cover.nix`.
98111
cleanSrc = haskellLib.rootAndSubDir (if canCleanSource
99-
then haskellLib.cleanCabalComponent package component "${componentId.ctype}-${componentId.cname}" src
112+
then haskellLib.cleanCabalComponent package componentForSetup "${componentId.ctype}-${componentId.cname}" src
100113
else
101114
# We can clean out the siblings though to at least avoid changes to other packages
102115
# from triggering a rebuild of this one.
@@ -118,8 +131,9 @@ let
118131
needsProfiling = enableExecutableProfiling || enableLibraryProfiling;
119132

120133
configFiles = makeConfigFiles {
134+
component = componentForSetup;
121135
inherit (package) identifier;
122-
inherit component fullName flags needsProfiling enableDWARF;
136+
inherit fullName flags needsProfiling enableDWARF;
123137
};
124138

125139
enableFeature = enable: feature:
@@ -129,8 +143,13 @@ let
129143

130144
finalConfigureFlags = lib.concatStringsSep " " (
131145
[ "--prefix=$out"
132-
"${haskellLib.componentTarget componentId}"
133-
"$(cat ${configFiles}/configure-flags)"
146+
] ++ (
147+
# If configureAllComponents is set we should not specify the component
148+
# and Setup will attempt to configure them all.
149+
if configureAllComponents
150+
then ["--enable-tests" "--enable-benchmarks"]
151+
else ["${haskellLib.componentTarget componentId}"]
152+
) ++ [ "$(cat ${configFiles}/configure-flags)"
134153
] ++ commonConfigureFlags);
135154

136155
# From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
@@ -328,15 +347,21 @@ let
328347
++ (lib.optional enableSeparateDataOutput "data")
329348
++ (lib.optional keepSource "source");
330349

331-
configurePhase =
350+
prePatch =
351+
# emcc is very slow if it cannot cache stuff in $HOME
352+
(lib.optionalString (stdenv.hostPlatform.isGhcjs) ''
353+
export HOME=$(mktemp -d)
354+
'') +
332355
(lib.optionalString (!canCleanSource) ''
333356
echo "Cleaning component source not supported, leaving it un-cleaned"
334357
'') +
335358
(lib.optionalString keepSource ''
336359
cp -r . $source
337360
cd $source
338361
chmod -R +w .
339-
'') + ''
362+
'') + commonAttrs.prePatch;
363+
364+
configurePhase = ''
340365
runHook preConfigure
341366
echo Configure flags:
342367
printf "%q " ${finalConfigureFlags}
@@ -364,7 +389,11 @@ let
364389
target-pkg-and-db = "${ghc.targetPrefix}ghc-pkg -v0 --package-db $out/package.conf.d";
365390
in ''
366391
runHook preInstall
367-
$SETUP_HS copy ${lib.concatStringsSep " " setupInstallFlags}
392+
$SETUP_HS copy ${lib.concatStringsSep " " (
393+
setupInstallFlags
394+
++ lib.optional configureAllComponents
395+
(haskellLib.componentTarget componentId)
396+
)}
368397
${lib.optionalString (haskellLib.isLibrary componentId) ''
369398
$SETUP_HS register --gen-pkg-config=${name}.conf
370399
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
@@ -451,9 +480,24 @@ let
451480
'')
452481
}
453482
runHook postInstall
454-
'' + (lib.optionalString keepSource ''
455-
rm -rf dist
456-
'') + (lib.optionalString (haskellLib.isTest componentId) ''
483+
'' + (
484+
# Keep just the autogen files and package.conf.inplace package
485+
# DB (probably empty unless this is a library component).
486+
# We also have to remove any refernces to $out to avoid
487+
# circular references.
488+
if configureAllComponents
489+
then ''
490+
mv dist dist-tmp-dir
491+
mkdir -p dist/build
492+
mv dist-tmp-dir/build/${componentId.cname}/autogen dist/build/
493+
mv dist-tmp-dir/package.conf.inplace dist/
494+
remove-references-to -t $out dist/build/autogen/*
495+
rm -rf dist-tmp-dir
496+
''
497+
else lib.optionalString keepSource ''
498+
rm -rf dist
499+
''
500+
) + (lib.optionalString (haskellLib.isTest componentId) ''
457501
echo The test ${package.identifier.name}.components.tests.${componentId.cname} was built. To run the test build ${package.identifier.name}.checks.${componentId.cname}.
458502
'');
459503

builder/hspkg-builder.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ let
107107
inherit (pkg) preUnpack postUnpack;
108108
};
109109

110-
buildComp = componentId: component: comp-builder {
111-
inherit componentId component package name src flags setup cabalFile cabal-generator patches revision
110+
buildComp = allComponent: componentId: component: comp-builder {
111+
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches revision
112112
shellHook
113113
;
114114
};
115115

116116
in rec {
117-
components = haskellLib.applyComponents buildComp pkg;
117+
components = haskellLib.applyComponents (buildComp pkg.allComponent) pkg;
118118
checks = pkgs.recurseIntoAttrs (builtins.mapAttrs
119119
(_: d: haskellLib.check d)
120120
(lib.filterAttrs (_: d: d.config.doCheck) components.tests));

builder/shell-for.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ in
128128
++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
129129
# If this shell is a cross compilation shell include
130130
# wrapper script for running cabal build with appropriate args.
131+
# Includes `--with-compiler` in case the `cabal.project` file has `with-compiler:` in it.
131132
++ lib.optional (ghcEnv.targetPrefix != "") (
132133
buildPackages.writeShellScriptBin "${ghcEnv.targetPrefix}cabal" ''
133134
exec cabal \
134135
--with-ghc=${ghcEnv.targetPrefix}ghc \
136+
--with-compiler=${ghcEnv.targetPrefix}ghc \
135137
--with-ghc-pkg=${ghcEnv.targetPrefix}ghc-pkg \
136138
--with-hsc2hs=${ghcEnv.targetPrefix}hsc2hs \
137139
${lib.optionalString (ghcEnv.targetPrefix == "js-unknown-ghcjs-") ''

compiler/ghcjs/ghcjs-src.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"url": "https://github.com/ghcjs/ghcjs",
3-
"rev": "31a54f7320b1f9700eb6389c2eb2d50c712e8371",
4-
"sha256": "1cj1gfqcj0ygc23xj5gbm0ym9wmh8ini57zlgd6s25avgjbrwga6",
3+
"rev": "30706cd687a301776ba4c1efd3db442fa9c78883",
4+
"sha256": "sha256-7mJ/y6l89Rq/rIvZLZAOGpHsiBJ5BPCUuZIu2nxc6Dk=",
55
"fetchSubmodules": true
66
}

compiler/ghcjs/ghcjs.nix

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ pkgs
22
, ghcjsSrcJson ? ./ghcjs-src.json
33
, ghcjsSrc ? pkgs.buildPackages.fetchgit (builtins.fromJSON (builtins.readFile ghcjsSrcJson))
4-
, ghcjsVersion ? "8.6.0.1"
4+
, ghcjsVersion ? "8.6.0.0.10"
55
, ghcVersion ? "8.6.5"
66
, compiler-nix-name ? if builtins.compareVersions ghcjsVersion "8.8.0.0" > 0
77
then "ghc884"
@@ -24,21 +24,25 @@ let
2424
all-ghcjs = pkgs.buildPackages.symlinkJoin {
2525
name = "ghcjs-${ghcjsVersion}-symlinked";
2626
paths = [
27-
(ghcjs.getComponent "exe:ghcjs")
28-
(ghcjs.getComponent "exe:ghcjs-pkg")
2927
(ghcjs.getComponent "exe:ghcjs-boot")
30-
(ghcjs.getComponent "exe:ghcjs-dumparchive")
3128
] ++ (if isGhcjs88
3229
then [
30+
(ghcjs.getComponent "exe:ghcjs")
31+
(ghcjs.getComponent "exe:ghcjs-pkg")
32+
(ghcjs.getComponent "exe:private-ghcjs-hsc2hs")
3333
(ghcjs.getComponent "exe:haddock")
34+
(ghcjs.getComponent "exe:ghcjs-dumparchive")
3435
(ghcjs.getComponent "exe:private-ghcjs-run")
3536
(ghcjs.getComponent "exe:private-ghcjs-unlit")
36-
(ghcjs.getComponent "exe:private-ghcjs-hsc2hs")
3737
]
3838
else [
39-
(ghcjs.getComponent "exe:haddock-ghcjs")
40-
(ghcjs.getComponent "exe:hsc2hs-ghcjs")
41-
(ghcjs.getComponent "exe:ghcjs-run")
39+
(ghcjs.getComponent "exe:private-ghcjs-ghcjs")
40+
(ghcjs.getComponent "exe:private-ghcjs-ghcjs-pkg")
41+
(ghcjs.getComponent "exe:private-ghcjs-run")
42+
(ghcjs.getComponent "exe:private-ghcjs-unlit")
43+
(ghcjs.getComponent "exe:private-ghcjs-hsc2hs")
44+
(ghcjs.getComponent "exe:private-ghcjs-haddock")
45+
(ghcjs.getComponent "exe:private-ghcjs-ghcjs-dumparchive")
4246
]);
4347
};
4448
libexec = "libexec/${builtins.replaceStrings ["darwin" "i686"] ["osx" "i386"] pkgs.stdenv.buildPlatform.system}-${ghc.name}/ghcjs-${ghcVersion}";
@@ -77,13 +81,17 @@ let
7781
wrapProgram $out/bin/ghcjs-pkg --add-flags "--global-package-db=$out/lib/package.conf.d"
7882
''
7983
else ''
80-
mkdir -p $out/bin
84+
mkdir -p $out
85+
lndir ${all-ghcjs} $out
8186
mkdir -p $out/lib/ghcjs-${ghcVersion}
82-
lndir ${all-ghcjs}/${libexec} $out/bin
87+
rm $out/bin/ghcjs-boot
88+
cp ${ghcjs.getComponent "exe:ghcjs-boot"}/bin/ghcjs-boot $out/bin
89+
wrapProgram $out/bin/ghcjs-boot --set ghcjs_libexecdir $out/bin
90+
mv $out/${libexec}/* $out/bin
8391
84-
wrapProgram $out/bin/ghcjs --add-flags "-B$out/lib/ghcjs-${ghcVersion}"
85-
wrapProgram $out/bin/haddock-ghcjs --add-flags "-B$out/lib/ghcjs-${ghcVersion}"
86-
wrapProgram $out/bin/ghcjs-pkg --add-flags "--global-package-db=$out/lib/ghcjs-${ghcVersion}/package.conf.d"
92+
wrapProgram $out/bin/private-ghcjs-ghcjs --add-flags "-B$out/lib"
93+
wrapProgram $out/bin/private-ghcjs-haddock --add-flags "-B$out/lib"
94+
wrapProgram $out/bin/private-ghcjs-ghcjs-pkg --add-flags "--global-package-db=$out/lib/package.conf.d"
8795
''
8896
}
8997
# Avoid timeouts while unix package runs hsc2hs (it does not print anything
@@ -101,12 +109,12 @@ let
101109
# Unsets NIX_CFLAGS_COMPILE so the osx version of iconv.h is not used by mistake
102110
''
103111
env -u NIX_CFLAGS_COMPILE PATH=$out/bin:$PATH \
104-
PYTHON=${pkgs.buildPackages.python3}/bin/python3 \
105112
$out/bin/ghcjs-boot -j1 --with-emsdk=${project.emsdk} --no-prof --no-haddock \
106113
|| (echo failed > $TMP/done; false)
107114
''
108115
else ''
109-
env PATH=$out/bin:$PATH $out/bin/ghcjs-boot -j1 --with-ghcjs-bin $out/bin \
116+
env -u NIX_CFLAGS_COMPILE PATH=$out/bin:$PATH \
117+
$out/bin/ghcjs-boot -j1 --with-ghcjs-libdir=$out --with-emsdk=${project.emsdk} \
110118
|| (echo failed > $TMP/done; false)
111119
''
112120
}

compiler/ghcjs/ghcjs88-src.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"url": "https://github.com/ghcjs/ghcjs",
3-
"rev": "23e75593937dc15eaee73bed1443450fc68bd277",
4-
"sha256": "1cj4q2rx3xs8zfkpjjwfdfadidg0wgn3qisffiikxmgf41b4a760",
3+
"rev": "1af48a877fdf1f647a3b81e828a1e61adb0baceb",
4+
"sha256": "sha256-B4LFpd1nl96SO6/gsTjkizMGSglMkrujmwgXVjahC68=",
55
"fetchSubmodules": true
66
}

docs/reference/commands.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# stack-to-nix
1+
# Command line tools
2+
3+
To install the command line tools refer to the [Installing nix-tools](https://input-output-hk.github.io/haskell.nix/dev/manually-generating-nix-expressions/) section.
4+
5+
## stack-to-nix
26

37
```
48
stack-to-nix - a stack to nix converter
@@ -28,7 +32,7 @@ output directory, it will create a basic one with a
2832

2933
[cache-issue]: https://github.com/input-output-hk/haskell.nix/issues/57
3034

31-
# plan-to-nix
35+
## plan-to-nix
3236

3337
```
3438
plan-to-nix - a stack to nix converter
@@ -65,7 +69,7 @@ these files.
6569
generated, remove `.nix-tools.cache`
6670
(The open issue is [#57][cache-issue]).
6771

68-
# cabal-to-nix
72+
## cabal-to-nix
6973

7074
```
7175
Usage: cabal-to-nix FILE.cabal

docs/tutorials/development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ themselves. This is what the [`shellFor`][shellFor] function does.
3737
{ pkgs ? import <nixpkgs> {} }:
3838
3939
let
40-
hsPkgs = import ./default.nix { inherit pkgs; };
40+
hsPkgs = import ./default.nix { };
4141
in
4242
hsPkgs.shellFor {
4343
# Include only the *local* packages of your project.

0 commit comments

Comments
 (0)