···
-
cfg = config.services.rippled;
-
opt = options.services.rippled;
-
b2i = val: if val then "1" else "0";
-
${lib.optionalString (db.compression != null) ("compression=${b2i db.compression}")}
-
${lib.optionalString (db.onlineDelete != null) ("online_delete=${toString db.onlineDelete}")}
-
${lib.optionalString (db.advisoryDelete != null) ("advisory_delete=${b2i db.advisoryDelete}")}
-
${lib.concatMapStringsSep "\n" (n: "port_${n}") (lib.attrNames cfg.ports)}
-
${lib.concatMapStrings (p: ''
-
port=${toString p.port}
-
protocol=${lib.concatStringsSep "," p.protocol}
-
${lib.optionalString (p.user != "") "user=${p.user}"}
-
${lib.optionalString (p.password != "") "user=${p.password}"}
-
admin=${lib.concatStringsSep "," p.admin}
-
${lib.optionalString (p.ssl.key != null) "ssl_key=${p.ssl.key}"}
-
${lib.optionalString (p.ssl.cert != null) "ssl_cert=${p.ssl.cert}"}
-
${lib.optionalString (p.ssl.chain != null) "ssl_chain=${p.ssl.chain}"}
-
'') (lib.attrValues cfg.ports)}
-
${lib.optionalString (cfg.tempDb != null) ''
-
${lib.optionalString (cfg.importDb != null) ''
-
${dbCfg cfg.importDb}''}
-
${lib.concatStringsSep "\n" cfg.ips}
-
${lib.concatStringsSep "\n" cfg.ipsFixed}
-
${lib.concatStringsSep "\n" cfg.validators}
-
${toString cfg.ledgerHistory}
-
${toString cfg.fetchDepth}
-
${toString cfg.validationQuorum}
-
${lib.concatStringsSep "\n" cfg.sntpServers}
-
${lib.optionalString cfg.statsd.enable ''
-
address=${cfg.statsd.address}
-
prefix=${cfg.statsd.prefix}
-
{ "command": "log_level", "severity": "${cfg.logLevel}" }
-
description = "Ip where rippled listens.";
-
description = "Port where rippled listens.";
-
protocol = lib.mkOption {
-
description = "Protocols expose by rippled.";
-
type = lib.types.listOf (
-
description = "When set, these credentials will be required on HTTP/S requests.";
-
password = lib.mkOption {
-
description = "When set, these credentials will be required on HTTP/S requests.";
-
description = "A comma-separated list of admin IP addresses.";
-
type = lib.types.listOf lib.types.str;
-
default = [ "127.0.0.1" ];
-
Specifies the filename holding the SSL key in PEM format.
-
type = lib.types.nullOr lib.types.path;
-
Specifies the path to the SSL certificate file in PEM format.
-
This is not needed if the chain includes it.
-
type = lib.types.nullOr lib.types.path;
-
If you need a certificate chain, specify the path to the
-
certificate chain here. The chain may include the end certificate.
-
type = lib.types.nullOr lib.types.path;
-
description = "Rippled database type.";
-
type = lib.types.enum [
-
description = "Location to store the database.";
-
default = cfg.databasePath;
-
defaultText = lib.literalExpression "config.${opt.databasePath}";
-
compression = lib.mkOption {
-
description = "Whether to enable snappy compression.";
-
type = lib.types.nullOr lib.types.bool;
-
onlineDelete = lib.mkOption {
-
description = "Enable automatic purging of older ledger information.";
-
type = lib.types.nullOr (lib.types.addCheck lib.types.int (v: v > 256));
-
default = cfg.ledgerHistory;
-
defaultText = lib.literalExpression "config.${opt.ledgerHistory}";
-
advisoryDelete = lib.mkOption {
-
If set, then require administrative RPC call "can_delete"
-
to enable online deletion of ledger records.
-
type = lib.types.nullOr lib.types.bool;
-
extraOpts = lib.mkOption {
-
description = "Extra database options.";
-
type = lib.types.lines;
-
enable = lib.mkEnableOption "rippled, a decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++";
-
package = lib.mkPackageOption pkgs "rippled" { };
-
description = "Ports exposed by rippled";
-
type = with lib.types; attrsOf (submodule portOptions);
-
admin = [ "127.0.0.1" ];
-
nodeDb = lib.mkOption {
-
description = "Rippled main database options.";
-
type = with lib.types; nullOr (submodule dbOptions);
-
tempDb = lib.mkOption {
-
description = "Rippled temporary database options.";
-
type = with lib.types; nullOr (submodule dbOptions);
-
importDb = lib.mkOption {
-
description = "Settings for performing a one-time import.";
-
type = with lib.types; nullOr (submodule dbOptions);
-
nodeSize = lib.mkOption {
-
Rippled size of the node you are running.
-
"tiny", "small", "medium", "large", and "huge"
-
type = lib.types.enum [
-
List of hostnames or ips where the Ripple protocol is served.
-
For a starter list, you can either copy entries from:
-
https://ripple.com/ripple.txt or if you prefer you can let it
-
default to r.ripple.com 51235
-
A port may optionally be specified after adding a space to the
-
address. By convention, if known, IPs are listed in from most
-
type = lib.types.listOf lib.types.str;
-
default = [ "r.ripple.com 51235" ];
-
ipsFixed = lib.mkOption {
-
List of IP addresses or hostnames to which rippled should always
-
attempt to maintain peer connections with. This is useful for
-
manually forming private networks, for example to configure a
-
validation server that connects to the Ripple network through a
-
public-facing server, or for building a set of cluster peers.
-
A port may optionally be specified after adding a space to the address
-
type = lib.types.listOf lib.types.str;
-
validators = lib.mkOption {
-
List of nodes to always accept as validators. Nodes are specified by domain
-
type = lib.types.listOf lib.types.str;
-
"n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7 RL1"
-
"n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj RL2"
-
"n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C RL3"
-
"n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS RL4"
-
"n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA RL5"
-
databasePath = lib.mkOption {
-
Path to the ripple database.
-
default = "/var/lib/rippled";
-
validationQuorum = lib.mkOption {
-
The minimum number of trusted validations a ledger must have before
-
the server considers it fully validated.
-
ledgerHistory = lib.mkOption {
-
The number of past ledgers to acquire on server startup and the minimum
-
to maintain while running.
-
type = lib.types.either lib.types.int (lib.types.enum [ "full" ]);
-
default = 1296000; # 1 month
-
fetchDepth = lib.mkOption {
-
The number of past ledgers to serve to other peers that request historical
-
ledger data (or "full" for no limit).
-
type = lib.types.either lib.types.int (lib.types.enum [ "full" ]);
-
sntpServers = lib.mkOption {
-
IP address or domain of NTP servers to use for time synchronization.;
-
type = lib.types.listOf lib.types.str;
-
logLevel = lib.mkOption {
-
description = "Logging verbosity.";
-
type = lib.types.enum [
-
enable = lib.mkEnableOption "statsd monitoring for rippled";
-
address = lib.mkOption {
-
description = "The UDP address and port of the listening StatsD server.";
-
default = "127.0.0.1:8125";
-
prefix = lib.mkOption {
-
description = "A string prepended to each collected metric.";
-
extraConfig = lib.mkOption {
-
type = lib.types.lines;
-
Extra lines to be added verbatim to the rippled.cfg configuration file.
-
config = lib.mkOption {
-
default = pkgs.writeText "rippled.conf" rippledCfg;
-
defaultText = lib.literalMD "generated config file";
-
config = lib.mkIf cfg.enable {
-
users.users.rippled = {
-
description = "Ripple server user";
-
home = cfg.databasePath;
-
users.groups.rippled = { };
-
systemd.services.rippled = {
-
after = [ "network.target" ];
-
wantedBy = [ "multi-user.target" ];
-
ExecStart = "${cfg.package}/bin/rippled --fg --conf ${cfg.config}";
-
Restart = "on-failure";
-
environment.systemPackages = [ cfg.package ];