Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions modules/geth/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
flatten
mapAttrs'
mapAttrsToList
mkDefault
mkForce
mkIf
mkMerge
nameValuePair
Expand Down Expand Up @@ -121,13 +123,24 @@ in {
serviceConfig = mkMerge [
baseServiceConfig
{
User = serviceName;
StateDirectory = serviceName;
ExecStart = "${cfg.package}/bin/geth ${scriptArgs}";
User =
if cfg.user != null
then cfg.user
else mkDefault serviceName;
StateDirectory = mkDefault serviceName;
ExecStart = mkDefault "${cfg.package}/bin/geth ${scriptArgs}";
}
(mkIf (cfg.args.authrpc.jwtsecret != null) {
LoadCredential = ["jwtsecret:${cfg.args.authrpc.jwtsecret}"];
})
(mkIf (!cfg.dynamicUser) {
DynamicUser = mkForce false;
RemoveIPC = mkDefault true;
PrivateTmp = mkDefault true;
NoNewPrivileges = mkDefault "strict";
RestrictSUIDSGID = mkDefault true;
ProtectSystem = mkDefault true;
})
];
})
)
Expand Down
12 changes: 12 additions & 0 deletions modules/geth/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

inherit args;

dynamicUser = mkOption {
type = types.bool;
default = true;
description = "Whether to use systemd's DynamicUser feature.";
};

user = mkOption {
type = types.nullOr types.str;
default = null;
description = "User to run the service as.";
};

extraArgs = mkOption {
type = types.listOf types.str;
description = "Additional arguments to pass to Go Ethereum.";
Expand Down