rtl: add option extraConfig
for nodes
Also define rtl config as a Nix attrset that is converted to JSON
This commit is contained in:
parent
ff228a604d
commit
3755b3ebea
113
modules/rtl.nix
113
modules/rtl.nix
@ -26,6 +26,19 @@ let
|
|||||||
default = false;
|
default = false;
|
||||||
description = "Enable the clightning node interface.";
|
description = "Enable the clightning node interface.";
|
||||||
};
|
};
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
Settings.userPersona = "MERCHANT";
|
||||||
|
Settings.logLevel = "DEBUG";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Extra clightning node configuration.
|
||||||
|
See here for all available options:
|
||||||
|
https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
lnd = {
|
lnd = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
@ -38,6 +51,19 @@ let
|
|||||||
default = false;
|
default = false;
|
||||||
description = "Enable swaps with lightning-loop.";
|
description = "Enable swaps with lightning-loop.";
|
||||||
};
|
};
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
Settings.userPersona = "MERCHANT";
|
||||||
|
Settings.logLevel = "DEBUG";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Extra lnd node configuration.
|
||||||
|
See here for all available options:
|
||||||
|
https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
reverseOrder = mkOption {
|
reverseOrder = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@ -82,62 +108,53 @@ let
|
|||||||
nbPkgs = config.nix-bitcoin.pkgs;
|
nbPkgs = config.nix-bitcoin.pkgs;
|
||||||
secretsDir = config.nix-bitcoin.secretsDir;
|
secretsDir = config.nix-bitcoin.secretsDir;
|
||||||
|
|
||||||
node = { isLnd, index }: ''
|
inherit (nbLib) optionalAttr;
|
||||||
{
|
|
||||||
"index": ${toString index},
|
node = { isLnd, index }: {
|
||||||
"lnNode": "Node",
|
inherit index;
|
||||||
"lnImplementation": "${if isLnd then "LND" else "CLT"}",
|
lnNode = "Node";
|
||||||
"Authentication": {
|
lnImplementation = if isLnd then "LND" else "CLT";
|
||||||
${optionalString (isLnd && lndLoopEnabled)
|
Authentication = {
|
||||||
''"swapMacaroonPath": "${lightning-loop.dataDir}/${bitcoind.network}",''
|
${optionalAttr (isLnd && lndLoopEnabled) "swapMacaroonPath"} = "${lightning-loop.dataDir}/${bitcoind.network}";
|
||||||
}
|
macaroonPath = if isLnd
|
||||||
"macaroonPath": "${if isLnd
|
|
||||||
then "${cfg.dataDir}/macaroons"
|
then "${cfg.dataDir}/macaroons"
|
||||||
else "${clightning-rest.dataDir}/certs"
|
else "${clightning-rest.dataDir}/certs";
|
||||||
}"
|
};
|
||||||
},
|
Settings = {
|
||||||
"Settings": {
|
userPersona = "OPERATOR";
|
||||||
"userPersona": "OPERATOR",
|
themeMode = if cfg.nightTheme then "NIGHT" else "DAY";
|
||||||
"themeMode": "${if cfg.nightTheme then "NIGHT" else "DAY"}",
|
themeColor = "PURPLE";
|
||||||
"themeColor": "PURPLE",
|
${optionalAttr isLnd "channelBackupPath"} = "${cfg.dataDir}/backup/lnd";
|
||||||
${optionalString isLnd
|
logLevel = "INFO";
|
||||||
''"channelBackupPath": "${cfg.dataDir}/backup/lnd",''
|
fiatConversion = cfg.extraCurrency != null;
|
||||||
}
|
${optionalAttr (cfg.extraCurrency != null) "currencyUnit"} = cfg.extraCurrency;
|
||||||
"logLevel": "INFO",
|
${optionalAttr (isLnd && lndLoopEnabled) "swapServerUrl"} =
|
||||||
"fiatConversion": ${if cfg.extraCurrency == null then "false" else "true"},
|
"https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}";
|
||||||
${optionalString (cfg.extraCurrency != null)
|
lnServerUrl = "https://${
|
||||||
''"currencyUnit": "${cfg.extraCurrency}",''
|
|
||||||
}
|
|
||||||
${optionalString (isLnd && lndLoopEnabled)
|
|
||||||
''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",''
|
|
||||||
}
|
|
||||||
"lnServerUrl": "https://${
|
|
||||||
if isLnd
|
if isLnd
|
||||||
then nbLib.addressWithPort lnd.restAddress lnd.restPort
|
then nbLib.addressWithPort lnd.restAddress lnd.restPort
|
||||||
else nbLib.addressWithPort clightning-rest.address clightning-rest.port
|
else nbLib.addressWithPort clightning-rest.address clightning-rest.port
|
||||||
}"
|
}";
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
nodes' = optional cfg.nodes.clightning.enable (node { isLnd = false; index = 1; }) ++
|
nodes' =
|
||||||
optional cfg.nodes.lnd.enable (node { isLnd = true; index = 2; });
|
optional cfg.nodes.clightning.enable
|
||||||
|
(recursiveUpdate (node { isLnd = false; index = 1; }) cfg.nodes.clightning.extraConfig) ++
|
||||||
|
optional cfg.nodes.lnd.enable
|
||||||
|
(recursiveUpdate (node { isLnd = true; index = 2; }) cfg.nodes.lnd.extraConfig);
|
||||||
|
|
||||||
nodes = if cfg.nodes.reverseOrder then reverseList nodes' else nodes';
|
nodes = if cfg.nodes.reverseOrder then reverseList nodes' else nodes';
|
||||||
|
|
||||||
configFile = builtins.toFile "config" ''
|
rtlConfig = {
|
||||||
{
|
multiPass = "@multiPass@";
|
||||||
"multiPass": "@multiPass@",
|
host = cfg.address;
|
||||||
"host": "${cfg.address}",
|
port = cfg.port;
|
||||||
"port": "${toString cfg.port}",
|
SSO.rtlSSO = 0;
|
||||||
"SSO": {
|
inherit nodes;
|
||||||
"rtlSSO": 0
|
};
|
||||||
},
|
|
||||||
"nodes": [
|
configFile = builtins.toFile "config" (builtins.toJSON rtlConfig);
|
||||||
${builtins.concatStringsSep ",\n" nodes}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
inherit (config.services)
|
inherit (config.services)
|
||||||
bitcoind
|
bitcoind
|
||||||
|
@ -107,4 +107,6 @@ let self = {
|
|||||||
|
|
||||||
addressWithPort = addr: port: "${self.address addr}:${toString port}";
|
addressWithPort = addr: port: "${self.address addr}:${toString port}";
|
||||||
|
|
||||||
|
optionalAttr = cond: name: if cond then name else null;
|
||||||
|
|
||||||
}; in self
|
}; in self
|
||||||
|
@ -67,6 +67,7 @@ let
|
|||||||
lnd = {
|
lnd = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
loop = mkDefault true;
|
loop = mkDefault true;
|
||||||
|
extraConfig.Settings.userPersona = "MERCHANT";
|
||||||
};
|
};
|
||||||
clightning.enable = mkDefault true;
|
clightning.enable = mkDefault true;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user