Skip to content

Commit 997b333

Browse files
authored
Merge pull request #58 from input-output-hk/next-2025-02-05
Node-ng 10.2.1, mithril-cli v2506.0, env cleanup
2 parents 7fa68fa + 167c5cd commit 997b333

28 files changed

+270
-238
lines changed

.github/workflows/nix-jobs-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
rm -rf workbench
9595
for i in ${JOBS[@]}; do
9696
echo "Running nix job .#$i"
97-
if [ "$UNSTABLE" = "true" ] && [ "$i" = "job-gen-custom-node-config-data" ]; then
97+
if [ "$i" = "job-gen-custom-node-config-data" ]; then
9898
ERA_CMD="conway" nix run ".#$i"
9999
else
100100
nix run ".#$i"

flake.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
services-flake.url = "github:juspay/services-flake";
2626

2727
# Cardano related inputs
28-
capkgs.url = "github:input-output-hk/capkgs";
28+
capkgs.url = "github:input-output-hk/capkgs/input-addressed";
2929
empty-flake.url = "github:input-output-hk/empty-flake";
3030
haskell-nix.url = "github:input-output-hk/haskell.nix";
3131
iohk-nix.url = "github:input-output-hk/iohk-nix";
32-
iohk-nix-ng.url = "github:input-output-hk/iohk-nix/jl/peerSnapshotFile";
32+
iohk-nix-ng.url = "github:input-output-hk/iohk-nix";
3333

3434
# For tmp local faucet testing
3535
# cardano-faucet.url = "github:input-output-hk/cardano-faucet/jl/node-9.2";
@@ -58,12 +58,12 @@
5858
};
5959

6060
cardano-node-service = {
61-
url = "github:IntersectMBO/cardano-node/10.2.0";
61+
url = "github:IntersectMBO/cardano-node/10.2.1";
6262
flake = false;
6363
};
6464

6565
cardano-node-service-ng = {
66-
url = "github:IntersectMBO/cardano-node/10.2.0";
66+
url = "github:IntersectMBO/cardano-node/10.2.1";
6767
flake = false;
6868
};
6969

flake/nixosModules/module-aws-ec2.nix

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,31 @@
1212
{inputs, ...}: {
1313
flake.nixosModules.module-aws-ec2 = {lib, ...}: let
1414
inherit (lib) mkDefault mkOption types;
15-
inherit (types) anything nullOr str submodule;
15+
inherit (types) anything nullOr str;
1616
in {
1717
imports = [
1818
"${inputs.nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
1919
];
2020

2121
options = {
22-
aws = mkOption {
23-
default = null;
24-
type = types.nullOr (submodule {
25-
options = {
26-
instance = mkOption {
27-
type = anything;
28-
};
22+
aws = {
23+
instance = mkOption {
24+
type = anything;
25+
};
2926

30-
region = mkOption {
31-
type = str;
32-
};
27+
region = mkOption {
28+
type = str;
29+
};
3330

34-
route53 = mkOption {
35-
default = null;
36-
type = nullOr anything;
37-
};
38-
};
39-
40-
config = {
41-
instance.count = mkDefault 1;
42-
};
43-
});
31+
route53 = mkOption {
32+
default = null;
33+
type = nullOr anything;
34+
};
4435
};
4536
};
37+
38+
config = {
39+
aws.instance.count = mkDefault 1;
40+
};
4641
};
4742
}

flake/nixosModules/profile-aws-ec2-ephemeral.nix

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
# TODO: Move this to a docs generator
44
#
55
# Attributes available on nixos module import:
6-
# config.aws.ec2.ephemeral.enablePostMountService
7-
# config.aws.ec2.ephemeral.fsOpts
8-
# config.aws.ec2.ephemeral.fsType
9-
# config.aws.ec2.ephemeral.label
10-
# config.aws.ec2.ephemeral.mountPoint
11-
# config.aws.ec2.ephemeral.postMountScript
12-
# config.aws.ec2.ephemeral.postMountServiceName
13-
# config.aws.ec2.ephemeral.raidCfgFile
14-
# config.aws.ec2.ephemeral.raidDevice
15-
# config.aws.ec2.ephemeral.serviceName
16-
# config.aws.ec2.ephemeral.specialEphemeralInstanceTypePrefixes
17-
# config.aws.ec2.ephemeral.symlinkTarget
6+
# config.services.aws.ec2.ephemeral.enablePostMountService
7+
# config.services.aws.ec2.ephemeral.fsOpts
8+
# config.services.aws.ec2.ephemeral.fsType
9+
# config.services.aws.ec2.ephemeral.label
10+
# config.services.aws.ec2.ephemeral.mountPoint
11+
# config.services.aws.ec2.ephemeral.postMountScript
12+
# config.services.aws.ec2.ephemeral.postMountServiceName
13+
# config.services.aws.ec2.ephemeral.raidCfgFile
14+
# config.services.aws.ec2.ephemeral.raidDevice
15+
# config.services.aws.ec2.ephemeral.serviceName
16+
# config.services.aws.ec2.ephemeral.specialEphemeralInstanceTypePrefixes
17+
# config.services.aws.ec2.ephemeral.symlinkTarget
1818
#
1919
# Tips:
2020
# * This module modifies handles formatting and mounting of single or

flake/nixosModules/profile-cardano-node-group.nix

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# config.services.cardano-node.totalMaxHeapSizeMiB
88
# config.services.mithril-client.enable
99
# config.services.mithril-client.aggregatorEndpointUrl
10+
# config.services.mithril-client.allowedNetworks
1011
# config.services.mithril-client.genesisVerificationKey
1112
# config.services.mithril-client.snapshotDigest
1213
# config.services.mithril-client.verifyingPools
@@ -32,7 +33,7 @@
3233
nodeResources,
3334
...
3435
}: let
35-
inherit (builtins) fromJSON readFile;
36+
inherit (builtins) elem fromJSON readFile;
3637
inherit (lib) boolToString concatStringsSep flatten foldl' getExe min mkDefault mkIf mkOption optional optionalAttrs optionalString range recursiveUpdate types;
3738
inherit (types) bool float ints listOf oneOf str;
3839
inherit (nodeResources) cpuCount memMiB;
@@ -43,7 +44,7 @@
4344
inherit (nixos.config.cardano-parts.perNode.pkgs) cardano-cli cardano-node cardano-node-pkgs mithril-client-cli;
4445
inherit (cardanoLib) mkEdgeTopology mkEdgeTopologyP2P;
4546
inherit (cardanoLib.environments.${environmentName}.nodeConfig) ByronGenesisFile ShelleyGenesisFile;
46-
inherit (opsLib) mithrilVerifyingPools;
47+
inherit (opsLib) mithrilAllowedNetworks mithrilVerifyingPools;
4748
inherit ((fromJSON (readFile ByronGenesisFile)).protocolConsts) protocolMagic;
4849
inherit (fromJSON (readFile ShelleyGenesisFile)) slotsPerKESPeriod;
4950

