Skip to content

Commit e7fe1d0

Browse files
MartinNikovPetarKirov
authored andcommitted
feat(modules/nimbus-eth2): Add keymanager options
1 parent 09576c9 commit e7fe1d0

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

modules/nimbus-eth2/args.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,31 @@ with lib; {
135135
description = mdDoc "Payload builder URL.";
136136
};
137137
};
138+
139+
keymanager = {
140+
enable = lib.mkEnableOption (mdDoc "Enable the REST keymanager API");
141+
address = mkOption {
142+
type = types.str;
143+
default = "127.0.0.1";
144+
description = mdDoc "Listening port for the REST keymanager API.";
145+
};
146+
147+
port = mkOption {
148+
type = types.port;
149+
default = 5052;
150+
description = mdDoc "Listening port for the REST keymanager API.";
151+
};
152+
153+
allow-origin = mkOption {
154+
type = types.nullOr types.str;
155+
default = null;
156+
description = mdDoc "Limit the access to the Keymanager API to a particular hostname (for CORS-enabled clients such as browsers).";
157+
};
158+
159+
token-file = mkOption {
160+
type = types.nullOr types.path;
161+
default = null;
162+
description = mdDoc "A file specifying the authorization token required for accessing the keymanager API.";
163+
};
164+
};
138165
}

modules/nimbus-eth2/default.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ in {
7474
then ''--jwt-secret="%d/jwt-secret"''
7575
else "";
7676

77+
keymanagerTokenFile =
78+
if cfg.args.keymanager.token-file != null
79+
then ''--keymanager-token-file="%d/keymanager-token-file"''
80+
else "";
81+
7782
trustedNodeUrl =
7883
if cfg.args.trusted-node-url != null
7984
then ''--trusted-node-url="${cfg.args.trusted-node-url}"''
@@ -134,13 +139,14 @@ in {
134139
inherit pathReducer;
135140
};
136141
# filter out certain args which need to be treated differently
137-
specialArgs = ["--network" "--jwt-secret" "--web3-urls" "--trusted-node-url" "--backfill" "--payload-builder"];
142+
specialArgs = ["--network" "--jwt-secret" "--web3-urls" "--trusted-node-url" "--backfill" "--payload-builder" "--keymanager-token-file"];
138143
isNormalArg = name: (findFirst (arg: hasPrefix arg name) null specialArgs) == null;
139144
filteredArgs = builtins.filter isNormalArg args;
140145
in ''
141146
${network} ${jwtSecret} \
142147
${web3Url} \
143148
${dataDir} \
149+
${keymanagerTokenFile} \
144150
${payloadBuilder} \
145151
${concatStringsSep " \\\n" filteredArgs} \
146152
${lib.escapeShellArgs cfg.extraArgs}
@@ -193,6 +199,9 @@ in {
193199
(mkIf (cfg.args.jwt-secret != null) {
194200
LoadCredential = ["jwt-secret:${cfg.args.jwt-secret}"];
195201
})
202+
(mkIf (cfg.args.keymanager.token-file != null) {
203+
LoadCredential = ["keymanager-token-file:${cfg.args.keymanager.token-file}"];
204+
})
196205
];
197206
})
198207
)

0 commit comments

Comments
 (0)