mirror of
https://github.com/fort-nix/nix-bitcoin.git
synced 2024-11-22 22:33:46 +03:00
rtl: change nodes
options
- Move option `rtl.nodes.{lnd,clightning}` -> `rtl.nodes.{lnd,clightning}.enable` This is required by the next commit. - Move option `rtl.loop` -> `rtl.nodes.lnd.loop` - Only enable loop when `nodes.lnd` is enabled
This commit is contained in:
parent
beae9f8df7
commit
ff228a604d
@ -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
|
||||
|
@ -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;
|
||||
|
@ -20,16 +20,25 @@ let
|
||||
description = "The data directory for RTL.";
|
||||
};
|
||||
nodes = {
|
||||
clightning = mkOption {
|
||||
clightning = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable the clightning node interface.";
|
||||
};
|
||||
lnd = mkOption {
|
||||
};
|
||||
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.";
|
||||
};
|
||||
};
|
||||
reverseOrder = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
@ -39,11 +48,6 @@ let
|
||||
'';
|
||||
};
|
||||
};
|
||||
loop = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether to enable swaps with lightning-loop.";
|
||||
};
|
||||
nightTheme = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
@ -84,7 +88,7 @@ let
|
||||
"lnNode": "Node",
|
||||
"lnImplementation": "${if isLnd then "LND" else "CLT"}",
|
||||
"Authentication": {
|
||||
${optionalString (isLnd && cfg.loop)
|
||||
${optionalString (isLnd && lndLoopEnabled)
|
||||
''"swapMacaroonPath": "${lightning-loop.dataDir}/${bitcoind.network}",''
|
||||
}
|
||||
"macaroonPath": "${if isLnd
|
||||
@ -104,7 +108,7 @@ let
|
||||
${optionalString (cfg.extraCurrency != null)
|
||||
''"currencyUnit": "${cfg.extraCurrency}",''
|
||||
}
|
||||
${optionalString (isLnd && cfg.loop)
|
||||
${optionalString (isLnd && lndLoopEnabled)
|
||||
''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",''
|
||||
}
|
||||
"lnServerUrl": "https://${
|
||||
@ -116,8 +120,8 @@ let
|
||||
}
|
||||
'';
|
||||
|
||||
nodes' = optional cfg.nodes.clightning (node { isLnd = false; index = 1; }) ++
|
||||
optional cfg.nodes.lnd (node { isLnd = true; index = 2; });
|
||||
nodes' = optional cfg.nodes.clightning.enable (node { isLnd = false; index = 1; }) ++
|
||||
optional cfg.nodes.lnd.enable (node { isLnd = true; index = 2; });
|
||||
|
||||
nodes = if cfg.nodes.reverseOrder then reverseList nodes' else nodes';
|
||||
|
||||
@ -140,21 +144,23 @@ let
|
||||
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 +170,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 +180,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 +201,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} = {};
|
||||
|
||||
|
@ -62,14 +62,20 @@ 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;
|
||||
};
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user