3755b3ebea rtl: add option `extraConfig` for nodes (Erik Arvstedt)
ff228a604d rtl: change `nodes` options (Erik Arvstedt)
beae9f8df7 clightning-rest: 0.7.0 -> 0.7.2 (Erik Arvstedt)
4c2d908a38 rtl: 0.12.2-beta -> 0.12.3-beta (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  nixbitcoin:
    ACK 3755b3ebea

Tree-SHA512: 21b413473792802a49694427dd488d7ba0575bb79297b8cd3d3e09707f0389fa4a65ed18eea11af167e1f42154f43685a7afc0829b769dea4b8d64007dcd7be5
This commit is contained in:
Jonas Nick 2022-05-25 19:47:51 +00:00
commit ebaa9a3f2e
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
9 changed files with 138 additions and 104 deletions

View File

@ -103,17 +103,17 @@
# #
# Set this to add a clightning node interface. # Set this to add a clightning node interface.
# Automatically enables clightning. # Automatically enables clightning.
# services.rtl.nodes.clightning = true; # services.rtl.nodes.clightning.enable = true;
# #
# Set this to add a lnd node interface. # Set this to add a lnd node interface.
# Automatically enables lnd. # Automatically enables lnd.
# services.rtl.nodes.lnd = true; # services.rtl.nodes.lnd.enable = true;
# #
# You can enable both nodes simultaneously. # You can enable both nodes simultaneously.
# #
# Set this option to enable swaps with lightning-loop. # Set this option to enable swaps with lightning-loop.
# Automatically enables lightning-loop. # Automatically enables lightning-loop.
# services.rtl.loop = true; # services.rtl.nodes.lnd.loop = true;
### SPARK WALLET ### SPARK WALLET
# Set this to enable spark-wallet, a minimalistic wallet GUI for # Set this to enable spark-wallet, a minimalistic wallet GUI for

View File

@ -283,10 +283,12 @@ in {
}; };
rtl = { rtl = {
id = 29; id = 29;
connections = connections = let
optional config.services.rtl.nodes.lnd "lnd" ++ nodes = config.services.rtl.nodes;
optional config.services.rtl.loop "lightning-loop" ++ in
optional config.services.rtl.nodes.clightning "clightning-rest"; optional nodes.lnd.enable "lnd" ++
optional (nodes.lnd.enable && nodes.lnd.loop) "lightning-loop" ++
optional nodes.clightning.enable "clightning-rest";
}; };
clightning-rest = { clightning-rest = {
id = 30; id = 30;

View File

@ -20,16 +20,51 @@ let
description = "The data directory for RTL."; description = "The data directory for RTL.";
}; };
nodes = { nodes = {
clightning = mkOption { clightning = {
enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable the clightning node interface."; description = "Enable the clightning node interface.";
}; };
lnd = mkOption { 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 = {
enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable the lnd node interface."; 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 { reverseOrder = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -39,11 +74,6 @@ let
''; '';
}; };
}; };
loop = mkOption {
type = types.bool;
default = false;
description = "Whether to enable swaps with lightning-loop.";
};
nightTheme = mkOption { nightTheme = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -78,83 +108,76 @@ 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 && cfg.loop) 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 && cfg.loop)
''"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 (node { isLnd = false; index = 1; }) ++ nodes' =
optional cfg.nodes.lnd (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
lnd lnd
clightning-rest clightning-rest
lightning-loop; lightning-loop;
lndLoopEnabled = cfg.nodes.lnd.enable && cfg.nodes.lnd.loop;
in { in {
inherit options; inherit options;
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ assertions = [
{ assertion = cfg.nodes.clightning || cfg.nodes.lnd; { assertion = cfg.nodes.clightning.enable || cfg.nodes.lnd.enable;
message = '' 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.lnd.enable = mkIf cfg.nodes.lnd.enable true;
services.lightning-loop.enable = mkIf cfg.loop true; services.lightning-loop.enable = mkIf lndLoopEnabled true;
services.clightning-rest.enable = mkIf cfg.nodes.clightning true; services.clightning-rest.enable = mkIf cfg.nodes.clightning.enable true;
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
@ -164,8 +187,8 @@ in {
systemd.services.rtl = rec { systemd.services.rtl = rec {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
requires = optional cfg.nodes.clightning "clightning-rest.service" ++ requires = optional cfg.nodes.clightning.enable "clightning-rest.service" ++
optional cfg.nodes.lnd "lnd.service"; optional cfg.nodes.lnd.enable "lnd.service";
after = requires; after = requires;
environment.RTL_CONFIG_PATH = cfg.dataDir; environment.RTL_CONFIG_PATH = cfg.dataDir;
serviceConfig = nbLib.defaultHardening // { serviceConfig = nbLib.defaultHardening // {
@ -174,7 +197,7 @@ in {
<${configFile} sed "s|@multiPass@|$(cat ${secretsDir}/rtl-password)|" \ <${configFile} sed "s|@multiPass@|$(cat ${secretsDir}/rtl-password)|" \
> '${cfg.dataDir}/RTL-Config.json' > '${cfg.dataDir}/RTL-Config.json'
'') '')
] ++ optional cfg.nodes.lnd ] ++ optional cfg.nodes.lnd.enable
(nbLib.rootScript "rtl-copy-macaroon" '' (nbLib.rootScript "rtl-copy-macaroon" ''
install -D -o ${cfg.user} -g ${cfg.group} ${lnd.networkDir}/admin.macaroon \ install -D -o ${cfg.user} -g ${cfg.group} ${lnd.networkDir}/admin.macaroon \
'${cfg.dataDir}/macaroons/admin.macaroon' '${cfg.dataDir}/macaroons/admin.macaroon'
@ -195,8 +218,8 @@ in {
group = cfg.group; group = cfg.group;
extraGroups = extraGroups =
# Reads cert and macaroon from the clightning-rest datadir # Reads cert and macaroon from the clightning-rest datadir
optional cfg.nodes.clightning clightning-rest.group ++ optional cfg.nodes.clightning.enable clightning-rest.group ++
optional cfg.loop lnd.group; optional lndLoopEnabled lnd.group;
}; };
users.groups.${cfg.group} = {}; users.groups.${cfg.group} = {};

View File

@ -5,7 +5,7 @@ set -euo pipefail
TMPDIR="$(mktemp -d -p /tmp)" TMPDIR="$(mktemp -d -p /tmp)"
trap "rm -rf $TMPDIR" EXIT trap "rm -rf $TMPDIR" EXIT
version="0.7.0" version="0.7.2"
repo=https://github.com/Ride-The-Lightning/c-lightning-REST repo=https://github.com/Ride-The-Lightning/c-lightning-REST
# Fetch and verify source tarball # Fetch and verify source tarball

View File

@ -175,13 +175,13 @@ let
sha1 = "1b681c21ff84033c826543090689420d187151dc"; sha1 = "1b681c21ff84033c826543090689420d187151dc";
}; };
}; };
"clightningjs-0.1.1" = { "clightningjs-0.2.2" = {
name = "clightningjs"; name = "clightningjs";
packageName = "clightningjs"; packageName = "clightningjs";
version = "0.1.1"; version = "0.2.2";
src = fetchurl { src = fetchurl {
url = "https://registry.npmjs.org/clightningjs/-/clightningjs-0.1.1.tgz"; url = "https://registry.npmjs.org/clightningjs/-/clightningjs-0.2.2.tgz";
sha512 = "r/poNODgYDJQZVU1X3lMirDCOD2Bw9XyPdjRXcOXAnHtSihf4OnO1c7iB82ots+2aExQnKuBk9JOE3QwY6FHOw=="; sha512 = "9fdWYNxe/IUe0uG0b1XdxWGlev1IPlWZpN6Hrsr3uTOZe1kSR+ySBMzdsgD73Rc3LeX7DfdKhT3uuT8B77HIqg==";
}; };
}; };
"combined-stream-1.0.8" = { "combined-stream-1.0.8" = {
@ -1277,10 +1277,10 @@ let
args = { args = {
name = "c-lightning-rest"; name = "c-lightning-rest";
packageName = "c-lightning-rest"; packageName = "c-lightning-rest";
version = "0.7.0"; version = "0.7.2";
src = fetchurl { src = fetchurl {
url = "https://github.com/Ride-The-Lightning/c-lightning-REST/archive/refs/tags/v0.7.0.tar.gz"; url = "https://github.com/Ride-The-Lightning/c-lightning-REST/archive/refs/tags/v0.7.2.tar.gz";
hash = "sha256-NeeG4WyXWPZv5u5HuMwVhIgDgHStgah3YNtk4bKvNoY="; hash = "sha256-G3PWoOW69B+so7sDiAcZNgaAWtmp/H5U9I6vh5YeUEQ=";
}; };
dependencies = [ dependencies = [
sources."accepts-1.3.7" sources."accepts-1.3.7"
@ -1300,7 +1300,7 @@ let
sources."bytes-3.1.0" sources."bytes-3.1.0"
sources."call-me-maybe-1.0.1" sources."call-me-maybe-1.0.1"
sources."caseless-0.12.0" sources."caseless-0.12.0"
sources."clightningjs-0.1.1" sources."clightningjs-0.2.2"
sources."combined-stream-1.0.8" sources."combined-stream-1.0.8"
sources."commander-2.20.0" sources."commander-2.20.0"
sources."concat-map-0.0.1" sources."concat-map-0.0.1"

View File

@ -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

View File

@ -5,7 +5,7 @@ set -euo pipefail
TMPDIR="$(mktemp -d -p /tmp)" TMPDIR="$(mktemp -d -p /tmp)"
trap "rm -rf $TMPDIR" EXIT trap "rm -rf $TMPDIR" EXIT
version="0.12.2" version="0.12.3"
repo=https://github.com/Ride-The-Lightning/RTL repo=https://github.com/Ride-The-Lightning/RTL
# Fetch and verify source tarball # Fetch and verify source tarball

View File

@ -2389,13 +2389,13 @@ let
sha512 = "6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A=="; sha512 = "6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==";
}; };
}; };
"minimist-1.2.5" = { "minimist-1.2.6" = {
name = "minimist"; name = "minimist";
packageName = "minimist"; packageName = "minimist";
version = "1.2.5"; version = "1.2.6";
src = fetchurl { src = fetchurl {
url = "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz"; url = "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz";
sha512 = "FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="; sha512 = "Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==";
}; };
}; };
"ms-2.0.0" = { "ms-2.0.0" = {
@ -3590,10 +3590,10 @@ let
args = { args = {
name = "rtl"; name = "rtl";
packageName = "rtl"; packageName = "rtl";
version = "0.12.2-beta"; version = "0.12.3-beta";
src = fetchurl { src = fetchurl {
url = "https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v0.12.2.tar.gz"; url = "https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v0.12.3.tar.gz";
hash = "sha256-xvW6zq/mBsuRy8AwoAPJ2RR7iqhKrC57SVWyFTjq6aw="; hash = "sha256-2X5Bf9rniiN/NNEqnNJYF/YQ0v+EwnwQHB5VXVfS9to=";
}; };
dependencies = [ dependencies = [
sources."@angular/animations-13.0.3" sources."@angular/animations-13.0.3"
@ -3943,7 +3943,7 @@ let
sources."methods-1.1.2" sources."methods-1.1.2"
sources."mime-db-1.51.0" sources."mime-db-1.51.0"
sources."mime-types-2.1.34" sources."mime-types-2.1.34"
sources."minimist-1.2.5" sources."minimist-1.2.6"
sources."ms-2.1.2" sources."ms-2.1.2"
sources."negotiator-0.6.2" sources."negotiator-0.6.2"
sources."next-tick-1.0.0" sources."next-tick-1.0.0"

View File

@ -62,14 +62,21 @@ let
tests.clightning-rest = cfg.clightning-rest.enable; tests.clightning-rest = cfg.clightning-rest.enable;
tests.rtl = cfg.rtl.enable; tests.rtl = cfg.rtl.enable;
services.rtl.nodes.lnd = mkDefault true; services.rtl = {
services.rtl.nodes.clightning = mkDefault true; nodes = {
services.rtl.loop = mkIf cfg.rtl.nodes.lnd (mkDefault true); lnd = {
enable = mkDefault true;
loop = mkDefault true;
extraConfig.Settings.userPersona = "MERCHANT";
};
clightning.enable = mkDefault true;
};
extraCurrency = mkDefault "CHF";
};
# Use a simple, non-random password for manual web interface tests # Use a simple, non-random password for manual web interface tests
nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce '' nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce ''
echo a > rtl-password echo a > rtl-password
''); '');
services.rtl.extraCurrency = mkDefault "CHF";
tests.spark-wallet = cfg.spark-wallet.enable; tests.spark-wallet = cfg.spark-wallet.enable;