-
Notifications
You must be signed in to change notification settings - Fork 721
/
Copy pathhaskell.nix
176 lines (162 loc) · 7.07 KB
/
haskell.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
############################################################################
# Builds Haskell packages with Haskell.nix
############################################################################
{ pkgs
, lib
, stdenv
, haskell-nix
, buildPackages
# GHC attribute name
, compiler
# Enable profiling
, profiling ? false
# Enable asserts for given packages
, assertedPackages ? []
# Version info, to be passed when not building from a git work tree
, gitrev ? null
, libsodium ? pkgs.libsodium
}:
let
src = haskell-nix.haskellLib.cleanGit {
name = "cardano-node-src";
src = ../.;
};
projectPackages = lib.attrNames (haskell-nix.haskellLib.selectProjectPackages
(haskell-nix.cabalProject {
inherit src;
compiler-nix-name = "ghc865";
}));
# This creates the Haskell package set.
# https://input-output-hk.github.io/haskell.nix/user-guide/projects/
pkgSet = haskell-nix.cabalProject (lib.optionalAttrs stdenv.hostPlatform.isWindows {
# FIXME: without this deprecated attribute, db-converter fails to compile directory with:
# Encountered missing dependencies: unix >=2.5.1 && <2.9
ghc = buildPackages.haskell-nix.compiler.${compiler};
} // {
inherit src;
compiler-nix-name = compiler;
modules = [
{ compiler.nix-name = compiler; }
# Allow reinstallation of Win32
{ nonReinstallablePkgs =
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
# ghcjs custom packages
"ghcjs-prim" "ghcjs-th"
"ghc-boot"
"ghc" "array" "binary" "bytestring" "containers"
"filepath" "ghc-boot" "ghc-compact" "ghc-prim"
# "ghci" "haskeline"
"hpc"
"mtl" "parsec" "text" "transformers"
"xhtml"
# "stm" "terminfo"
];
# Tell hydra to skip this test on windows (it does not build)
# 1. Set them to all ...
packages.cardano-cli.components.all.platforms =
with stdenv.lib.platforms; lib.mkForce [ linux darwin windows ];
# 2. then drop windows for the test
packages.cardano-cli.components.tests.cardano-cli-test.platforms =
with stdenv.lib.platforms; lib.mkForce [ linux darwin ];
packages.cardano-cli.components.tests.cardano-cli-golden.platforms =
with stdenv.lib.platforms; lib.mkForce [ linux darwin ];
# Needed for the CLI tests.
# Coreutils because we need 'paste'.
packages.cardano-cli.components.tests.cardano-cli-test.build-tools =
lib.mkForce [buildPackages.jq buildPackages.coreutils buildPackages.shellcheck];
packages.cardano-cli.components.tests.cardano-cli-golden.build-tools =
lib.mkForce [buildPackages.jq buildPackages.coreutils buildPackages.shellcheck];
}
{
# Stamp executables with the git revision
# And make sure that libsodium DLLs are available for windows binaries:
packages = lib.genAttrs projectPackages (name: {
postInstall = ''
if [ -d $out/bin ]; then
${setGitRev}
${lib.optionalString stdenv.hostPlatform.isWindows
"ln -s ${libsodium}/bin/libsodium-23.dll $out/bin/libsodium-23.dll"
}
fi
'';
});
}
{
# Packages we wish to ignore version bounds of.
# This is similar to jailbreakCabal, however it
# does not require any messing with cabal files.
packages.katip.doExactConfig = true;
# split data output for ekg to reduce closure size
packages.ekg.components.library.enableSeparateDataOutput = true;
# cardano-cli-test depends on cardano-cli
packages.cardano-cli.preCheck = "export CARDANO_CLI=${pkgSet.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli";
# cardano-node-test depends on cardano-node
packages.cardano-node-chairman.preCheck = "
export CARDANO_CLI=${pkgSet.cardano-cli.components.exes.cardano-cli}/bin/cardano-cli
export CARDANO_NODE=${pkgSet.cardano-node.components.exes.cardano-node}/bin/cardano-node
export CARDANO_NODE_SRC=${ ./.. }
";
}
{
packages = lib.genAttrs projectPackages
(name: { configureFlags = [ "--ghc-option=-Werror" ]; });
}
(lib.optionalAttrs profiling {
enableLibraryProfiling = true;
packages.cardano-node.components.exes.cardano-node.enableExecutableProfiling = true;
})
{
packages = lib.genAttrs assertedPackages
(name: { flags.asserts = true; });
}
(lib.optionalAttrs stdenv.hostPlatform.isLinux {
# systemd can't be statically linked
packages.cardano-config.flags.systemd = !stdenv.hostPlatform.isMusl;
packages.cardano-node.flags.systemd = !stdenv.hostPlatform.isMusl;
})
# Musl libc fully static build
(lib.optionalAttrs stdenv.hostPlatform.isMusl (let
# Module options which adds GHC flags and libraries for a fully static build
fullyStaticOptions = {
enableShared = false;
enableStatic = true;
};
in
{
packages = lib.genAttrs projectPackages (name: fullyStaticOptions);
# Haddock not working and not needed for cross builds
doHaddock = false;
}
))
(lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
# Make sure we use a buildPackages version of happy
packages.pretty-show.components.library.build-tools = [ buildPackages.haskell-nix.haskellPackages.happy ];
# Remove hsc2hs build-tool dependencies (suitable version will be available as part of the ghc derivation)
packages.Win32.components.library.build-tools = lib.mkForce [];
packages.terminal-size.components.library.build-tools = lib.mkForce [];
packages.network.components.library.build-tools = lib.mkForce [];
# Disable cabal-doctest tests by turning off custom setups
packages.comonad.package.buildType = lib.mkForce "Simple";
packages.distributive.package.buildType = lib.mkForce "Simple";
packages.lens.package.buildType = lib.mkForce "Simple";
packages.nonempty-vector.package.buildType = lib.mkForce "Simple";
packages.semigroupoids.package.buildType = lib.mkForce "Simple";
})
];
# TODO add flags to packages (like cs-ledger) so we can turn off tests that will
# not build for windows on a per package bases (rather than using --disable-tests).
# configureArgs = lib.optionalString stdenv.hostPlatform.isWindows "--disable-tests";
});
# setGitRev is a postInstall script to stamp executables with
# version info. It uses the "gitrev" argument, if set. Otherwise,
# the revision is sourced from the local git work tree.
setGitRev = ''
${haskellBuildUtils}/bin/set-git-rev "${gitrev'}" $out/bin/* || true
'';
gitrev' = if (gitrev == null)
then buildPackages.commonLib.commitIdFromGitRepoOrZero ../.git
else gitrev;
haskellBuildUtils = buildPackages.haskellBuildUtils.package;
in
pkgSet