forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.nix
154 lines (135 loc) · 5.43 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
############################################################################
#
# 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 project sources
{ cardano-node ? { outPath = ./.; rev = "abcdef"; }
# Function arguments to pass to the project
, projectArgs ? {
inherit sourcesOverride;
config = { allowUnfree = false; inHydra = true; };
gitrev = cardano-node.rev;
}
# The systems that the jobset will be built for.
, supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
# The systems used for cross-compiling (default: linux)
, supportedCrossSystems ? [ (builtins.head supportedSystems) ]
# Cross compilation to Windows is currently only supported on linux.
, windowsBuild ? builtins.elem "x86_64-linux" supportedCrossSystems
# 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-node;
gitrev = cardano-node.rev;
};
with pkgs.lib;
let
makeScripts = cluster: let
getScript = name: {
x86_64-linux = (pkgsFor "x86_64-linux").scripts.${cluster}.${name};
x86_64-darwin = (pkgsFor "x86_64-darwin").scripts.${cluster}.${name};
};
in {
node = getScript "node";
};
dockerImageArtifact = let
image = (pkgsFor (builtins.head supportedSystems)).dockerImage;
wrapImage = image: pkgs.runCommand "${image.name}-hydra" {} ''
mkdir -pv $out/nix-support/
cat <<EOF > $out/nix-support/hydra-build-products
file dockerimage-${image.name} ${image}
EOF
'';
in wrapImage image;
mkPins = inputs: pkgs.runCommand "ifd-pins" {} ''
mkdir $out
cd $out
${lib.concatMapStringsSep "\n" (input: "ln -sv ${input.value} ${input.key}") (lib.attrValues (lib.mapAttrs (key: value: { inherit key value; }) inputs))}
'';
makeRelease = cluster: {
name = cluster;
value = {
scripts = makeScripts cluster;
};
};
extraBuilds = {
# only build nixos tests on first supported system (linux)
inherit (pkgsFor (builtins.head supportedSystems)) nixosTests clusterTests;
# Environments listed in Network Configuration page
cardano-deployment = pkgs.iohkNix.cardanoLib.mkConfigHtml { inherit (pkgs.iohkNix.cardanoLib.environments) mainnet testnet ff shelley_testnet; };
} // (builtins.listToAttrs (map makeRelease [
# Environments we want to build scripts for on hydra
"mainnet"
"staging"
"shelley_qa"
"shelley_staging_short"
"shelley_staging"
"shelley_testnet"
"testnet"
]));
# restrict supported systems to a subset where tests (if exist) are required to pass:
testsSupportedSystems = intersectLists supportedSystems [ "x86_64-linux" "x86_64-darwin" ];
# Recurse through an attrset, returning all derivations in a list matching test supported systems.
collectJobs' = ds: filter (d: elem d.system testsSupportedSystems) (collect isDerivation ds);
# Adds the package name to the derivations for windows-testing-bundle.nix
# (passthru.identifier.name does not survive mapTestOn)
collectJobs = ds: concatLists (
mapAttrsToList (packageName: package:
map (drv: drv // { inherit packageName; }) (collectJobs' package)
) ds);
# Remove build jobs for which cross compiling does not make sense.
filterJobsCross = filterAttrs (n: _: n != "dockerImage" && n != "shell" && n != "cluster");
inherit (systems.examples) mingwW64 musl64;
inherit (pkgs.commonLib) sources nixpkgs;
jobs = {
inherit dockerImageArtifact;
native = mapTestOn (__trace (__toJSON (packagePlatforms project)) (packagePlatforms project));
musl64 = mapTestOnCross musl64 (packagePlatformsCross (filterJobsCross project));
ifd-pins = mkPins {
inherit (sources) iohk-nix "haskell.nix";
inherit nixpkgs;
inherit (pkgs.haskell-nix) hackageSrc stackageSrc;
};
cardano-node-macos = import ./nix/binary-release.nix {
inherit pkgs project;
platform = "macos";
exes = filter (p: p.system == "x86_64-darwin") (collectJobs jobs.native.exes);
};
cardano-node-linux = import ./nix/binary-release.nix {
inherit pkgs project;
platform = "linux";
exes = filter (p: p.system == "x86_64-linux") (collectJobs jobs.musl64.exes);
};
} // (optionalAttrs windowsBuild {
"${mingwW64.config}" = mapTestOnCross mingwW64 (packagePlatformsCross (filterJobsCross project));
cardano-node-win64 = import ./nix/binary-release.nix {
inherit pkgs project;
platform = "win64";
exes = collectJobs jobs.${mingwW64.config}.exes;
};
}) // extraBuilds // (mkRequiredJob (concatLists [
(collectJobs jobs.native.checks)
(collectJobs jobs.native.benchmarks)
(collectJobs jobs.native.exes)
(optional windowsBuild jobs.cardano-node-win64)
(optionals windowsBuild (collectJobs jobs.${mingwW64.config}.checks))
(map (cluster: collectJobs jobs.${cluster}.scripts.node.${head supportedSystems}) [ "mainnet" "testnet" "staging" "shelley_qa" "shelley_testnet" ])
(collectJobs jobs.nixosTests.chairmansCluster)
[
jobs.cardano-node-linux
jobs.cardano-node-macos
jobs.dockerImageArtifact
]
]));
in jobs