forked from cardano-foundation/cardano-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.nix
194 lines (167 loc) · 7.01 KB
/
release.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
184
185
186
187
188
189
190
191
192
193
194
############################################################################
#
# Hydra release jobset.
#
# The purpose of this file is to select jobs defined in default.nix and map
# them to all supported build platforms.
#
# The layout is TARGET-SYSTEM.ATTR-PATH.BUILD-SYSTEM where
#
# * TARGET-SYSTEM is one of
# - native - build the job for BUILD-SYSTEM
# - x86_64-w64-mingw32 - build the job for windows
# - musl64 - build the job for Linux, but statically linked with musl libc
#
# * ATTR-PATH is an attribute from default.nix
#
# * BUILD-SYSTEM is the system where the derivation is built. Hydra
# uses this to distribute builds to its build slaves. If building
# locally then it must reflect your local system. The value is one of:
# - x86_64-linux - Linux
# - x86_64-darwin - macOS
#
# Discover jobs by using tab completion in your shell:
# nix-build release.nix -A <TAB>
# ... or by looking at the jobset evaluated by Hydra:
# https://hydra.iohk.io/jobset/Cardano/cardano-wallet#tabs-jobs
#
############################################################################
# The project sources
{ cardano-wallet ? { outPath = ./.; rev = "abcdef"; }
# Function arguments to pass to the project
, projectArgs ? {
config = { allowUnfree = false; inHydra = true; };
gitrev = cardano-wallet.rev;
}
# The systems that the jobset will be built for.
, supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
# The systems used for cross-compiling
, supportedCrossSystems ? [ "x86_64-linux" ]
# A Hydra option
, scrubJobs ? true
# Dependencies overrides
, sourcesOverride ? {}
# Import pkgs, including IOHK common nix lib
, pkgs ? import ./nix { inherit sourcesOverride; }
}:
with (import pkgs.iohkNix.release-lib) {
inherit pkgs;
inherit supportedSystems supportedCrossSystems scrubJobs projectArgs;
packageSet = import cardano-wallet;
gitrev = cardano-wallet.rev;
};
with pkgs.lib;
let
testsSupportedSystems = [ "x86_64-linux" "x86_64-darwin" ];
# Recurse through an attrset, returning all test derivations in a list.
collectTests' = ds: filter (d: elem d.system testsSupportedSystems) (collect isDerivation ds);
# Adds the package name to the test derivations for windows-testing-bundle.nix
# (passthru.identifier.name does not survive mapTestOn)
collectTests = ds: concatLists (
mapAttrsToList (packageName: package:
map (drv: drv // { inherit packageName; }) (collectTests' package)
) ds);
inherit (systems.examples) mingwW64 musl64;
jobs = {
native = mapTestOn (packagePlatformsOrig project);
# Cross compilation, excluding the dockerImage and shells that we cannnot cross compile
"${mingwW64.config}" = mapTestOnCross mingwW64 (packagePlatformsCross
(filterAttrs (n: _: n != "dockerImage" && n != "shell" && n != "stackShell") project));
musl64 = mapTestOnCross musl64 (packagePlatformsCross
(filterAttrs (n: _: n != "dockerImage" && n != "shell") project));
}
// {
# This aggregate job is what IOHK Hydra uses to update
# the CI status in GitHub.
required = mkRequiredJob (
collectTests jobs.native.tests ++
collectTests jobs.native.benchmarks ++
[ jobs.native.shell.x86_64-linux
jobs.native.shell.x86_64-darwin
# jormungandr
jobs.native.cardano-wallet-jormungandr.x86_64-linux
jobs.native.cardano-wallet-jormungandr.x86_64-darwin
jobs.x86_64-pc-mingw32.cardano-wallet-jormungandr.x86_64-linux
jobs.cardano-wallet-jormungandr-win64
jobs.cardano-wallet-jormungandr-macos64
jobs.cardano-wallet-jormungandr-tests-win64
# cardano-node (Byron)
jobs.native.cardano-wallet-byron.x86_64-linux
jobs.native.cardano-wallet-byron.x86_64-darwin
]
);
# These derivations are used for the Daedalus installer.
daedalus-jormungandr = with jobs; {
linux = native.cardano-wallet-jormungandr.x86_64-linux;
macos = native.cardano-wallet-jormungandr.x86_64-darwin;
windows = x86_64-w64-mingw32.cardano-wallet-jormungandr.x86_64-linux;
};
# Windows release ZIP archive
cardano-wallet-jormungandr-win64 = import ./nix/windows-release.nix {
inherit pkgs project;
cardano-wallet-jormungandr = jobs.x86_64-w64-mingw32.cardano-wallet-jormungandr.x86_64-linux;
};
# This is used for testing the build on windows.
cardano-wallet-jormungandr-tests-win64 = import ./nix/windows-testing-bundle.nix {
inherit pkgs project;
cardano-wallet-jormungandr = jobs.x86_64-w64-mingw32.cardano-wallet-jormungandr.x86_64-linux;
tests = collectTests jobs.x86_64-w64-mingw32.tests;
benchmarks = collectTests jobs.x86_64-w64-mingw32.benchmarks;
};
# For testing migration tests on windows
migration-tests-win64 = import ./nix/windows-migration-tests-bundle.nix {
inherit pkgs project;
migration-tests = jobs.x86_64-w64-mingw32.migration-tests.x86_64-linux;
};
# Fully-static linux binary (placeholder - does not build)
cardano-wallet-jormungandr-linux64 = let
name = "cardano-wallet-jormungandr-${project.version}";
tarname = "${name}-linux64.tar.gz";
in pkgs.runCommand "${name}-linux64" {
buildInputs = with pkgs.buildPackages; [ gnutar gzip binutils ];
} ''
cp -R ${jobs.musl64.cardano-wallet-jormungandr.x86_64-linux}/bin ${name}
chmod -R 755 ${name}
strip ${name}/*
mkdir -p $out/nix-support
tar -czf $out/${tarname} ${name}
echo "file binary-dist $out/${tarname}" > $out/nix-support/hydra-build-products
'';
# macOS binary and dependencies in tarball
cardano-wallet-jormungandr-macos64 = let
name = "cardano-wallet-jormungandr-${project.version}";
tarname = "${name}-macos64.tar.gz";
in pkgs.runCommand "${name}-macos64" {
buildInputs = with pkgs.buildPackages; [ gnutar gzip binutils nix ];
} ''
cp -R ${jobs.native.cardano-wallet-jormungandr.x86_64-darwin}/bin ${name}
chmod -R 755 ${name}
mkdir -p $out/nix-support
tar -czf $out/${tarname} ${name}
echo "file binary-dist $out/${tarname}" > $out/nix-support/hydra-build-products
'';
# Build and cache the build script used on Buildkite
buildkiteScript = import ./.buildkite/default.nix {
walletPackages = project;
};
}
# Build the shell derivation in Hydra so that all its dependencies
# are cached.
// mapTestOn (packagePlatforms {
inherit (project) shell stackShell;
})
# This aggregate job is what IOHK Hydra uses to update
# the CI status in GitHub.
// (mkRequiredJob (
collectTests jobs.native.tests ++
collectTests jobs.native.benchmarks ++
[ jobs.native.cardano-wallet-jormungandr.x86_64-linux
jobs.native.cardano-wallet-jormungandr.x86_64-darwin
jobs.x86_64-w64-mingw32.cardano-wallet-jormungandr.x86_64-linux
jobs.native.shell.x86_64-linux
jobs.native.shell.x86_64-darwin
jobs.cardano-wallet-jormungandr-win64
jobs.cardano-wallet-jormungandr-macos64
jobs.cardano-wallet-jormungandr-tests-win64
]));
in jobs