lnd: extract option certPath

Improves service encapsulation.
This commit is contained in:
Erik Arvstedt 2021-09-08 17:01:13 +02:00
parent be12a49933
commit 2c8e29b35b
No known key found for this signature in database
GPG key ID: 33312B944DD97846
6 changed files with 13 additions and 10 deletions

View file

@ -14,7 +14,7 @@ let
configFile = pkgs.writeText "lnd.conf" ''
datadir=${cfg.dataDir}
logdir=${cfg.dataDir}/logs
tlscertpath=${secretsDir}/lnd-cert
tlscertpath=${cfg.certPath}
tlskeypath=${secretsDir}/lnd-key
listen=${toString cfg.address}:${toString cfg.port}
@ -126,7 +126,7 @@ in {
''
${runAsUser} ${cfg.user} ${cfg.package}/bin/lncli \
--rpcserver ${cfg.rpcAddress}:${toString cfg.rpcPort} \
--tlscertpath '${secretsDir}/lnd-cert' \
--tlscertpath '${cfg.certPath}' \
--macaroonpath '${networkDir}/admin.macaroon' "$@"
'';
description = "Binary to connect with the lnd instance.";
@ -149,6 +149,11 @@ in {
default = cfg.user;
description = "The group as which to run LND.";
};
certPath = mkOption {
readOnly = true;
default = "${secretsDir}/lnd-cert";
description = "LND TLS certificate path.";
};
inherit (nbLib) enforceTor;
};
@ -211,7 +216,7 @@ in {
# Retrying is necessary because it can happen that the lnd socket is
# existing, but the RPC service isn't yet, which results in error
# "waiting to start, RPC services not available".
curl = "${pkgs.curl}/bin/curl -s --show-error --retry 10 --cacert ${secretsDir}/lnd-cert";
curl = "${pkgs.curl}/bin/curl -s --show-error --retry 10 --cacert ${cfg.certPath}";
restUrl = "https://${cfg.restAddress}:${toString cfg.restPort}/v1";
in [
(nbLib.script "lnd-create-wallet" ''