-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathcronos-matrix.nix
62 lines (62 loc) · 1.56 KB
/
cronos-matrix.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
{
lib,
stdenv,
callPackage,
buildPackages,
runCommand,
bundle-exe,
rev ? "dirty",
}:
let
# make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references.
# reset the ownership and permissions to make the extract result more normal.
make-tarball =
drv:
runCommand "tarball-${drv.name}"
{
nativeBuildInputs = with buildPackages; [
gnutar
gzip
];
}
''
tar cfv - -C "${drv}" \
--owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \
| gzip -9 > $out
'';
bundle-win-exe = drv: callPackage ./bundle-win-exe.nix { cronosd = drv; };
matrix = lib.cartesianProduct {
network = [
"mainnet"
"testnet"
];
pkgtype = [
"nix" # normal nix package
"bundle" # relocatable bundled package
"tarball" # tarball of the bundle, for distribution and checksum
];
};
in
builtins.listToAttrs (
builtins.map (
{ network, pkgtype }:
{
name = builtins.concatStringsSep "-" (
[ "cronosd" ]
++ lib.optional (network != "mainnet") network
++ lib.optional (pkgtype != "nix") pkgtype
);
value =
let
cronosd = callPackage ../. { inherit rev network; };
bundle = if stdenv.hostPlatform.isWindows then bundle-win-exe cronosd else bundle-exe cronosd;
in
if pkgtype == "bundle" then
bundle
else if pkgtype == "tarball" then
make-tarball bundle
else
cronosd;
}
) matrix
)