lightning-pool/loop: extract lnd variable

This commit is contained in:
Erik Arvstedt 2021-09-08 17:01:12 +02:00
parent 955b44404c
commit be12a49933
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
2 changed files with 14 additions and 8 deletions

View File

@ -6,6 +6,9 @@ let
cfg = config.services.lightning-loop;
nbLib = config.nix-bitcoin.lib;
secretsDir = config.nix-bitcoin.secretsDir;
lnd = config.services.lnd;
network = config.services.bitcoind.network;
rpclisten = "${cfg.rpcAddress}:${toString cfg.rpcPort}";
configFile = builtins.toFile "loop.conf" ''
@ -17,8 +20,8 @@ let
tlscertpath=${secretsDir}/loop-cert
tlskeypath=${secretsDir}/loop-key
lnd.host=${config.services.lnd.rpcAddress}:${toString config.services.lnd.rpcPort}
lnd.macaroonpath=${config.services.lnd.networkDir}/admin.macaroon
lnd.host=${lnd.rpcAddress}:${toString lnd.rpcPort}
lnd.macaroonpath=${lnd.networkDir}/admin.macaroon
lnd.tlspath=${secretsDir}/lnd-cert
${optionalString (cfg.proxy != null) "server.proxy=${cfg.proxy}"}
@ -89,7 +92,7 @@ in {
environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ];
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${config.services.lnd.user} ${config.services.lnd.group} - -"
"d '${cfg.dataDir}' 0770 ${lnd.user} ${lnd.group} - -"
];
systemd.services.lightning-loop = {
@ -98,7 +101,7 @@ in {
after = [ "lnd.service" ];
serviceConfig = nbLib.defaultHardening // {
ExecStart = "${cfg.package}/bin/loopd --configfile=${configFile}";
User = config.services.lnd.user;
User = lnd.user;
Restart = "on-failure";
RestartSec = "10s";
ReadWritePaths = cfg.dataDir;
@ -106,8 +109,8 @@ in {
};
nix-bitcoin.secrets = {
loop-key.user = config.services.lnd.user;
loop-cert.user = config.services.lnd.user;
loop-key.user = lnd.user;
loop-cert.user = lnd.user;
};
};
}

View File

@ -6,6 +6,9 @@ let
cfg = config.services.lightning-pool;
nbLib = config.nix-bitcoin.lib;
secretsDir = config.nix-bitcoin.secretsDir;
lnd = config.services.lnd;
network = config.services.bitcoind.network;
rpclisten = "${cfg.rpcAddress}:${toString cfg.rpcPort}";
configFile = builtins.toFile "pool.conf" ''
@ -13,8 +16,8 @@ let
restlisten=${cfg.restAddress}:${toString cfg.restPort}
${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"}
lnd.host=${config.services.lnd.rpcAddress}:${toString config.services.lnd.rpcPort}
lnd.macaroondir=${config.services.lnd.networkDir}
lnd.host=${lnd.rpcAddress}:${toString lnd.rpcPort}
lnd.macaroondir=${lnd.networkDir}
lnd.tlspath=${secretsDir}/lnd-cert
${cfg.extraConfig}