@@ -87,6 +88,7 @@
8788
else legacyTopology;
8889

8990
iRange = range 0 (cfg.instances - 1);
91+
isMithrilEnv = cfgMithril.enable && elem environmentName cfgMithril.allowedNetworks;
9092

9193
cfg = nixos.config.services.cardano-node;
9294
cfgMithril = nixos.config.services.mithril-client;
@@ -137,6 +139,14 @@
137139
description = "The mithril aggregator endpoint url.";
138140
};
139141

142+
allowedNetworks = mkOption {
143+
type = listOf str;
144+
default = mithrilAllowedNetworks;
145+
description = ''
146+
A list of cardano networks permitted to use mithril snapshots.
147+
'';
148+
};
149+
140150
genesisVerificationKey = mkOption {
141151
type = str;
142152
default = cfg.environments.${environmentName}.mithrilGenesisVerificationKey or "";
@@ -184,7 +194,7 @@
184194
self'.packages.db-synthesizer-ng
185195
self'.packages.db-truncater-ng
186196
]
187-
++ optional cfgMithril.enable mithril-client-cli;
197+
++ optional isMithrilEnv mithril-client-cli;
188198

189199
environment = {
190200
shellAliases = {
@@ -211,9 +221,9 @@
211221
CARDANO_NODE_SOCKET_PATH = cfg.socketPath 0;
212222
TESTNET_MAGIC = toString protocolMagic;
213223
}
214-
// optionalAttrs cfgMithril.enable {
215-
AGGREGATOR_ENDPOINT = mkIf cfgMithril.enable cfgMithril.aggregatorEndpointUrl;
216-
GENESIS_VERIFICATION_KEY = mkIf cfgMithril.enable cfgMithril.genesisVerificationKey;
224+
// optionalAttrs isMithrilEnv {
225+
AGGREGATOR_ENDPOINT = cfgMithril.aggregatorEndpointUrl;
226+
GENESIS_VERIFICATION_KEY = cfgMithril.genesisVerificationKey;
217227
};
218228
};
219229

