File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 2020 ./restore
2121 ./reth
2222 ./nimbus
23+ ./nimbus-validator
2324 ] ;
2425 } ;
2526}
Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ ...
6+ } : let
7+ inherit
8+ ( lib )
9+ mapAttrs'
10+ mkIf
11+ mkMerge
12+ nameValuePair
13+ ;
14+
15+ modulesLib = import ../lib.nix lib ;
16+ inherit ( modulesLib ) baseServiceConfig ;
17+
18+ eachNimbusValidator = config . services . ethereum . nimbus-validator ;
19+ in {
20+ ###### interface
21+ inherit ( import ./options.nix { inherit lib pkgs ; } ) options ;
22+
23+ ###### implementation
24+
25+ config = mkIf ( eachNimbusValidator != { } ) {
26+ # create a service for each instance
27+ systemd . services =
28+ mapAttrs' (
29+ nimbusValidatorName : let
30+ serviceName = "nimbus-validator-${ nimbusValidatorName } " ;
31+ in
32+ cfg :
33+ nameValuePair serviceName ( mkIf cfg . enable {
34+ after = [ "network.target" ] ;
35+ wantedBy = [ "multi-user.target" ] ;
36+ description = "Nimbus Validator Client (${ nimbusValidatorName } )" ;
37+
38+ # create service config by merging with the base config
39+ serviceConfig = mkMerge [
40+ baseServiceConfig
41+ {
42+ User =
43+ if cfg . user != null
44+ then cfg . user
45+ else serviceName ;
46+ StateDirectory = serviceName ;
47+ ExecStart = "${ cfg . package } /bin/nimbus_validator_client ${ lib . escapeShellArgs cfg . extraArgs } " ;
48+ MemoryDenyWriteExecute = "false" ;
49+ }
50+ ] ;
51+ } )
52+ )
53+ eachNimbusValidator ;
54+ } ;
55+ }
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ pkgs ,
4+ ...
5+ } : let
6+ nimbusValidatorOpts = with lib ; {
7+ options = {
8+ enable = mkEnableOption "Nimbus Validator Client." ;
9+
10+ package = mkOption {
11+ type = types . package ;
12+ default = pkgs . nimbus ;
13+ defaultText = literalExpression "pkgs.nimbus" ;
14+ description = "Package to use as Nimbus Validator Client." ;
15+ } ;
16+
17+ extraArgs = mkOption {
18+ type = types . listOf types . str ;
19+ description = "Additional arguments to pass to Nimbus Validator Client." ;
20+ default = [ ] ;
21+ } ;
22+
23+ user = mkOption {
24+ type = types . nullOr types . str ;
25+ description = "Service user" ;
26+ } ;
27+ } ;
28+ } ;
29+ in {
30+ options . services . ethereum . nimbus-validator = with lib ;
31+ mkOption {
32+ type = types . attrsOf ( types . submodule nimbusValidatorOpts ) ;
33+ default = { } ;
34+ description = "Specification of one or more Nimbus Validator Client instances." ;
35+ } ;
36+ }
You can’t perform that action at this time.
0 commit comments