Skip to content

Commit

Permalink
feat: Allow configurable erigon, geth, nethermind datadir (#451)
Browse files Browse the repository at this point in the history
feat: Allow configurable erigon,geth,nethermind datadir

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
iofq and mergify[bot] authored Feb 2, 2024
1 parent f8690d9 commit b85be0f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
6 changes: 6 additions & 0 deletions modules/erigon/args.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
lib:
with lib; {
datadir = mkOption {
type = types.nullOr types.str;
default = null;
description = mdDoc "Data directory for Erigon. Defaults to '%S/erigon-\<name\>', which generally resolves to /var/lib/erigon-\<name\>.";
};

port = mkOption {
type = types.port;
default = 30303;
Expand Down
6 changes: 5 additions & 1 deletion modules/erigon/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ in {
inherit pathReducer opts;
inherit (cfg) args;
};
datadir =
if cfg.args.datadir != null
then "--datadir ${cfg.args.datadir}"
else "--datadir %S/${serviceName}";
in ''
--datadir %S/${serviceName} \
${datadir} \
${concatStringsSep " \\\n" args} \
${lib.escapeShellArgs cfg.extraArgs}
'';
Expand Down
6 changes: 6 additions & 0 deletions modules/geth/args.nix
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,10 @@ with lib; {
default = 50;
description = mdDoc "Maximum peers to connect to.";
};

datadir = mkOption {
type = types.nullOr types.str;
default = null;
description = mdDoc "Data directory for Geth. Defaults to '%S/geth-\<name\>', which generally resolves to /var/lib/geth-\<name\>.";
};
}
7 changes: 6 additions & 1 deletion modules/geth/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ in {
if cfg.args.authrpc.jwtsecret != null
then "--authrpc.jwtsecret %d/jwtsecret"
else "";

datadir =
if cfg.args.datadir != null
then "--datadir ${cfg.args.datadir}"
else "--datadir %S/${serviceName}";
in ''
${datadir} \
--ipcdisable ${network} ${jwtSecret} \
--datadir %S/${serviceName} \
${concatStringsSep " \\\n" filteredArgs} \
${lib.escapeShellArgs cfg.extraArgs}
'';
Expand Down
6 changes: 6 additions & 0 deletions modules/nethermind/args.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ with lib; {
description = mdDoc "Changes the source directory of your configuration files.";
};

datadir = mkOption {
type = types.nullOr types.str;
default = null;
description = mdDoc "Data directory for Nethermind. Defaults to '%S/nethermind-\<name\>', which generally resolves to /var/lib/nethermind-\<name\>.";
};

log = mkOption {
type = types.enum [
"OFF"
Expand Down
6 changes: 5 additions & 1 deletion modules/nethermind/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ in {
if cfg.args.modules.JsonRpc.JwtSecretFile != null
then "--JsonRpc.JwtSecretFile %d/jwtsecret"
else "";
datadir =
if cfg.args.datadir != null
then "--datadir ${cfg.args.datadir}"
else "--datadir %S/${serviceName}";

# generate flags
args = let
Expand All @@ -110,7 +114,7 @@ in {

filteredArgs = builtins.filter isNormalArg args;
in ''
--datadir %S/${serviceName} \
${datadir}
${jwtSecret} \
${concatStringsSep " \\\n" filteredArgs} \
${lib.escapeShellArgs cfg.extraArgs}
Expand Down

0 comments on commit b85be0f

Please sign in to comment.