Skip to content

Commit 52401d7

Browse files
authored
Fix quirks with overlays/hackage-default-args.nix (#564)
Adds a place for fixes to common problems that arise when using `hackage-project` and `hackage-package`.
1 parent 2cfba02 commit 52401d7

File tree

4 files changed

+64
-24
lines changed

4 files changed

+64
-24
lines changed

overlays/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#(import ./ghcjs-asterius-triple.nix)
77
#(import ./python.nix)
88
(import ./haskell.nix)
9+
(import ./hackage-quirks.nix)
910
(import ./bootstrap.nix)
1011
(import ./ghc.nix)
1112
(import ./ghc-packages.nix)

overlays/hackage-quirks.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This overlay adds hackageQuirks to provide suitable default
2+
# arguments for `haskell-nix.hackage-project` and the functions
3+
# that use it (like `hackage-package`)
4+
#
5+
self: super:
6+
let
7+
inherit (self) lib;
8+
9+
in { haskell-nix = super.haskell-nix // {
10+
11+
hackageQuirks = { name, version }: {
12+
# FIXME: this is required to build cabal-install 3.2 with ghc 8.6,
13+
# but also for
14+
# https://github.com/input-output-hk/haskell.nix/issues/422
15+
cabal-install = {
16+
modules = [ { reinstallableLibGhc = true; } ];
17+
};
18+
19+
hlint = {
20+
modules = [ { reinstallableLibGhc = true; } ];
21+
pkg-def-extras = [
22+
(hackage: {
23+
packages = {
24+
"alex" = (((hackage.alex)."3.2.5").revisions).default;
25+
};
26+
})
27+
];
28+
};
29+
30+
pandoc = {
31+
# Function that returns a sha256 string by looking up the location
32+
# and tag in a nested attrset
33+
lookupSha256 = { location, tag, ... }:
34+
{ "https://github.com/jgm/pandoc-citeproc"."0.17"
35+
= "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; }
36+
."${location}"."${tag}";
37+
modules = [
38+
# Windows characters confuse cross compilation
39+
# See https://github.com/snoyberg/file-embed/pull/33
40+
(lib.optionalAttrs (version == "2.9.2.1") {
41+
packages.file-embed.src = self.fetchgit {
42+
url = "https://github.com/hamishmack/file-embed.git";
43+
rev = "12b33b8b710517308954c1facff3dc679c2dc5e3";
44+
sha256 = "0jcpja4s4cylmg9rddyakb1p1fb4l41ffwmy0njpb1dxc5z3v618";
45+
};
46+
})
47+
# Musl needs static zlib
48+
(lib.optionalAttrs self.stdenv.hostPlatform.isMusl {
49+
packages.pandoc.components.exes.pandoc.configureFlags = [
50+
"--ghc-option=-optl=-L${self.zlib.static}/lib"
51+
];
52+
})
53+
];
54+
};
55+
56+
}."${name}" or {};
57+
58+
}; }

overlays/haskell.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,9 @@ self: super: {
414414
tar xzf ${tarball}
415415
mv "${name}-${version}" $out
416416
'';
417-
in cabalProject' (builtins.removeAttrs args [ "version" ] // { inherit src; });
417+
in cabalProject' (
418+
(self.haskell-nix.hackageQuirks { inherit name version; }) //
419+
builtins.removeAttrs args [ "version" ] // { inherit src; });
418420

419421
# This function is like `cabalProject` but it makes the plan-nix available
420422
# separately from the hsPkgs. The advantage is that the you can get the

test/lookup-sha256/default.nix

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{ pkgs, lib, stdenv, haskell-nix, testSrc, zlib } :
2-
let
3-
pandoc = haskell-nix.hackage-package {
2+
(haskell-nix.hackage-package {
43
name = "pandoc";
54
version = "2.9.2.1";
65
index-state = "2020-04-15T00:00:00Z";
@@ -10,24 +9,4 @@ let
109
{ "https://github.com/jgm/pandoc-citeproc"."0.17"
1110
= "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; }
1211
."${location}"."${tag}";
13-
modules = [
14-
# Windows characters confuse cross compilation
15-
# See https://github.com/snoyberg/file-embed/pull/33
16-
{
17-
packages.file-embed.src = pkgs.fetchgit {
18-
url = "https://github.com/hamishmack/file-embed.git";
19-
rev = "12b33b8b710517308954c1facff3dc679c2dc5e3";
20-
sha256 = "0jcpja4s4cylmg9rddyakb1p1fb4l41ffwmy0njpb1dxc5z3v618";
21-
};
22-
}
23-
# Musl needs static zlib
24-
(lib.optionalAttrs stdenv.hostPlatform.isMusl {
25-
packages.pandoc.components.exes.pandoc.configureFlags = [
26-
"--ghc-option=-optl=-L${zlib.static}/lib"
27-
];
28-
})
29-
];
30-
};
31-
in
32-
pandoc.components.exes.pandoc
33-
12+
}).components.exes.pandoc

0 commit comments

Comments
 (0)