Skip to content

Commit 236e7bc

Browse files
committed
imp: pass {abort,warn}OnMissingIpModule to perNode nixosModule opts
1 parent 2ab1253 commit 236e7bc

File tree

7 files changed

+115
-43
lines changed

7 files changed

+115
-43
lines changed

flake/hydraJobs.nix

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
lib,
44
withSystem,
55
...
6-
} @ parts: {
6+
}: {
77
flake.hydraJobs = lib.genAttrs config.systems (lib.flip withSystem (
88
{
99
config,
1010
pkgs,
1111
...
1212
}: let
13-
jobs = {
14-
nixosConfigurations =
15-
lib.mapAttrs
16-
(_: {config, ...}: config.system.build.toplevel)
17-
parts.config.flake.nixosConfigurations;
18-
inherit (config) packages checks devShells;
19-
};
13+
jobs = {inherit (config) packages checks devShells;};
2014
in
2115
jobs
2216
// {

flake/nixosModules/profile-cardano-parts.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
# Attributes available on nixos module import:
66
# config.cardano-parts.cluster.group.<...> # Inherited from flakeModule cluster.group assignment
7+
# config.cardano-parts.perNode.generic.abortOnMissingIpModule
8+
# config.cardano-parts.perNode.generic.warnOnMissingIpModule
79
# config.cardano-parts.perNode.lib.cardanoLib
810
# config.cardano-parts.perNode.lib.opsLib
911
# config.cardano-parts.perNode.lib.topologyLib
@@ -109,6 +111,12 @@ flake @ {moduleWithSystem, ...}: {
109111

110112
perNodeSubmodule = submodule {
111113
options = {
114+
generic = mkOption {
115+
type = genericSubmodule;
116+
description = mdDoc "Cardano-parts nixos perNode generic submodule";
117+
default = {};
118+
};
119+
112120
lib = mkOption {
113121
type = libSubmodule;
114122
description = mdDoc "Cardano-parts nixos perNode lib submodule";
@@ -135,6 +143,26 @@ flake @ {moduleWithSystem, ...}: {
135143
};
136144
};
137145

146+
genericSubmodule = submodule {
147+
options = {
148+
abortOnMissingIpModule = mkOption {
149+
type = bool;
150+
description = mdDoc ''
151+
The option to abort on missing downstream provided "ip-module" nixosModule.
152+
'';
153+
default = cfg.group.generic.abortOnMissingIpModule;
154+
};
155+
156+
warnOnMissingIpModule = mkOption {
157+
type = bool;
158+
description = mdDoc ''
159+
The option to warn on missing downstream provided "ip-module" nixosModule.
160+
'';
161+
default = cfg.group.generic.warnOnMissingIpModule;
162+
};
163+
};
164+
};
165+
138166
libSubmodule = submodule {
139167
options = foldl' recursiveUpdate {} [
140168
(mkSpecialOpt "cardanoLib" (attrsOf anything) (cfg.group.lib.cardanoLib system))

flakeModules/cluster.nix

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# flake.cardano-parts.cluster.infra.generic.warnOnMissingIpModule
1919
# flake.cardano-parts.cluster.infra.grafana.stackName
2020
# flake.cardano-parts.cluster.groups.<default|name>.bookRelayMultivalueDns
21+
# flake.cardano-parts.cluster.groups.<default|name>.generic.abortOnMissingIpModule
22+
# flake.cardano-parts.cluster.groups.<default|name>.generic.warnOnMissingIpModule
2123
# flake.cardano-parts.cluster.groups.<default|name>.groupBlockProducerSubstring
2224
# flake.cardano-parts.cluster.groups.<default|name>.groupFlake
2325
# flake.cardano-parts.cluster.groups.<default|name>.groupName
@@ -270,12 +272,31 @@ flake @ {
270272

271273
groupSubmodule = submodule ({name, ...}: {
272274
options = {
273-
meta = mkOption {
274-
type = metaSubmodule;
275-
description = mdDoc "Cardano-parts cluster group meta submodule.";
275+
bookRelayMultivalueDns = mkOption {
276+
type = nullOr str;
277+
description = mdDoc ''
278+
Cardano-parts cluster group(s) multivalue DNS.
279+
Machines belonging to this group and in the relay role have their IP A address added to this multivalue DNS record.
280+
This is intended to aggregate all group relays for a given environment to a single DNS for use as an upstream publicRoots.
281+
'';
282+
default = null;
283+
};
284+
285+
generic = mkOption {
286+
type = groupGenericSubmodule;
287+
description = mdDoc "Cardano-parts cluster group generic submodule.";
276288
default = {};
277289
};
278290

291+
groupBlockProducerSubstring = mkOption {
292+
type = str;
293+
description = mdDoc ''
294+
Cardano-parts cluster group block producer substring.
295+
Machines belonging to this group and in the block producer role will have Colmena names containing this substring.
296+
'';
297+
default = "bp-";
298+
};
299+
279300
groupFlake = mkOption {
280301
type = attrsOf raw;
281302
description = mdDoc ''
@@ -314,16 +335,6 @@ flake @ {
314335
default = "";
315336
};
316337

317-
bookRelayMultivalueDns = mkOption {
318-
type = nullOr str;
319-
description = mdDoc ''
320-
Cardano-parts cluster group(s) multivalue DNS.
321-
Machines belonging to this group and in the relay role have their IP A address added to this multivalue DNS record.
322-
This is intended to aggregate all group relays for a given environment to a single DNS for use as an upstream publicRoots.
323-
'';
324-
default = null;
325-
};
326-
327338
groupRelayMultivalueDns = mkOption {
328339
type = nullOr str;
329340
description = mdDoc ''
@@ -345,30 +356,47 @@ flake @ {
345356
default = "rel-";
346357
};
347358

348-
groupBlockProducerSubstring = mkOption {
349-
type = str;
350-
description = mdDoc ''
351-
Cardano-parts cluster group block producer substring.
352-
Machines belonging to this group and in the block producer role will have Colmena names containing this substring.
353-
'';
354-
default = "bp-";
359+
meta = mkOption {
360+
type = groupMetaSubmodule;
361+
description = mdDoc "Cardano-parts cluster group meta submodule.";
362+
default = {};
355363
};
356364

357365
pkgs = mkOption {
358-
type = pkgsSubmodule;
366+
type = groupPkgsSubmodule;
359367
description = mdDoc "Cardano-parts cluster group pkgs submodule.";
360368
default = {};
361369
};
362370

363371
lib = mkOption {
364-
type = libSubmodule;
372+
type = groupLibSubmodule;
365373
description = mdDoc "Cardano-parts cluster group lib submodule.";
366374
default = {};
367375
};
368376
};
369377
});
370378

371-
libSubmodule = submodule {
379+
groupGenericSubmodule = submodule {
380+
options = {
381+
abortOnMissingIpModule = mkOption {
382+
type = bool;
383+
description = mdDoc ''
384+
Cardano-parts cluster group option to abort on missing downstream provided "ip-module" nixosModule.
385+
'';
386+
default = cfg.cluster.infra.generic.abortOnMissingIpModule;
387+
};
388+
389+
warnOnMissingIpModule = mkOption {
390+
type = bool;
391+
description = mdDoc ''
392+
Cardano-parts cluster group option to warn on missing downstream provided "ip-module" nixosModule.
393+
'';
394+
default = cfg.cluster.infra.generic.warnOnMissingIpModule;
395+
};
396+
};
397+
};
398+
399+
groupLibSubmodule = submodule {
372400
options = {
373401
cardanoLib = mkOption {
374402
type = functionTo (attrsOf anything);
@@ -394,7 +422,7 @@ flake @ {
394422
};
395423
};
396424

397-
metaSubmodule = submodule {
425+
groupMetaSubmodule = submodule {
398426
options = {
399427
addressType = mkOption {
400428
type = enum ["fqdn" "namePrivateIpv4" "namePublicIpv4" "namePublicIpv6" "privateIpv4" "publicIpv4" "publicIpv6"];
@@ -519,7 +547,7 @@ flake @ {
519547
};
520548
};
521549

522-
pkgsSubmodule = submodule {
550+
groupPkgsSubmodule = submodule {
523551
options = {
524552
blockfrost-platform = mkOption {
525553
type = functionTo package;

flakeModules/pkgs.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ in
443443
(mkPkg "cardano-address" caPkgs."\"cardano-addresses:exe:cardano-address\"-IntersectMBO-cardano-addresses-4-0-0-3749045")
444444
(mkPkg "cardano-cli" (caPkgs.cardano-cli-input-output-hk-cardano-node-10-4-1-420c94f // {version = "10.8.0.0";}))
445445
(mkPkg "cardano-cli-ng" (caPkgs.cardano-cli-input-output-hk-cardano-node-10-4-1-420c94f // {version = "10.8.0.0";}))
446-
# (mkPkg "cardano-db-sync" (recursiveUpdate caPkgs."\"cardano-db-sync:exe:cardano-db-sync\"-input-output-hk-cardano-db-sync-13-6-0-5-cb61094" {meta.mainProgram = "cardano-db-sync";}))
447-
# (mkPkg "cardano-db-sync-ng" (recursiveUpdate caPkgs."\"cardano-db-sync:exe:cardano-db-sync\"-input-output-hk-cardano-db-sync-13-6-0-5-cb61094" {meta.mainProgram = "cardano-db-sync";}))
448446
(mkPkg "cardano-db-sync" caPkgs."\"cardano-db-sync:exe:cardano-db-sync\"-input-output-hk-cardano-db-sync-13-6-0-5-cb61094")
449447
(mkPkg "cardano-db-sync-ng" caPkgs."\"cardano-db-sync:exe:cardano-db-sync\"-input-output-hk-cardano-db-sync-13-6-0-5-cb61094")
450448
(mkPkg "cardano-db-tool" caPkgs."\"cardano-db-tool:exe:cardano-db-tool\"-input-output-hk-cardano-db-sync-13-6-0-5-cb61094")

templates/cardano-parts-project/flake/colmena.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ in
8484

8585
# Mithril signing config
8686
# mithrilRelay = {imports = [inputs.cardano-parts.nixosModules.profile-mithril-relay];};
87-
# declMRel = node: {services.mithril-signer.relayEndpoint = nixosConfigurations.${node}.config.ips.privateIpv4;};
88-
# declMSigner = node: {services.mithril-relay.signerIp = nixosConfigurations.${node}.config.ips.privateIpv4;};
87+
# declMRel = node: {services.mithril-signer.relayEndpoint = nixosConfigurations.${node}.config.ips.privateIpv4 or "ip-module not available";};
88+
# declMSigner = node: {services.mithril-relay.signerIp = nixosConfigurations.${node}.config.ips.privateIpv4 or "ip-module not available;};
8989

9090
# Optimize tcp sysctl and route params for long distance transmission.
9191
# Apply to one relay per pool group.

templates/cardano-parts-project/flake/hydraJobs.nix

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,50 @@
33
lib,
44
withSystem,
55
...
6-
} @ parts: {
7-
flake.hydraJobs = lib.genAttrs config.systems (lib.flip withSystem (
6+
} @ parts:
7+
with builtins;
8+
with lib; {
9+
flake.hydraJobs = genAttrs config.systems (flip withSystem (
810
{
911
config,
1012
pkgs,
1113
...
1214
}: let
15+
nixosCfgsNoIpModule =
16+
mapAttrs
17+
(name: cfg:
18+
if cfg.config.cardano-parts.perNode.generic.abortOnMissingIpModule
19+
then
20+
# Hydra will not have access to "ip-module" IPV4/IPV6 secrets
21+
# which are ordinarily only accessible from a deployer machine and
22+
# are not committed. In this case, hydra can still complete a
23+
# generic build without "ip-module" to check for other breakage.
24+
cfg.extendModules {
25+
modules = [
26+
(_: {
27+
cardano-parts.perNode.generic = warn "Building machine ${name} without secret \"ip-module\" inclusion for hydraJobs CI" {
28+
abortOnMissingIpModule = false;
29+
warnOnMissingIpModule = false;
30+
};
31+
})
32+
];
33+
}
34+
else cfg)
35+
parts.config.flake.nixosConfigurations;
36+
1337
jobs = {
1438
nixosConfigurations =
15-
lib.mapAttrs
39+
mapAttrs
1640
(_: {config, ...}: config.system.build.toplevel)
17-
parts.config.flake.nixosConfigurations;
41+
nixosCfgsNoIpModule;
1842
inherit (config) packages checks devShells;
1943
};
2044
in
2145
jobs
2246
// {
2347
required = pkgs.releaseTools.aggregate {
2448
name = "required";
25-
constituents = lib.collect lib.isDerivation jobs;
49+
constituents = collect isDerivation jobs;
2650
};
2751
}
2852
));

templates/cardano-parts-project/flake/nixosModules/ip-module-check.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ flake: {
77
inherit (lib) optional;
88
inherit (flake.config.flake) nixosModules;
99

10-
cfgGeneric = flake.config.flake.cardano-parts.cluster.infra.generic;
10+
cfgGeneric = config.cardano-parts.perNode.generic;
1111

1212
msg = ''
1313

0 commit comments

Comments
 (0)