Skip to content

Commit

Permalink
fix (again) datadir and jwtsecret special args in erigon
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Warfield committed Mar 14, 2024
1 parent 74c6018 commit ad561e4
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions modules/erigon/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ in {
cfg: let
scriptArgs = let
# replace enable flags like --http.enable with just --http
pathReducer = path: let
arg = concatStringsSep "." (lib.lists.remove "enable" path);
in "--${arg}";
pathReducer =
path:
let arg = concatStringsSep "." (lib.lists.remove "enable" path);
in "--${arg}";

# generate flags
args = let
Expand All @@ -83,13 +84,26 @@ in {
inherit pathReducer opts;
inherit (cfg) args;
};

specialArgs = ["--authrpc.jwtsecret" "--dataDir"];
isNormalArg = name: (findFirst (arg: hasPrefix arg name) null specialArgs) == null;
filteredArgs = builtins.filter isNormalArg args;

# If provided, load from systemd credentials dir (see LoadCredential below).
jwtsecret =
if cfg.args.authrpc.jwtsecret != null
then "--authrpc.jwtsecret %d/jwt-secret"
else "";
# If provided: use the provided path. If not: use the systemd statedir
datadir =
if cfg.args.datadir != null
then "--datadir ${cfg.args.datadir}"
else "--datadir %S/${serviceName}";
if cfg.args.dataDir != null
then cfg.args.dataDir
else "%S/${serviceName}";

in ''
${datadir} \
${concatStringsSep " \\\n" args} \
--datadir ${datadir} \
${jwtsecret}
${concatStringsSep " \\\n" filteredArgs} \
${lib.escapeShellArgs cfg.extraArgs}
'';
in
Expand Down

0 comments on commit ad561e4

Please sign in to comment.