@@ -457,9 +467,9 @@
457467
serviceConfig = {
458468
ExecStartPre = getExe (pkgs.writeShellApplication {
459469
name = "cardano-node-pre-start";
460-
runtimeInputs = with pkgs; [curl gnugrep gnutar jq gzip] ++ optional cfgMithril.enable mithril-client-cli;
470+
runtimeInputs = with pkgs; [curl gnugrep gnutar jq gzip] ++ optional isMithrilEnv mithril-client-cli;
461471
text = let
462-
mithril-client-bootstrap = optionalString cfgMithril.enable ''
472+
mithril-client-bootstrap = optionalString isMithrilEnv ''
463473
if ! [ -d "$DB_DIR" ]; then
464474
DIGEST="${cfgMithril.snapshotDigest}"
465475
@@ -541,15 +551,19 @@
541551
}"
542552
cd "$STATE_DIRECTORY"
543553
544-
# Legacy: if a db-restore.tar.gz file exists, use it to replace state of the first node instance
554+
# Legacy: if a db-restore.tar.gz file exists, use it to
555+
# replace state of the first node instance.
545556
if [ -f db-restore.tar.gz ] && [ "$INSTANCE" == "0" ]; then
546557
echo "Restoring database from db-restore.tar.gz to $DB_DIR"
547558
rm -rf "$DB_DIR"
548559
tar xzf db-restore.tar.gz
549560
rm db-restore.tar.gz
550561
fi
551562
552-
# Mithril-client bootstrap code will follow if nixos option service.mithril-client.enable is true
563+
# Mithril-client bootstrap code will follow if nixos option
564+
# service.mithril-client.enable is true and the list of
565+
# nixos option service.mithril-client.allowedNetworks
566+
# includes this cardano configuration's network name.
553567
${mithril-client-bootstrap}
554568
'';
555569
});

flake/nixosModules/profile-common.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
};
115115

116116
# On boot SOPS runs in stage 2 without networking.
117-
# For repositories using KMS sops secrets, this prevent KMS from working,
117+
# For repositories using KMS sops secrets, this prevents KMS from working,
118118
# so we repeat the activation script until decryption succeeds.
119119
#
120120
# Sops-nix module does provide a systemd restart and reload hook for

flake/nixosModules/profile-grafana-alloy.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# Attributes available on nixos module import:
66
# config.services.alloy.enableLiveDebugging
7+
# config.services.alloy.extraAlloyConfig
78
# config.services.alloy.labels
89
# config.services.alloy.logLevel
910
# config.services.alloy.prometheusExporterUnixNodeSetCollectors
@@ -428,6 +429,14 @@ flake @ {moduleWithSystem, ...}: {
428429
description = "Whether to enable live debugging for grafana alloy.";
429430
};
430431

432+
extraAlloyConfig = mkOption {
433+
type = str;
434+
default = "";
435+
description = ''
436+
Extra configuration appended to the /etc/alloy/config.alloy file prior to formatting.
437+
'';
438+
};
439+
431440
labels = mkOption {
432441
type = attrsOf str;
433442
default = {
@@ -615,6 +624,7 @@ flake @ {moduleWithSystem, ...}: {
615624
++ cardanoPartsComponentCfg.nginxVts
616625
++ cardanoPartsComponentCfg.varnishCache
617626
)
627+
+ cfg.extraAlloyConfig
618628
);
619629
in
620630
(pkgs.runCommandNoCCLocal "alloy.config" {} ''

flakeModules/entrypoints.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ in {
99
system,
1010
...
1111
}: let
12-
inherit (builtins) attrNames;
12+
inherit (builtins) attrNames elem;
1313
inherit (lib) boolToString concatStringsSep escapeShellArgs getExe;
14-
inherit (opsLib) generateStaticHTMLConfigs mithrilVerifyingPools;
14+
inherit (opsLib) generateStaticHTMLConfigs mithrilAllowedNetworks mithrilVerifyingPools;
1515

1616
cardanoLib = flake.config.flake.cardano-parts.pkgs.special.cardanoLib system;
1717
cardanoLibNg = flake.config.flake.cardano-parts.pkgs.special.cardanoLibNg system;
@@ -23,6 +23,10 @@ in {
2323
copyEnvsTemplate = cardanoLib: let
2424
inherit (cardanoLib) environments;
2525
envCfgs = generateStaticHTMLConfigs pkgs cardanoLib environments;
26+
isMithrilEnv = env:
27+
boolToString (
28+
environments.${env} ? mithrilAggregatorEndpointUrl && elem env mithrilAllowedNetworks
29+
);
2630
in ''
2731
# Prepare standard env configs
2832
ENVS=(${escapeShellArgs (attrNames environments)})
@@ -37,7 +41,7 @@ in {
3741
map (
3842
env:
3943
"declare -A MITHRIL_CFG_${env}\n"
40-
+ "MITHRIL_CFG_${env}[MITHRIL_ENV]=\"${boolToString (environments.${env} ? mithrilAggregatorEndpointUrl)}\"\n"
44+
+ "MITHRIL_CFG_${env}[MITHRIL_ENV]=\"${isMithrilEnv env}\"\n"
4145
+ "MITHRIL_CFG_${env}[AGG_ENDPOINT]=\"${environments.${env}.mithrilAggregatorEndpointUrl or ""}\"\n"
4246
+ "MITHRIL_CFG_${env}[GENESIS_VKEY]=\"${environments.${env}.mithrilGenesisVerificationKey or ""}\"\n"
4347
+ "MITHRIL_CFG_${env}[VERIFYING_POOLS]=\"${concatStringsSep "|" (mithrilVerifyingPools.${env} or [])}\"\n"

0 commit comments

Comments
 (0)