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.
# Automatically enables clightning.
# services.rtl.nodes.clightning = true;
# services.rtl.nodes.clightning.enable = true;
#
# Set this to add a lnd node interface.
# Automatically enables lnd.
# services.rtl.nodes.lnd = true;
# services.rtl.nodes.lnd.enable = true;
#
# You can enable both nodes simultaneously.
#
# Set this option to enable swaps with lightning-loop.
# Automatically enables lightning-loop.
# services.rtl.loop = true;
# services.rtl.nodes.lnd.loop = true;
### SPARK WALLET
# Set this to enable spark-wallet, a minimalistic wallet GUI for

View File

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

View File

@ -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} = {};

View File

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

View File

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

View File

@ -107,4 +107,6 @@ let self = {
addressWithPort = addr: port: "${self.address addr}:${toString port}";
optionalAttr = cond: name: if cond then name else null;
}; in self

View File

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

View File

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

View File

@ -62,14 +62,21 @@ let
tests.clightning-rest = cfg.clightning-rest.enable;
tests.rtl = cfg.rtl.enable;
services.rtl.nodes.lnd = mkDefault true;
services.rtl.nodes.clightning = mkDefault true;
services.rtl.loop = mkIf cfg.rtl.nodes.lnd (mkDefault true);
services.rtl = {
nodes = {
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
nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce ''
echo a > rtl-password
'');
services.rtl.extraCurrency = mkDefault "CHF";
tests.spark-wallet = cfg.spark-wallet.enable;