Skip to content

Commit 9caf1cd

Browse files
authored
Merge branch 'master' into support-cabal-doctest
2 parents c3e883c + 49cbd34 commit 9caf1cd

File tree

166 files changed

+15254
-411
lines changed

Some content is hidden

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

166 files changed

+15254
-411
lines changed

build.nix

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ let
1616
in rec {
1717
tests = import ./test/default.nix { inherit pkgs ifdLevel; };
1818

19+
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3)
20+
(pkgs.recurseIntoAttrs
21+
(pkgs.lib.mapAttrs (_: ghc:
22+
let
23+
tool = name: version: pkgs.buildPackages.haskell-nix.tool name { inherit version ghc; };
24+
in pkgs.recurseIntoAttrs {
25+
cabal-32 = tool "cabal" "3.2.0.0";
26+
ghcide = tool "ghcide" "object-code";
27+
} // pkgs.lib.optionalAttrs (ghc.version == "8.6.5") {
28+
cabal-30 = tool "cabal" "3.0.0.0";
29+
}) { inherit (pkgs.buildPackages.haskell-nix.compiler) ghc865 ghc883; }));
30+
1931
# Scripts for keeping Hackage and Stackage up to date, and CI tasks.
2032
# The dontRecurseIntoAttrs prevents these from building on hydra
2133
# as not all of them can work in restricted eval mode (as they
@@ -25,12 +37,7 @@ in rec {
2537
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {};
2638
update-pins = haskell.callPackage ./scripts/update-pins.nix {};
2739
update-docs = pkgs.buildPackages.callPackage ./scripts/update-docs.nix {
28-
generatedOptions = import ./scripts/options-doc.nix {
29-
# nixpkgs 19.09 changes "Option has no description" from an
30-
# error into a warning. That is quite helpful when hardly any
31-
# of our options are documented, thanks @oxij.
32-
pkgs = import (import ./nixpkgs/default.nix).nixpkgs-1909 {};
33-
};
40+
generatedOptions = pkgs.callPackage ./scripts/options-doc.nix { };
3441
};
3542
# Because this is going to be used to test caching on hydra, it must not
3643
# use the darcs package from the haskell.nix we are testing. For that reason

builder/default.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ let
3939

4040

4141
hoogleLocal = let
42-
# Use the latest default nixpkgs hoogle.nix, as the 19.03 one does not work with cross compilers
43-
nixpkgsHoogleLocal = import ((import (import ../nixpkgs).nixpkgs-default {}).path + /pkgs/development/haskell-modules/hoogle.nix);
42+
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
4443
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.haskellPackages.hoogle.components.exes.hoogle }:
45-
haskellLib.weakCallPackage pkgs nixpkgsHoogleLocal {
44+
haskellLib.weakCallPackage pkgs nixpkgsHoogle {
4645
# For musl we can use haddock from the buildGHC
4746
ghc = if stdenv.hostPlatform.isLinux && stdenv.targetPlatform.isMusl
4847
then ghc.buildGHC
@@ -52,8 +51,9 @@ let
5251

5352
# Same as haskellPackages.shellFor in nixpkgs.
5453
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
55-
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
54+
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib buildPackages;
5655
inherit (buildPackages) glibcLocales;
56+
buildGHC = ghc.passthru.buildGHC or ghc;
5757
};
5858

5959
# Same as haskellPackages.ghcWithPackages and ghcWithHoogle in nixpkgs.

builder/make-config-files.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,5 @@ in { identifier, component, fullName, flags ? {} }:
179179
sed -i -E "/^ ./{H;$!d} ; x ; s,^dynamic-library-dirs:.*,dynamic-library-dirs: $dynamicLinksDir," $f
180180
done
181181
'' + ''
182-
# Use ''${pkgroot} relative paths so that we can relocate the package database
183-
# along with referenced packages and still have it work on systems with
184-
# or without nix installed.
185-
sed -i 's|/nix/store/|''${pkgroot}/../../../|' $out/${packageCfgDir}/*.conf
186182
${target-pkg} -v0 --package-db $out/${packageCfgDir} recache
187183
'')

builder/shell-for.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:
1+
{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, buildGHC }:
22

33
{ packages ? ps:
44
let
@@ -9,6 +9,7 @@
99
, additional ? _: []
1010
, withHoogle ? true
1111
, exactDeps ? false
12+
, tools ? {}
1213
, ... } @ args:
1314

1415
let
@@ -74,7 +75,7 @@ let
7475
# inherit (hsPkgs) hoogle;
7576
};
7677

77-
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle"];
78+
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools"];
7879
in
7980
stdenv.mkDerivation (mkDrvArgs // {
8081
name = mkDrvArgs.name or name;
@@ -84,12 +85,17 @@ in
8485
++ lib.optional withHoogle' hoogleIndex;
8586
nativeBuildInputs = [ ghcEnv ]
8687
++ nativeBuildInputs
87-
++ mkDrvArgs.nativeBuildInputs or [];
88+
++ mkDrvArgs.nativeBuildInputs or []
89+
++ lib.attrValues (buildPackages.haskell-nix.toolsForGhc buildGHC tools);
8890
phases = ["installPhase"];
8991
installPhase = "echo $nativeBuildInputs $buildInputs > $out";
9092
LANG = "en_US.UTF-8";
9193
LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";
9294

95+
# This helps tools like `ghcide` (that use the ghc api) to find
96+
# the correct global package DB.
97+
NIX_GHC_LIBDIR = ghcEnv + "/" + configFiles.libDir;
98+
9399
passthru = (mkDrvArgs.passthru or {}) // {
94100
ghc = ghcEnv;
95101
inherit configFiles;

ci-lib.nix

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ in rec {
3030
# TODO: Surely this shouldn't be necessary. I think normal 'filterAttrsRecursive' will effectively cause infinite loops
3131
# if you keep derivations and your predicate forces the value of the attribute, as this then triggers a loop on the
3232
# 'out' attribute. Weird.
33+
# To make this function faster, unwanted attributes are mapped to {} instead of being
34+
# removed. This keeps the function lazy and avoids unwanted evaluation of sibling
35+
# derivations.
3336
filterAttrsOnlyRecursive = pred: set:
34-
lib.listToAttrs (
35-
lib.concatMap (name:
36-
let v = set.${name}; in
37-
if pred name v then [
38-
(lib.nameValuePair name (
39-
if builtins.isAttrs v && !lib.isDerivation v then filterAttrsOnlyRecursive pred v
37+
lib.mapAttrs (name: v:
38+
if pred name v
39+
then
40+
if builtins.isAttrs v
41+
&& !lib.isDerivation v
42+
then filterAttrsOnlyRecursive pred v
4043
else v
41-
))
42-
] else []
43-
) (builtins.attrNames set)
44-
);
44+
else {}) set;
4545
}

ci.nix

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ let
88
inherit (import ./ci-lib.nix) dimension platformFilterGeneric filterAttrsOnlyRecursive;
99
inherit (import ./default.nix {}) sources nixpkgsArgs;
1010
nixpkgsVersions = {
11-
"R1903" = "nixpkgs-1903";
1211
"R1909" = "nixpkgs-1909";
12+
"R2003" = "nixpkgs-2003";
1313
};
1414
systems = nixpkgs: nixpkgs.lib.filterAttrs (_: v: builtins.elem v supportedSystems) {
1515
# I wanted to take these from 'lib.systems.examples', but apparently there isn't one for linux!
@@ -20,8 +20,8 @@ let
2020
# We need to use the actual nixpkgs version we're working with here, since the values
2121
# of 'lib.systems.examples' are not understood between all versions
2222
let lib = nixpkgs.lib;
23-
in lib.optionalAttrs (system == "x86_64-linux" || nixpkgsName == "R1903") {
24-
# Windows cross compilation is currently broken on macOS for nixpkgs 19.09 (works on 19.03)
23+
in lib.optionalAttrs (system == "x86_64-linux") {
24+
# Windows cross compilation is currently broken on macOS
2525
inherit (lib.systems.examples) mingwW64;
2626
} // lib.optionalAttrs (system == "x86_64-linux") {
2727
# Musl cross only works on linux
@@ -37,29 +37,50 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
3737
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; });
3838
build = import ./build.nix { inherit pkgs ifdLevel; };
3939
platformFilter = platformFilterGeneric pkgs system;
40+
compilers = {
41+
inherit (pkgs.haskell-nix.compiler) ghc865 ghc883;
42+
};
4043
in filterAttrsOnlyRecursive (_: v: platformFilter v) {
4144
# Native builds
4245
# TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
43-
native = pkgs.recurseIntoAttrs {
44-
inherit (build) tests maintainer-scripts maintainer-script-cache;
46+
native = pkgs.recurseIntoAttrs ({
47+
inherit (build) tests tools maintainer-scripts maintainer-script-cache;
48+
ghc = pkgs.recurseIntoAttrs compilers;
49+
} // pkgs.lib.optionalAttrs (ifdLevel >= 1) {
50+
iserv-proxy = pkgs.recurseIntoAttrs (
51+
pkgs.lib.mapAttrs (ghcName: _:
52+
pkgs.ghc-extra-packages."${ghcName}".iserv-proxy.components.exes.iserv-proxy
53+
) compilers);
54+
} // pkgs.lib.optionalAttrs (ifdLevel >= 2) {
4555
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; }).components.exes.hello;
46-
iserv-proxy = pkgs.ghc-extra-packages.ghc865.iserv-proxy.components.exes.iserv-proxy;
47-
ghc = pkgs.recurseIntoAttrs pkgs.haskell-nix.compiler;
48-
};
56+
});
4957
}
5058
//
5159
dimension "Cross system" (crossSystems nixpkgsName genericPkgs system) (crossSystemName: crossSystem:
5260
# Cross builds
5361
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
5462
build = import ./build.nix { inherit pkgs ifdLevel; };
55-
in pkgs.recurseIntoAttrs {
63+
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) {
64+
ghc = pkgs.recurseIntoAttrs compilers;
65+
# TODO: look into making tools work when cross compiling
66+
# inherit (build) tools;
67+
} // pkgs.lib.optionalAttrs (ifdLevel >= 2) {
68+
remote-iserv = pkgs.recurseIntoAttrs (
69+
pkgs.lib.mapAttrs (ghcName: _:
70+
pkgs.ghc-extra-packages."${ghcName}".remote-iserv.components.exes.remote-iserv
71+
) compilers);
72+
iserv-proxy = pkgs.recurseIntoAttrs (
73+
pkgs.lib.mapAttrs (ghcName: _:
74+
pkgs.ghc-extra-packages."${ghcName}".iserv-proxy.components.exes.iserv-proxy
75+
) compilers);
76+
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
5677
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; }).components.exes.hello;
57-
iserv-proxy = pkgs.ghc-extra-packages.ghc865.iserv-proxy.components.exes.iserv-proxy;
58-
remote-iserv = pkgs.ghc-extra-packages.ghc865.remote-iserv.components.exes.remote-iserv;
5978
}
6079
//
6180
# Tests are broken on aarch64 cross https://github.com/input-output-hk/haskell.nix/issues/513
62-
pkgs.lib.optionalAttrs (crossSystemName != "aarch64-multiplatform") build.tests
81+
pkgs.lib.optionalAttrs (crossSystemName != "aarch64-multiplatform") {
82+
inherit (build) tests;
83+
})
6384
)
6485
)
6586
)

compiler/ghc/default.nix

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,7 @@
4242
# specific flavour and falls back to ghc default values.
4343
ghcFlavour ? stdenv.lib.optionalString haskell-nix.haskellLib.isCrossTarget (
4444
if useLLVM
45-
then (
46-
# TODO check if the issues with qemu and Aarch32 persist. See
47-
# https://github.com/input-output-hk/haskell.nix/pull/411/commits/1986264683067198e7fdc1d665351622b664712e
48-
if stdenv.targetPlatform.isAarch32
49-
then "quick-cross"
50-
else "perf-cross"
51-
)
45+
then "perf-cross"
5246
else "perf-cross-ncg"
5347
)
5448

@@ -104,9 +98,6 @@ let
10498
GhcRtsHcOpts += -fPIC
10599
'' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
106100
EXTRA_CC_OPTS += -std=gnu99
107-
'' + stdenv.lib.optionalString useLLVM ''
108-
GhcStage2HcOpts += -fast-llvm
109-
GhcLibHcOpts += -fast-llvm
110101
'' + stdenv.lib.optionalString (!enableTerminfo) ''
111102
WITH_TERMINFO=NO
112103
''
@@ -218,13 +209,13 @@ in let configured-src = stdenv.mkDerivation (rec {
218209
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
219210
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
220211
"--enable-bootstrap-with-devel-snapshot"
212+
] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
213+
"--disable-large-address-space"
221214
] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [
222215
"CFLAGS=-fuse-ld=gold"
223216
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
224217
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
225-
] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
226-
"--disable-large-address-space"
227-
];
218+
] ;
228219

229220
outputs = [ "out" ];
230221
phases = [ "unpackPhase" "patchPhase" ]

config.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
wine.build = "wine64";
77
wine.release = "stable";
88

9+
# This is marked insecure on 20.03, but many packages still depend on it
10+
permittedInsecurePackages = [ "openssl-1.0.2u" ];
11+
912
# sadly we need to patch GHC a bit.
1013
packageOverrides = ps: with ps; let
1114
in rec {

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let haskellNix = rec {
22
sources = {
3-
inherit (import ./nixpkgs/default.nix) nixpkgs-1903 nixpkgs-1909 nixpkgs-default;
3+
inherit (import ./nixpkgs/default.nix) nixpkgs-1909 nixpkgs-2003 nixpkgs-default;
44
};
55

66
config = import ./config.nix;

docs/reference/library.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,11 @@ shellFor =
366366
| Argument | Type | Description |
367367
|----------------|------|---------------------|
368368
| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
369-
| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
370-
| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
371-
| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
369+
| `additional` | Function | Similar to `packages`, but the selected packages are built and included in `ghc-pkg list` (not just their dependencies). |
370+
| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
371+
| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
372+
| `tools` | Function | AttrSet of tools to make available e.g. `{ cabal = "3.2.0.0"; }` or `{ cabal = { version = "3.2.0.0"; }; }` |
373+
| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
372374

373375
**Return value**: a derivation
374376

0 commit comments

Comments
 (0)