Merge fort-nix/nix-bitcoin#484: Update RTL
3755b3ebeartl: add option `extraConfig` for nodes (Erik Arvstedt)ff228a604drtl: change `nodes` options (Erik Arvstedt)beae9f8df7clightning-rest: 0.7.0 -> 0.7.2 (Erik Arvstedt)4c2d908a38rtl: 0.12.2-beta -> 0.12.3-beta (Erik Arvstedt) Pull request description: ACKs for top commit: nixbitcoin: ACK3755b3ebeaTree-SHA512: 21b413473792802a49694427dd488d7ba0575bb79297b8cd3d3e09707f0389fa4a65ed18eea11af167e1f42154f43685a7afc0829b769dea4b8d64007dcd7be5
This commit is contained in:
commit
ebaa9a3f2e
9 changed files with 138 additions and 104 deletions
|
|
@ -283,10 +283,12 @@ in {
|
|||
};
|
||||
rtl = {
|
||||
id = 29;
|
||||
connections =
|
||||
optional config.services.rtl.nodes.lnd "lnd" ++
|
||||
optional config.services.rtl.loop "lightning-loop" ++
|
||||
optional config.services.rtl.nodes.clightning "clightning-rest";
|
||||
connections = let
|
||||
nodes = config.services.rtl.nodes;
|
||||
in
|
||||
optional nodes.lnd.enable "lnd" ++
|
||||
optional (nodes.lnd.enable && nodes.lnd.loop) "lightning-loop" ++
|
||||
optional nodes.clightning.enable "clightning-rest";
|
||||
};
|
||||
clightning-rest = {
|
||||
id = 30;
|
||||
|
|
|
|||
173
modules/rtl.nix
173
modules/rtl.nix
|
|
@ -20,15 +20,50 @@ let
|
|||
description = "The data directory for RTL.";
|
||||
};
|
||||
nodes = {
|
||||
clightning = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable the clightning node interface.";
|
||||
clightning = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
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 = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable the lnd node interface.";
|
||||
lnd = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable the lnd node interface.";
|
||||
};
|
||||
loop = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
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 {
|
||||
type = types.bool;
|
||||
|
|
@ -39,11 +74,6 @@ let
|
|||
'';
|
||||
};
|
||||
};
|
||||
loop = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether to enable swaps with lightning-loop.";
|
||||
};
|
||||
nightTheme = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
|
@ -78,83 +108,76 @@ let
|
|||
nbPkgs = config.nix-bitcoin.pkgs;
|
||||
secretsDir = config.nix-bitcoin.secretsDir;
|
||||
|
||||
node = { isLnd, index }: ''
|
||||
{
|
||||
"index": ${toString index},
|
||||
"lnNode": "Node",
|
||||
"lnImplementation": "${if isLnd then "LND" else "CLT"}",
|
||||
"Authentication": {
|
||||
${optionalString (isLnd && cfg.loop)
|
||||
''"swapMacaroonPath": "${lightning-loop.dataDir}/${bitcoind.network}",''
|
||||
}
|
||||
"macaroonPath": "${if isLnd
|
||||
then "${cfg.dataDir}/macaroons"
|
||||
else "${clightning-rest.dataDir}/certs"
|
||||
}"
|
||||
},
|
||||
"Settings": {
|
||||
"userPersona": "OPERATOR",
|
||||
"themeMode": "${if cfg.nightTheme then "NIGHT" else "DAY"}",
|
||||
"themeColor": "PURPLE",
|
||||
${optionalString isLnd
|
||||
''"channelBackupPath": "${cfg.dataDir}/backup/lnd",''
|
||||
}
|
||||
"logLevel": "INFO",
|
||||
"fiatConversion": ${if cfg.extraCurrency == null then "false" else "true"},
|
||||
${optionalString (cfg.extraCurrency != null)
|
||||
''"currencyUnit": "${cfg.extraCurrency}",''
|
||||
}
|
||||
${optionalString (isLnd && cfg.loop)
|
||||
''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",''
|
||||
}
|
||||
"lnServerUrl": "https://${
|
||||
if isLnd
|
||||
then nbLib.addressWithPort lnd.restAddress lnd.restPort
|
||||
else nbLib.addressWithPort clightning-rest.address clightning-rest.port
|
||||
}"
|
||||
}
|
||||
}
|
||||
'';
|
||||
inherit (nbLib) optionalAttr;
|
||||
|
||||
nodes' = optional cfg.nodes.clightning (node { isLnd = false; index = 1; }) ++
|
||||
optional cfg.nodes.lnd (node { isLnd = true; index = 2; });
|
||||
node = { isLnd, index }: {
|
||||
inherit index;
|
||||
lnNode = "Node";
|
||||
lnImplementation = if isLnd then "LND" else "CLT";
|
||||
Authentication = {
|
||||
${optionalAttr (isLnd && lndLoopEnabled) "swapMacaroonPath"} = "${lightning-loop.dataDir}/${bitcoind.network}";
|
||||
macaroonPath = if isLnd
|
||||
then "${cfg.dataDir}/macaroons"
|
||||
else "${clightning-rest.dataDir}/certs";
|
||||
};
|
||||
Settings = {
|
||||
userPersona = "OPERATOR";
|
||||
themeMode = if cfg.nightTheme then "NIGHT" else "DAY";
|
||||
themeColor = "PURPLE";
|
||||
${optionalAttr isLnd "channelBackupPath"} = "${cfg.dataDir}/backup/lnd";
|
||||
logLevel = "INFO";
|
||||
fiatConversion = cfg.extraCurrency != null;
|
||||
${optionalAttr (cfg.extraCurrency != null) "currencyUnit"} = cfg.extraCurrency;
|
||||
${optionalAttr (isLnd && lndLoopEnabled) "swapServerUrl"} =
|
||||
"https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}";
|
||||
lnServerUrl = "https://${
|
||||
if isLnd
|
||||
then nbLib.addressWithPort lnd.restAddress lnd.restPort
|
||||
else nbLib.addressWithPort clightning-rest.address clightning-rest.port
|
||||
}";
|
||||
};
|
||||
};
|
||||
|
||||
nodes' =
|
||||
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';
|
||||
|
||||
configFile = builtins.toFile "config" ''
|
||||
{
|
||||
"multiPass": "@multiPass@",
|
||||
"host": "${cfg.address}",
|
||||
"port": "${toString cfg.port}",
|
||||
"SSO": {
|
||||
"rtlSSO": 0
|
||||
},
|
||||
"nodes": [
|
||||
${builtins.concatStringsSep ",\n" nodes}
|
||||
]
|
||||
}
|
||||
'';
|
||||
rtlConfig = {
|
||||
multiPass = "@multiPass@";
|
||||
host = cfg.address;
|
||||
port = cfg.port;
|
||||
SSO.rtlSSO = 0;
|
||||
inherit nodes;
|
||||
};
|
||||
|
||||
configFile = builtins.toFile "config" (builtins.toJSON rtlConfig);
|
||||
|
||||
inherit (config.services)
|
||||
bitcoind
|
||||
lnd
|
||||
clightning-rest
|
||||
lightning-loop;
|
||||
|
||||
lndLoopEnabled = cfg.nodes.lnd.enable && cfg.nodes.lnd.loop;
|
||||
in {
|
||||
inherit options;
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{ assertion = cfg.nodes.clightning || cfg.nodes.lnd;
|
||||
{ assertion = cfg.nodes.clightning.enable || cfg.nodes.lnd.enable;
|
||||
message = ''
|
||||
RTL: At least one of `nodes.lnd` or `nodes.clightning` must be `true`.
|
||||
RTL: At least one of `nodes.lnd.enable` or `nodes.clightning.enable` must be `true`.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
services.lnd.enable = mkIf cfg.nodes.lnd true;
|
||||
services.lightning-loop.enable = mkIf cfg.loop true;
|
||||
services.clightning-rest.enable = mkIf cfg.nodes.clightning true;
|
||||
services.lnd.enable = mkIf cfg.nodes.lnd.enable true;
|
||||
services.lightning-loop.enable = mkIf lndLoopEnabled true;
|
||||
services.clightning-rest.enable = mkIf cfg.nodes.clightning.enable true;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
|
||||
|
|
@ -164,8 +187,8 @@ in {
|
|||
|
||||
systemd.services.rtl = rec {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
requires = optional cfg.nodes.clightning "clightning-rest.service" ++
|
||||
optional cfg.nodes.lnd "lnd.service";
|
||||
requires = optional cfg.nodes.clightning.enable "clightning-rest.service" ++
|
||||
optional cfg.nodes.lnd.enable "lnd.service";
|
||||
after = requires;
|
||||
environment.RTL_CONFIG_PATH = cfg.dataDir;
|
||||
serviceConfig = nbLib.defaultHardening // {
|
||||
|
|
@ -174,7 +197,7 @@ in {
|
|||
<${configFile} sed "s|@multiPass@|$(cat ${secretsDir}/rtl-password)|" \
|
||||
> '${cfg.dataDir}/RTL-Config.json'
|
||||
'')
|
||||
] ++ optional cfg.nodes.lnd
|
||||
] ++ optional cfg.nodes.lnd.enable
|
||||
(nbLib.rootScript "rtl-copy-macaroon" ''
|
||||
install -D -o ${cfg.user} -g ${cfg.group} ${lnd.networkDir}/admin.macaroon \
|
||||
'${cfg.dataDir}/macaroons/admin.macaroon'
|
||||
|
|
@ -195,8 +218,8 @@ in {
|
|||
group = cfg.group;
|
||||
extraGroups =
|
||||
# Reads cert and macaroon from the clightning-rest datadir
|
||||
optional cfg.nodes.clightning clightning-rest.group ++
|
||||
optional cfg.loop lnd.group;
|
||||
optional cfg.nodes.clightning.enable clightning-rest.group ++
|
||||
optional lndLoopEnabled lnd.group;
|
||||
};
|
||||
users.groups.${cfg.group} = {};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue