-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefault.nix
160 lines (143 loc) · 4.46 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
let
compiler = "ghc8101";
sources = import ./nix/sources.nix;
pkgsOrig =
let
basePkgs = import sources.nixpkgs { };
patched = basePkgs.applyPatches {
name = "nixpkgs-patched";
src = sources.nixpkgs;
patches = [
./nix/patches/0001-Revert-ghc-8.6.3-binary-8.6.5-binary.patch
];
};
in
import patched { config.allowBroken = true; };
pkgsMusl = pkgsOrig.pkgsMusl.extend (se: su: {
fetchgit = pkgsOrig.fetchgit;
});
haskell = pkgsMusl.haskell;
gitignore = pkgsMusl.nix-gitignore.gitignoreSourcePure [ ./.gitignore ];
fixLocale = pkg: pkgsMusl.lib.overrideDerivation pkg (_: {
LANG = "C.UTF-8";
});
staticLibs = with pkgsMusl; [
zlib.static
(libffi.override { stdenv = makeStaticLibraries stdenv; })
(gmp.override { withStatic = true; })
];
overlays = se: su: {
"distributed-dataset" =
se.callCabal2nix
"distributed-dataset"
(gitignore ./distributed-dataset) { };
"distributed-dataset-aws" =
let orig = se.callCabal2nix
"distributed-dataset-aws"
(gitignore ./distributed-dataset-aws) { };
in
haskell.lib.overrideCabal orig (_: {
extraLibraries = staticLibs;
});
"distributed-dataset-opendatasets" =
se.callCabal2nix
"distributed-dataset-opendatasets"
(gitignore ./distributed-dataset-opendatasets) { };
"example-gh" =
let orig = se.callCabal2nix
"example-gh"
(gitignore ./examples/gh) { };
in
haskell.lib.overrideCabal orig (_: {
extraLibraries = staticLibs;
});
# Tests don't compile with musl:
# hGetContents: invalid argument (invalid byte sequence)
# commitBuffer: invalid argument (invalid character)
"blaze-builder" = fixLocale su.blaze-builder;
"bsb-http-chunked" = fixLocale su.bsb-http-chunked;
"code-page" = fixLocale su.code-page;
"conduit" = fixLocale su.conduit;
"foundation" = fixLocale su.foundation;
"hedgehog" = fixLocale su.hedgehog;
"memory" = fixLocale su.memory;
"ormolu" = fixLocale su.ormolu;
"retry" = fixLocale su.retry;
"shelly" = fixLocale su.shelly;
"tasty-hedgehog" = fixLocale su.tasty-hedgehog;
"yaml" = fixLocale su.yaml;
# Haddock does not work with musl:
# haddock: internal error: <stdout>: \
# commitBuffer: invalid argument (invalid character)
# hGetContents: invalid argument (invalid byte sequence)
"basement" = fixLocale su.basement;
"path-io" = fixLocale su.path-io;
};
haskellPackages = haskell.packages.${compiler}.override {
overrides = overlays;
};
in
rec
{
"distributed-dataset" = haskellPackages.distributed-dataset;
"distributed-dataset-aws" = haskellPackages.distributed-dataset-aws;
"distributed-dataset-opendatasets" = haskellPackages.distributed-dataset-opendatasets;
"example-gh" = haskellPackages.example-gh;
docs =
let ds = [
distributed-dataset
distributed-dataset-aws
distributed-dataset-opendatasets
];
in
pkgsOrig.runCommand "distributed-dataset-docs"
{ buildInputs = [ pkgsOrig.tree ]; } ''
mkdir -p $out
${pkgsOrig.lib.concatMapStringsSep
"\n"
(d: "cp -r ${d.doc}/share/doc/${d.name}/html $out/${d.name}")
ds
}
cat <<EOF > $out/index.html
<html>
<head>
<title>distributed-dataset docs</title>
<link rel="stylesheet" href="${(builtins.head ds).name}/linuwial.css">
</head>
<body>
<div id="content">
<h1>distributed-dataset docs</h1>
<ul>
${pkgsOrig.lib.concatMapStringsSep
"\n"
(d: "<li><a href=\"./${d.name}/index.html\">${d.name}</a></li>")
ds}
</ul>
</div>
</body>
</html>
EOF
'';
shell = haskellPackages.shellFor {
packages = p: with p; [
distributed-dataset
distributed-dataset-aws
distributed-dataset-opendatasets
example-gh
];
buildInputs = [
haskellPackages.cabal-install
pkgsOrig.haskellPackages.steeloverseer
pkgsOrig.haskellPackages.ormolu
pkgsOrig.haskellPackages.cabal-fmt
pkgsOrig.nixpkgs-fmt
pkgsOrig.niv
];
withHoogle = true;
# shellFor unsets LOCALE_ARCHIVE when GHC is compiled with musl, which breaks
# glibc-linked programs in nix-shell in weird ways.
shellHook = ''
export LOCALE_ARCHIVE="${pkgsOrig.glibcLocales}/lib/locale/locale-archive"
'';
};
}