File tree Expand file tree Collapse file tree 4 files changed +142
-0
lines changed Expand file tree Collapse file tree 4 files changed +142
-0
lines changed Original file line number Diff line number Diff line change 1919 ./prysm-validator
2020 ./restore
2121 ./reth
22+ ./nimbus
2223 ] ;
2324 } ;
2425}
Original file line number Diff line number Diff line change 1+ lib :
2+ with lib ; {
3+ port = mkOption {
4+ type = types . int ;
5+ description = "Port to open" ;
6+ } ;
7+ network = mkOption {
8+ type = types . str ;
9+ description = "Network" ;
10+ } ;
11+ jwtsecret = mkOption {
12+ type = types . nullOr types . str ;
13+ default = null ;
14+ description = "Path to the token that ensures safe connection between CL and EL." ;
15+ } ;
16+ }
Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ ...
6+ } : let
7+ inherit
8+ ( builtins )
9+ toString
10+ ;
11+ inherit
12+ ( lib )
13+ filterAttrs
14+ flatten
15+ mapAttrs'
16+ mapAttrsToList
17+ mkIf
18+ mkMerge
19+ nameValuePair
20+ zipAttrsWith
21+ ;
22+
23+ modulesLib = import ../lib.nix lib ;
24+ inherit ( modulesLib ) baseServiceConfig ;
25+
26+ eachNimbus = config . services . ethereum . nimbus ;
27+ in {
28+ ###### interface
29+ inherit ( import ./options.nix { inherit lib pkgs ; } ) options ;
30+
31+ ###### implementation
32+
33+ config = mkIf ( eachNimbus != { } ) {
34+ # configure the firewall for each service
35+ networking . firewall = let
36+ openFirewall = filterAttrs ( _ : cfg : cfg . openFirewall ) eachNimbus ;
37+ perService =
38+ mapAttrsToList
39+ (
40+ _ : cfg :
41+ with cfg . args ; {
42+ allowedUDPPorts = [ port ] ;
43+ allowedTCPPorts = [ port ] ;
44+ }
45+ )
46+ openFirewall ;
47+ in
48+ zipAttrsWith ( _name : flatten ) perService ;
49+
50+ # create a service for each instance
51+ systemd . services =
52+ mapAttrs' (
53+ nimbusName : let
54+ serviceName = "nimbus-${ nimbusName } " ;
55+ in
56+ cfg :
57+ nameValuePair serviceName ( mkIf cfg . enable {
58+ after = [ "network.target" ] ;
59+ wantedBy = [ "multi-user.target" ] ;
60+ description = "Nimbus Node (${ nimbusName } )" ;
61+
62+ # create service config by merging with the base config
63+ serviceConfig = mkMerge [
64+ baseServiceConfig
65+ {
66+ User =
67+ if cfg . user != null
68+ then cfg . user
69+ else serviceName ;
70+ StateDirectory = serviceName ;
71+ ExecStart = "${ cfg . package } /bin/nimbus_beacon_node --tcp-port=${ builtins . toString cfg . args . port } --network=${ cfg . args . network } --jwt-secret=${ cfg . args . jwtsecret } --udp-port=${ builtins . toString cfg . args . port } ${ lib . escapeShellArgs cfg . extraArgs } " ;
72+ MemoryDenyWriteExecute = "false" ;
73+ }
74+ ] ;
75+ } )
76+ )
77+ eachNimbus ;
78+ } ;
79+ }
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ pkgs ,
4+ ...
5+ } : let
6+ args = import ./args.nix lib ;
7+
8+ nimbusOpts = with lib ; {
9+ options = {
10+ enable = mkEnableOption "Nimbus Ethereum Node." ;
11+
12+ package = mkOption {
13+ type = types . package ;
14+ default = pkgs . nimbus ;
15+ defaultText = literalExpression "pkgs.nimbus" ;
16+ description = "Package to use as Nimbus." ;
17+ } ;
18+
19+ inherit args ;
20+
21+ extraArgs = mkOption {
22+ type = types . listOf types . str ;
23+ description = "Additional arguments to pass to Nimbus." ;
24+ default = [ ] ;
25+ } ;
26+
27+ user = mkOption {
28+ type = types . nullOr types . str ;
29+ description = "Service user" ;
30+ } ;
31+
32+ openFirewall = mkOption {
33+ type = types . bool ;
34+ default = false ;
35+ description = "Open ports in the firewall for any enabled networking services" ;
36+ } ;
37+ } ;
38+ } ;
39+ in {
40+ options . services . ethereum . nimbus = with lib ;
41+ mkOption {
42+ type = types . attrsOf ( types . submodule nimbusOpts ) ;
43+ default = { } ;
44+ description = "Specification of one or more Nimbus instances." ;
45+ } ;
46+ }
You can’t perform that action at this time.
0 commit comments