Merge fort-nix/nix-bitcoin#510: lnd, lightning-loop: add certificate options extraIPs and extraDomains

c853f380d4 lightning-loop: add certificate options `extraIPs` and `extraDomains` (Erik Arvstedt)
edfbe700e7 lnd: add certificate options `extraIPs` and `extraDomains` (Erik Arvstedt)
60a27d58a6 lnd, lightning-loop: improve `extraConfig` option description (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK c853f380d4

Tree-SHA512: f83ddd99826fdcae964de2ff7f45ca941f0ffb6130f5e4f8481d7e2c9946ebea8415460c0cfe68a9626a2fb0d6912e5285b580db00d78bfcfdac665426bf3649
This commit is contained in:
Jonas Nick 2022-07-08 20:56:17 +00:00
commit 7e94b7eddc
No known key found for this signature in database
GPG key ID: 4861DBF262123605
5 changed files with 88 additions and 10 deletions

View file

@ -40,13 +40,37 @@ let
default = if cfg.tor.proxy then config.nix-bitcoin.torClientAddressWithPort else null;
description = "host:port of SOCKS5 proxy for connnecting to the loop server.";
};
certificate = {
extraIPs = mkOption {
type = with types; listOf str;
default = [];
example = [ "60.100.0.1" ];
description = ''
Extra `subjectAltName` IPs added to the certificate.
This works the same as loop option `tlsextraip`.
'';
};
extraDomains = mkOption {
type = with types; listOf str;
default = [];
example = [ "example.com" ];
description = ''
Extra `subjectAltName` domain names added to the certificate.
This works the same as loop option `tlsextradomain`.
'';
};
};
extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
debuglevel=trace
'';
description = "Extra lines appended to the configuration file.";
description = ''
Extra lines appended to the configuration file.
See here for all available options:
https://github.com/lightninglabs/loop/blob/11ab596080e9d36f1df43edbeba0702b25aa7457/loopd/config.go#L119
'';
};
cli = mkOption {
default = pkgs.writeScriptBin "loop" ''
@ -97,6 +121,8 @@ in {
"d '${cfg.dataDir}' 0770 ${lnd.user} ${lnd.group} - -"
];
services.lightning-loop.certificate.extraIPs = mkIf (cfg.rpcAddress != "localhost") [ "${cfg.rpcAddress}" ];
systemd.services.lightning-loop = {
wantedBy = [ "multi-user.target" ];
requires = [ "lnd.service" ];
@ -115,7 +141,7 @@ in {
loop-cert.user = lnd.user;
};
nix-bitcoin.generateSecretsCmds.lightning-loop = ''
makeCert loop '${optionalString (cfg.rpcAddress != "localhost") "IP:${cfg.rpcAddress}"}'
makeCert loop '${nbLib.mkCertExtraAltNames cfg.certificate}'
'';
};
}

View file

@ -70,13 +70,37 @@ let
Extra macaroon definitions.
'';
};
certificate = {
extraIPs = mkOption {
type = with types; listOf str;
default = [];
example = [ "60.100.0.1" ];
description = ''
Extra `subjectAltName` IPs added to the certificate.
This works the same as lnd option `tlsextraip`.
'';
};
extraDomains = mkOption {
type = with types; listOf str;
default = [];
example = [ "example.com" ];
description = ''
Extra `subjectAltName` domain names added to the certificate.
This works the same as lnd option `tlsextradomain`.
'';
};
};
extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
autopilot.active=1
'';
description = "Extra lines appended to <filename>lnd.conf</filename>.";
description = ''
Extra lines appended to `lnd.conf`.
See here for all available options:
https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf
'';
};
package = mkOption {
type = types.package;
@ -191,6 +215,8 @@ in {
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
];
services.lnd.certificate.extraIPs = mkIf (cfg.rpcAddress != "localhost") [ "${cfg.rpcAddress}" ];
systemd.services.lnd = {
wantedBy = [ "multi-user.target" ];
requires = [ "bitcoind.service" ];
@ -278,7 +304,7 @@ in {
# - Enables deployment of a mesh of server plus client nodes with predefined certs
nix-bitcoin.generateSecretsCmds.lnd = ''
makePasswordSecret lnd-wallet-password
makeCert lnd '${optionalString (cfg.rpcAddress != "localhost") "IP:${cfg.rpcAddress}"}'
makeCert lnd '${nbLib.mkCertExtraAltNames cfg.certificate}'
'';
};
}