forked from cardano-foundation/cardano-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
183 lines (170 loc) · 6.68 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
############################################################################
#
# Cardano Wallet Nix build
#
# Derivation attributes of this file can be build with "nix-build -A ..."
# Discover attribute names using tab-completion in your shell.
#
# Interesting top-level attributes:
#
# - cardano-wallet-jormungandr - cli executable
# - cardano-wallet-byron - cli executable
# - cardano-wallet-shelley - cli executable
# - tests - attrset of test-suite executables
# - cardano-wallet-core.unit
# - cardano-wallet-jormungandr.jormungandr-integration
# - cardano-wallet-byron.integration
# - etc (layout is PACKAGE.COMPONENT)
# - checks - attrset of test-suite results
# - cardano-wallet-core.unit
# - cardano-wallet-jormungandr.jormungandr-integration
# - cardano-wallet-byron.integration
# - etc
# - benchmarks - attret of benchmark executables
# - cardano-wallet-core.db
# - cardano-wallet-jormungandr.latency
# - cardano-wallet-byron.restore
# - etc
# - migration-tests - tests db migrations from previous versions
# - dockerImage - tarballs of the docker images
# - jormungandr
# - byron
# - shelley
# - shell - imported by shell.nix
# - haskellPackages - a Haskell.nix package set of all packages and their dependencies
# - cardano-wallet-core.components.library
# - etc (layout is PACKAGE-NAME.components.COMPONENT-TYPE.COMPONENT-NAME)
#
# The attributes of this file are imported by the Hydra jobset and
# mapped into the layout TARGET-SYSTEM.ATTR-PATH.BUILD-SYSTEM.
# See release.nix for more info about that.
#
# Other documentation:
# https://github.com/input-output-hk/cardano-wallet/wiki/Building#nix-build
#
############################################################################
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
# Import pinned Nixpkgs with iohk-nix and Haskell.nix overlays
, pkgs ? import ./nix/default.nix { inherit system crossSystem config sourcesOverride; }
# Use this git revision for stamping executables
, gitrev ? pkgs.commonLib.commitIdFromGitRepoOrZero ./.git
# Use this to reference local sources rather than the niv pinned versions (see nix/default.nix)
, sourcesOverride ? {}
# GitHub PR number (as a string), set when building a Hydra PR jobset.
, pr ? null
}:
# commonLib includes iohk-nix utilities, our util.nix and nixpkgs lib.
with pkgs; with commonLib; with pkgs.haskell-nix.haskellLib;
let
src = cleanSourceWith {
src = pkgs.haskell-nix.cleanSourceHaskell { src = ./.; };
name = "cardano-wallet-src";
filter = removeSocketFilesFilter;
};
buildHaskellPackages = args: import ./nix/haskell.nix ({
inherit config lib stdenv pkgs buildPackages;
inherit (pkgs) haskell-nix;
inherit src pr gitrev;
} // args);
haskellPackages = buildHaskellPackages {};
profiledHaskellPackages = buildHaskellPackages { profiling = true; };
getPackageChecks = mapAttrs (_: package: package.checks);
self = {
inherit pkgs commonLib src haskellPackages profiledHaskellPackages;
# Jormungandr
inherit (jmPkgs) jormungandr jormungandr-cli;
# expose cardano-node, so daedalus can ship it without needing to pin cardano-node
inherit (pkgs) cardano-node cardano-cli;
inherit (haskellPackages.cardano-wallet-core.identifier) version;
# expose db-converter, so daedalus can ship it without needing to pin a ouroborus-network rev
inherit (haskellPackages.ouroboros-consensus-byron.components.exes) db-converter;
# adrestia tool belt
inherit (haskellPackages.bech32.components.exes) bech32;
inherit (haskellPackages.cardano-addresses.components.exes) cardano-address;
inherit (haskellPackages.cardano-transactions.components.exes) cardano-tx;
cardano-wallet-jormungandr = import ./nix/package-jormungandr.nix {
inherit (haskellPackages.cardano-wallet-jormungandr.components.exes)
cardano-wallet-jormungandr;
inherit pkgs jmPkgs gitrev;
haskellBuildUtils = haskellBuildUtils.package;
};
cardano-wallet-byron = import ./nix/package-cardano-node.nix {
inherit pkgs gitrev;
haskellBuildUtils = haskellBuildUtils.package;
exe = haskellPackages.cardano-wallet-byron.components.exes.cardano-wallet-byron;
inherit (self) cardano-node;
};
cardano-wallet-shelley = import ./nix/package-cardano-node.nix {
inherit pkgs gitrev;
haskellBuildUtils = haskellBuildUtils.package;
exe = haskellPackages.cardano-wallet-shelley.components.exes.cardano-wallet-shelley;
inherit (self) cardano-node;
};
# `tests` are the test suites which have been built.
tests = collectComponents "tests" isProjectPackage haskellPackages;
# `checks` are the result of executing the tests.
checks = pkgs.recurseIntoAttrs (getPackageChecks (selectProjectPackages haskellPackages));
# `benchmarks` are only built, not run.
benchmarks = collectComponents "benchmarks" isProjectPackage haskellPackages;
dockerImage = let
mkDockerImage = backend: exe: pkgs.callPackage ./nix/docker.nix { inherit backend exe; };
in recurseIntoAttrs (mapAttrs mkDockerImage {
jormungandr = self.cardano-wallet-jormungandr;
byron = self.cardano-wallet-byron;
shelley = self.cardano-wallet-shelley;
});
shell = haskellPackages.shellFor {
name = "cardano-wallet-shell";
packages = ps: attrValues (selectProjectPackages ps);
buildInputs = (with self; [
jormungandr
jormungandr-cli
cardano-node
cardano-cli
cardano-address
cardano-tx
bech32
]) ++ (with pkgs; [
niv
pkgconfig
python3Packages.openapi-spec-validator
ruby
sqlite-interactive
yq
]);
tools = {
cabal = "3.2.0.0";
ghcid = "0.8.7";
ghcide = "0.2.0";
hlint = "3.1.6";
stylish-haskell = "0.11.0.0";
weeder = "1.0.9";
};
CARDANO_NODE_CONFIGS = cardano-node.deployments;
meta.platforms = lib.platforms.unix;
shellHook = ''
setup_completion() {
local p
for p in $buildInputs; do
if [ -d "$p/share/bash-completion" ]; then
addToSearchPath XDG_DATA_DIRS "$p/share"
fi
done
}
setup_completion
'';
};
stackShell = import ./nix/stack-shell.nix {
walletPackages = self;
};
# This is the ./nix/regenerate.sh script. Put it here so that it's
# built and cached on CI.
inherit stackNixRegenerate;
# This attribute ensures that every single derivation required for
# evaluation of the haskell package set is built and cached on CI.
# haskellNixRoots = haskellPackages._roots;
};
in
self