2022-11-05 04:16:56 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.erigon;
|
|
|
|
|
|
|
|
settingsFormat = pkgs.formats.toml { };
|
|
|
|
configFile = settingsFormat.generate "config.toml" cfg.settings;
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.erigon = {
|
2024-08-28 19:18:55 +00:00
|
|
|
enable = lib.mkEnableOption "Ethereum implementation on the efficiency frontier";
|
2022-11-05 04:16:56 +00:00
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
package = lib.mkPackageOption pkgs "erigon" { };
|
2023-10-29 08:18:15 +00:00
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
extraArgs = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2022-11-28 10:17:02 +00:00
|
|
|
description = "Additional arguments passed to Erigon";
|
|
|
|
default = [ ];
|
|
|
|
};
|
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
secretJwtPath = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
2022-11-07 12:36:28 +00:00
|
|
|
description = ''
|
2022-11-12 18:01:24 +00:00
|
|
|
Path to the secret jwt used for the http api authentication.
|
2022-11-07 12:36:28 +00:00
|
|
|
'';
|
2022-11-12 18:01:24 +00:00
|
|
|
default = "";
|
|
|
|
example = "config.age.secrets.ERIGON_JWT.path";
|
2022-11-07 12:36:28 +00:00
|
|
|
};
|
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
settings = lib.mkOption {
|
2022-11-05 04:16:56 +00:00
|
|
|
description = ''
|
|
|
|
Configuration for Erigon
|
|
|
|
Refer to <https://github.com/ledgerwatch/erigon#usage> for details on supported values.
|
|
|
|
'';
|
|
|
|
|
|
|
|
type = settingsFormat.type;
|
|
|
|
|
|
|
|
example = {
|
|
|
|
datadir = "/var/lib/erigon";
|
|
|
|
chain = "mainnet";
|
|
|
|
http = true;
|
|
|
|
"http.port" = 8545;
|
|
|
|
"http.api" = ["eth" "debug" "net" "trace" "web3" "erigon"];
|
|
|
|
ws = true;
|
|
|
|
port = 30303;
|
|
|
|
"authrpc.port" = 8551;
|
|
|
|
"torrent.port" = 42069;
|
|
|
|
"private.api.addr" = "localhost:9090";
|
|
|
|
"log.console.verbosity" = 3; # info
|
|
|
|
};
|
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
defaultText = lib.literalExpression ''
|
2022-11-05 04:16:56 +00:00
|
|
|
{
|
|
|
|
datadir = "/var/lib/erigon";
|
|
|
|
chain = "mainnet";
|
|
|
|
http = true;
|
|
|
|
"http.port" = 8545;
|
|
|
|
"http.api" = ["eth" "debug" "net" "trace" "web3" "erigon"];
|
|
|
|
ws = true;
|
|
|
|
port = 30303;
|
|
|
|
"authrpc.port" = 8551;
|
|
|
|
"torrent.port" = 42069;
|
|
|
|
"private.api.addr" = "localhost:9090";
|
|
|
|
"log.console.verbosity" = 3; # info
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-28 19:18:55 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2022-11-05 04:16:56 +00:00
|
|
|
# Default values are the same as in the binary, they are just written here for convenience.
|
|
|
|
services.erigon.settings = {
|
2024-08-28 19:18:55 +00:00
|
|
|
datadir = lib.mkDefault "/var/lib/erigon";
|
|
|
|
chain = lib.mkDefault "mainnet";
|
|
|
|
http = lib.mkDefault true;
|
|
|
|
"http.port" = lib.mkDefault 8545;
|
|
|
|
"http.api" = lib.mkDefault ["eth" "debug" "net" "trace" "web3" "erigon"];
|
|
|
|
ws = lib.mkDefault true;
|
|
|
|
port = lib.mkDefault 30303;
|
|
|
|
"authrpc.port" = lib.mkDefault 8551;
|
|
|
|
"torrent.port" = lib.mkDefault 42069;
|
|
|
|
"private.api.addr" = lib.mkDefault "localhost:9090";
|
|
|
|
"log.console.verbosity" = lib.mkDefault 3; # info
|
2022-11-05 04:16:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.erigon = {
|
|
|
|
description = "Erigon ethereum implemenntation";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
2022-11-12 18:01:24 +00:00
|
|
|
LoadCredential = "ERIGON_JWT:${cfg.secretJwtPath}";
|
2023-10-29 08:18:15 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/erigon --config ${configFile} --authrpc.jwtsecret=%d/ERIGON_JWT ${lib.escapeShellArgs cfg.extraArgs}";
|
2022-11-12 18:01:24 +00:00
|
|
|
DynamicUser = true;
|
2022-11-05 04:16:56 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
StateDirectory = "erigon";
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectProc = "noaccess";
|
|
|
|
ProcSubset = "pid";
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
RemoveIPC = true;
|
|
|
|
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|