Skip to content

Commit 1d8a687

Browse files
committed
Merge master into support-cabal-doctest
2 parents c7ba0f9 + d3511cd commit 1d8a687

Some content is hidden

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

41 files changed

+732
-556
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ tags
9999

100100

101101
# End of https://www.gitignore.io/api/haskell,emacs,vim
102+
nix-tools-src-new.json

bors.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
status = [
2+
"buildkite/haskell-dot-nix",
3+
"ci/hydra:Cardano:haskell-nix:required",
4+
]
5+
timeout_sec = 7200
6+
required_approvals = 1
7+
block_labels = [ "WIP", "DO NOT MERGE" ]
8+
delete_merged_branches = true

builder/comp-builder.nix

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, buildPackages, ghc, lib, pkgconfig, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
1+
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, nodejs }:
22

33
{ allComponent
44
, componentId
@@ -81,7 +81,7 @@ let
8181
"--with-ghc=${ghc.targetPrefix}ghc"
8282
"--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
8383
"--with-hsc2hs=${ghc.targetPrefix}hsc2hs"
84-
] ++ lib.optionals (stdenv.cc != null)
84+
] ++ lib.optionals (stdenv.hasCC or (stdenv.cc != null))
8585
( # CC
8686
[ "--with-gcc=${stdenv.cc.targetPrefix}cc"
8787
] ++
@@ -132,7 +132,7 @@ let
132132
(lib.concatMap (c: if c.isHaskell or false
133133
then builtins.attrValues (c.components.exes or {})
134134
else [c]) component.build-tools) ++
135-
lib.optional (component.pkgconfig != []) pkgconfig;
135+
lib.optional (component.pkgconfig != []) buildPackages.pkgconfig;
136136

137137
# Unfortunately, we need to wrap ghc commands for cabal builds to
138138
# work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
@@ -153,7 +153,8 @@ let
153153
&& (haskellLib.isLibrary componentId)
154154
&& !haskellLib.isCrossHost;
155155

156-
exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
156+
exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
157+
if stdenv.hostPlatform.isWindows then ".exe" else "";
157158
exeName = componentId.cname + exeExt;
158159
testExecutable = "dist/build/${componentId.cname}/${exeName}";
159160

@@ -325,7 +326,13 @@ stdenv.mkDerivation ({
325326
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
326327
mkdir -p $out/bin
327328
if [ -f ${testExecutable} ]; then
328-
cp ${testExecutable} $out/bin/
329+
mkdir -p $(dirname $out/bin/${exeName})
330+
${if stdenv.hostPlatform.isGhcjs then ''
331+
cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
332+
chmod +x $out/bin/${exeName}
333+
'' else ''
334+
cp -r ${testExecutable} $(dirname $out/bin/${exeName})
335+
''}
329336
fi
330337
'')
331338
# In case `setup copy` did not creat this

ci.nix

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,42 @@
33
# - https://github.com/NixOS/nixpkgs/pull/68398
44

55
let
6+
inherit (import ./dimension.nix) dimension;
67
nixpkgsVersions = {
78
# "release-18.09" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/7e4dcacbf066a8e2d12693a9de1fb30c77081c5d.tar.gz";
89
"release-19.03" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/a8f81dc037a5977414a356dd068f2621b3c89b60.tar.gz";
910
# "release-19.09" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/3d623a406cec9052ae0a16a79ce3ce9de11236bb.tar.gz";
1011
};
12+
systems = {
13+
"x86_64-linux" = {};
14+
};
15+
crossSystems = {
16+
"x86_64-pc-mingw32" = {};
17+
};
1118
haskellNixArgs = import ./.;
12-
defaultNixpkgs = import (nixpkgsVersions."release-19.03") {};
13-
recRecurseIntoAttrs = with defaultNixpkgs; pred: x: if pred x then recurseIntoAttrs (lib.mapAttrs (n: v: if n == "buildPackages" then v else recRecurseIntoAttrs pred v) x) else x;
1419
in
15-
recRecurseIntoAttrs (x: with defaultNixpkgs; lib.isAttrs x && !lib.isDerivation x) (
16-
builtins.mapAttrs (nixpkgsName: nixpkgsSrc: with (import nixpkgsSrc {}); {
17-
x86_64-linux = {
18-
hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
19-
(haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
20-
x86_64-pc-mingw32-hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
21-
(haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
22-
23-
iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
24-
(ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
25-
26-
x86_64-pc-mingw32-iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
27-
(buildPackages.ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
28-
29-
x86_64-pc-mingw32-remote-iserv = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
30-
(ghc-extra-packages.ghc865.remote-iserv.components.exes).remote-iserv;
31-
32-
};
33-
x86_64-darwin = {
34-
hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
35-
(haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
36-
x86_64-pc-mingw32-hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
37-
(haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
38-
39-
iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
40-
(ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
41-
42-
x86_64-pc-mingw32-iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
43-
(buildPackages.ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
44-
45-
x86_64-pc-mingw32-remote-iserv = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
46-
(ghc-extra-packages.ghc865.remote-iserv.components.exes).remote-iserv;
47-
48-
};
49-
haskell-nix.compiler = {
50-
x86_64-linux = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
51-
haskell-nix.compiler;
52-
x86_64-darwin = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin";}));
53-
haskell-nix.compiler;
54-
};
55-
tests = {
56-
x86_64-linux = (import ./test { nixpkgs = nixpkgsSrc; nixpkgsArgs = { system = "x86_64-linux"; }; });
57-
# x86_64-darwin = (import ./test { nixpkgs = nixpkgsSrc; nixpkgsArgs = { system = "x86_64-darwin"; }; });
58-
};
59-
60-
# Don't build (all of) stackage on linux for now.
61-
# stackage = {
62-
# x86_64-linux = (with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
63-
# haskell-nix.snapshots."lts-13.29");
64-
# # x86_64-darwin = (with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
65-
# # haskell-nix.snapshots."lts-13.29");
66-
# };
67-
68-
}) nixpkgsVersions)
20+
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgsSrc:
21+
dimension "System" systems (system: _:
22+
# Native builds
23+
# TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
24+
let pkgs = import nixpkgsSrc (haskellNixArgs // { inherit system; });
25+
in pkgs.recurseIntoAttrs {
26+
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
27+
iserv-proxy = pkgs.ghc-extra-packages.ghc865.iserv-proxy.components.exes.iserv-proxy;
28+
ghc = pkgs.recurseIntoAttrs pkgs.haskell-nix.compiler;
29+
tests = pkgs.lib.optionalAttrs (system == "x86_64-linux") (import ./test { inherit pkgs; });
30+
}
31+
//
32+
dimension "Cross system" crossSystems (crossSystem: _:
33+
# Cross builds
34+
let pkgs = import nixpkgsSrc (haskellNixArgs // { inherit system; crossSystem.config = crossSystem; });
35+
in pkgs.recurseIntoAttrs {
36+
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
37+
38+
iserv-proxy = pkgs.ghc-extra-packages.ghc865.iserv-proxy.components.exes.iserv-proxy;
39+
40+
remote-iserv = pkgs.ghc-extra-packages.ghc865.remote-iserv.components.exes.remote-iserv;
41+
}
42+
)
43+
)
44+
)

compiler/old-ghc-nix/old-ghc-nix.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"url": "https://github.com/angerman/old-ghc-nix",
3-
"rev": "ee5e7181f681522f075e01a1875228188b03cc8c",
4-
"date": "2019-12-08T20:24:29+08:00",
5-
"sha256": "0ywvyjvyw9vm0qbf0a7k6zpsrzcz5wa7y16rfcs3wfv36plj3qd5",
3+
"rev": "bf640c1a3f55203bb7492a366c6492ff3c211332",
4+
"date": "2020-02-27T19:53:36+08:00",
5+
"sha256": "050g06911rpmvn66y5lmnszswz17flw3b979imdchc2apji6a1sm",
66
"fetchSubmodules": false
77
}

dimension.nix

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Borrowed from https://github.com/cachix/ghcide-nix/pull/4/files#diff-70bfff902f4dec33e545cac10ee5844d
2+
# Tweaked to use builtins.mapAttrs instead of needing the one from nixpkgs lib
3+
{
4+
/*
5+
dimension: name -> attrs -> function -> attrs
6+
where
7+
function: keyText -> value -> attrsOf package
8+
9+
WARNING: Attribute names must not contain periods (".").
10+
See https://github.com/NixOS/nix/issues/3088
11+
12+
NOTE: The dimension name will be picked up by agent and web ui soon.
13+
14+
Specifies a dimension of the build matrix. For example
15+
16+
dimension "Example" {
17+
withP = { p = true; }
18+
withoutP = { p = false; }
19+
} (key: # either "withP" or "withoutP"
20+
{ p }: # either p = true or p = false
21+
myProject p
22+
)
23+
24+
evaluates roughly to
25+
26+
{
27+
withP = myProject true;
28+
withoutP = myProject false;
29+
}
30+
31+
Use nested calls for multiple dimensions.
32+
33+
Example:
34+
35+
dimension "System" {
36+
"x86_64-linux" = {};
37+
# ...
38+
}: (system: {}:
39+
40+
dimension "Nixpkgs release" (
41+
{
42+
"nixpkgs-19_03".nixpkgs = someSource
43+
} // optionalAttrs (system != "...") {
44+
"nixpkgs-unstable".nixpkgs = someOtherSource
45+
}
46+
) (_key: { nixpkgs }:
47+
48+
myProject system nixpkgs
49+
50+
)
51+
)
52+
53+
evaluates roughly to
54+
55+
{
56+
x86_64-linux.nixpkgs-19_03 = myProject "x86_64-linux" someSource;
57+
x86_64-linux.nixpkgs-unstable = myProject "x86_64-linux" someOtherSource;
58+
...
59+
}
60+
61+
If you need to make references across attributes, you can do so by binding
62+
the result. Wherever you write
63+
64+
dimension "My dimension" {} (key: value: f1 key value)
65+
66+
You can also write
67+
68+
let
69+
myDimension = dimension "My dimension" {} (key: value: f2 key value myDimension)
70+
in
71+
myDimension
72+
73+
This example builds a single test runner to reuse across releases:
74+
75+
let
76+
overlay =
77+
testRunnerPkgs: self: super: {
78+
# ...
79+
};
80+
myProject =
81+
{ nixpkgs,
82+
pkgs ? import nixpkgs { overlays = [ overlay ]; },
83+
testRunnerPkgs ? pkgs
84+
}: pkgs;
85+
in
86+
87+
let
88+
latest = "nixpkgs-19_03";
89+
releases =
90+
dimension "Nixpkgs release"
91+
{
92+
nixpkgs-18_09.nixpkgs = someSource
93+
nixpkgs-19_03.nixpkgs = someOtherSource
94+
}
95+
(_key: { nixpkgs }:
96+
97+
myProject {
98+
inherit nixpkgs;
99+
testRunnerPkgs = releases."${latest}";
100+
}
101+
102+
);
103+
in releases;
104+
105+
*/
106+
dimension = name: attrs: f:
107+
builtins.mapAttrs
108+
(k: v:
109+
let o = f k v;
110+
in o // { recurseForDerivations = o.recurseForDerivations or true; }
111+
)
112+
attrs
113+
// { meta.dimension.name = name; };
114+
}

docs/reference/library.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Assorted functions for operating on [Haskell.nix][] data. This is
281281
distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
282282
Infrastructure.
283283

284-
### collectComponents and collectComponents'
284+
### collectComponents, collectComponents'
285285

286286
Extracts a selection of components from a Haskell [package set](#package-set).
287287

@@ -316,6 +316,12 @@ tests = collectComponents "tests" (package: package.identifier.name == "mypackag
316316
Will result in moving derivations from `hsPkgs.mypackage.components.tests.unit-tests`
317317
to `tests.mypackage.unit-tests`.
318318

319+
### collectChecks, collectChecks'
320+
321+
These are just like `collectComponents` and `collectComponents'`, except that they collect
322+
the `checks` attributes of packages (which aren't components, and so can't be collected
323+
by the other functions.
324+
319325
#### check
320326

321327
This function turns a derivation that builds a test into one to run it.

hackage-src.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"url": "https://github.com/input-output-hk/hackage.nix",
3-
"rev": "18646b3296a596d712c4af6dd2b04de0e947cbbe",
4-
"date": "2020-03-04T01:10:41+00:00",
5-
"sha256": "11wlnjb4lcrnf4zkswincdbw41lry2gr3hmzb93pqdnv335vyfzx",
3+
"rev": "ca13a1a4b29d23a2ca159cfe72fbd591fb91e3bd",
4+
"date": "2020-03-21T01:14:31+00:00",
5+
"sha256": "1jqsaagc8hypam1vcbylrpn150dnmxr7rg6wbz7as4lnb0jp6q2q",
66
"fetchSubmodules": false
77
}

lib/cabal-licenses.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ lib: with lib.licenses;
44
MIT = mit;
55
"MPL-2.0" = mpl20;
66
ISC = isc;
7-
"LGPL-2.1-only" = lgpl21;
8-
"LGPL-3.0-only" = lgpl3;
9-
"GPL-2.0-only" = gpl2;
10-
"GPL-3.0-only" = gpl3;
11-
"Apache-2.0" = asl20;
7+
"LGPL-2.1-only" = lgpl21;
8+
"LGPL-3.0-only" = lgpl3;
9+
"GPL-2.0-only" = gpl2;
10+
"GPL-3.0-only" = gpl3;
11+
"AGPL-3.0-only" = agpl3;
12+
"AGPL-3.0-or-later" = agpl3Plus;
13+
"Apache-2.0" = asl20;
1214
# Generic
1315
LicenseRef-Apache = "Apache";
1416
LicenseRef-GPL = "GPL";

lib/default.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, lib, haskellLib, runCommand, git, srcOnly }:
1+
{ stdenv, lib, haskellLib, runCommand, git, recurseIntoAttrs, srcOnly }:
22

33
with haskellLib;
44

@@ -157,12 +157,12 @@ with haskellLib;
157157
# set recurseForDerivations unless it's a derivation itself (e.g. the "library" component) or an empty set
158158
in if lib.isDerivation components || components == {}
159159
then components
160-
else pkgs.recurseIntoAttrs components;
160+
else recurseIntoAttrs components;
161161
packageFilter = name: package: (package.isHaskell or false) && packageSel package;
162162
filteredPkgs = lib.filterAttrs packageFilter haskellPackages;
163163
# at this point we can filter out packages that don't have any of the given kind of component
164164
packagesByComponent = lib.filterAttrs (_: components: components != {}) (lib.mapAttrs packageToComponents filteredPkgs);
165-
in pkgs.recurseIntoAttrs packagesByComponent;
165+
in recurseIntoAttrs packagesByComponent;
166166

167167
# Equivalent to collectComponents with (_: true) as selection function.
168168
# Useful for pre-filtered package-set.
@@ -173,6 +173,17 @@ with haskellLib;
173173
# myTests = collectComponents' "tests" myHaskellPackages;
174174
collectComponents' = group: collectComponents group (_: true);
175175

176+
# Extracts a selection of 'checks' from a Haskell package set.
177+
#
178+
# This can be used to collect all the test runs in your project, so that can be run in CI.
179+
collectChecks = packageSel: haskellPackages:
180+
let packageFilter = name: package: (package.isHaskell or false) && packageSel package;
181+
in recurseIntoAttrs (lib.mapAttrs (_: p: p.checks) (lib.filterAttrs packageFilter haskellPackages));
182+
183+
# Equivalent to collectChecks with (_: true) as selection function.
184+
# Useful for pre-filtered package-set.
185+
collectChecks' = collectChecks (_: true);
186+
176187
# Replacement for lib.cleanSourceWith that has a subDir argument.
177188
inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
178189

lib/system-nixpkgs-map.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ pkgs:
7272
boost_wserialization = pkgs.boost;
7373
tensorflow = pkgs.libtensorflow;
7474
opencv = pkgs.opencv3;
75+
icuuc = pkgs.icu;
76+
icui18n = pkgs.icu;
77+
icudata = pkgs.icu;
7578
}
7679
# -- windows
7780
// { advapi32 = null; gdi32 = null; imm32 = null; msimg32 = null;

modules/plan.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let
153153
};
154154

155155
profilingDetail = mkOption {
156-
type = nullOr str;
156+
type = nullOr uniqueStr;
157157
default = (def.profilingDetail or "exported-functions");
158158
};
159159

0 commit comments

Comments
 (0)