Skip to content

Commit 20a437a

Browse files
authored
feat(unionvisor): symlink config.toml app.toml client.toml (#1319)
2 parents aaa53f8 + 6c7cc1a commit 20a437a

File tree

1 file changed

+53
-28
lines changed

1 file changed

+53
-28
lines changed

unionvisor/unionvisor.nix

+53-28
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,46 @@
136136
type = types.str;
137137
default = "b4d587b3d3666d52df0cd43962080fd164568fe0@union-testnet.cor.systems:26656";
138138
};
139-
node-key-file = mkOption {
139+
node-key-json = mkOption {
140140
description = lib.mdDoc ''
141141
Path to a node_key.json file.
142142
'';
143143
example = "/run/secrets/node_key.json";
144144
type = types.nullOr types.path;
145145
default = null;
146146
};
147-
priv-validator-key-file = mkOption {
147+
priv-validator-key-json = mkOption {
148148
description = lib.mdDoc ''
149149
Path to a priv_validator_key.json file.
150150
'';
151151
example = "/run/secrets/priv_validator_key.json";
152152
type = types.nullOr types.path;
153153
default = null;
154154
};
155+
app-toml = mkOption {
156+
description = lib.mdDoc ''
157+
Path to an app.toml file.
158+
'';
159+
example = "/some/app.toml";
160+
type = types.nullOr types.path;
161+
default = null;
162+
};
163+
config-toml = mkOption {
164+
description = lib.mdDoc ''
165+
Path to an config.toml file.
166+
'';
167+
example = "/some/config.toml";
168+
type = types.nullOr types.path;
169+
default = null;
170+
};
171+
client-toml = mkOption {
172+
description = lib.mdDoc ''
173+
Path to an client.toml file.
174+
'';
175+
example = "/some/client.toml";
176+
type = types.nullOr types.path;
177+
default = null;
178+
};
155179
};
156180

157181
config = mkIf cfg.enable {
@@ -164,35 +188,36 @@
164188
unionvisor-systemd-script = pkgs.writeShellApplication {
165189
name = "unionvisor-systemd";
166190
runtimeInputs = [ pkgs.coreutils wrappedUnionvisor ];
167-
text = ''
168-
${pkgs.coreutils}/bin/mkdir -p /var/lib/unionvisor
169-
cd /var/lib/unionvisor
170-
unionvisor init --moniker ${cfg.moniker} --seeds ${cfg.seeds} --network ${cfg.network} --allow-dirty
171-
172-
''
173-
174-
# symlink node_key.json if supplied
175-
+ (pkgs.lib.optionalString (cfg.node-key-file != null)
176-
''
177-
178-
rm ./home/config/node_key.json
179-
ln -s ${cfg.node-key-file} ./home/config/node_key.json
180-
181-
'')
182-
183-
# symlink priv_validator_key.json if supplied
184-
+ (pkgs.lib.optionalString (cfg.priv-validator-key-file != null)
191+
text =
192+
let
193+
configSymlinks = [
194+
{ name = "node_key.json"; path = cfg.node-key-json; }
195+
{ name = "priv_validator_key.json"; path = cfg.priv-validator-key-json; }
196+
{ name = "app.toml"; path = cfg.app-toml; }
197+
{ name = "client.toml"; path = cfg.client-toml; }
198+
{ name = "config.toml"; path = cfg.config-toml; }
199+
];
200+
201+
configSymLinkCommands = builtins.lib.concatMapStrings
202+
(l:
203+
''
204+
205+
rm ./home/config/${l.name}
206+
ln -s ${l.path} ./home/config/${l.name}
207+
208+
'')
209+
(builtins.filter (l: l.path != null) configSymlinks);
210+
211+
in
185212
''
213+
${pkgs.coreutils}/bin/mkdir -p /var/lib/unionvisor
214+
cd /var/lib/unionvisor
215+
unionvisor init --moniker ${cfg.moniker} --seeds ${cfg.seeds} --network ${cfg.network} --allow-dirty
186216
187-
rm ./home/config/priv_validator_key.json
188-
ln -s ${cfg.priv-validator-key-file} ./home/config/priv_validator_key.json
189-
190-
'')
191-
+
192-
''
217+
${configSymLinkCommands}
193218
194-
unionvisor run
195-
'';
219+
unionvisor run
220+
'';
196221
};
197222
in
198223
{

0 commit comments

Comments
 (0)