From be12a49933aa0034893f4acf06c86766d62f9c87 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 8 Sep 2021 17:01:12 +0200 Subject: [PATCH] lightning-pool/loop: extract lnd variable --- modules/lightning-loop.nix | 15 +++++++++------ modules/lightning-pool.nix | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/lightning-loop.nix b/modules/lightning-loop.nix index 18cce78..1eed2ff 100644 --- a/modules/lightning-loop.nix +++ b/modules/lightning-loop.nix @@ -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; }; }; } diff --git a/modules/lightning-pool.nix b/modules/lightning-pool.nix index 74ba9d5..0ec6bb6 100644 --- a/modules/lightning-pool.nix +++ b/modules/lightning-pool.nix @@ -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}