From 67e49fe4154ef188f920f1a7cd2f16bdf4ed39bb Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 18 Oct 2020 14:49:20 +0200 Subject: [PATCH] services: auto-enable dependencies --- examples/configuration.nix | 14 +++++++++----- modules/btcpayserver.nix | 10 +++------- modules/clightning.nix | 2 ++ modules/electrs.nix | 2 ++ modules/joinmarket.nix | 2 ++ modules/lightning-charge.nix | 6 +----- modules/lightning-loop.nix | 6 +----- modules/liquid.nix | 2 ++ modules/lnd.nix | 2 ++ modules/nanopos.nix | 7 ++----- modules/recurring-donations.nix | 6 +----- modules/spark-wallet.nix | 6 +----- 12 files changed, 28 insertions(+), 37 deletions(-) diff --git a/examples/configuration.nix b/examples/configuration.nix index f4ef69a..b5dc63f 100644 --- a/examples/configuration.nix +++ b/examples/configuration.nix @@ -65,7 +65,7 @@ ### SPARK WALLET # Enable this module to use spark-wallet, a minimalistic wallet GUI for # c-lightning, accessible over the web or through mobile and desktop apps. - # Only available if clightning is enabled. + # Automatically enables clightning. # services.spark-wallet.enable = true; ### ELECTRS @@ -87,6 +87,7 @@ # services.btcpayserver.lightningBackend = "clightning"; # Enable this option to connect BTCPayServert to lnd. # services.btcpayserver.lightningBackend = "lnd"; + # The lightning backend service automatically enabled. # Afterwards you need to go into Store > General Settings > Lightning Nodes # and click to use "the internal lightning node of this BTCPay Server". @@ -99,13 +100,14 @@ ### LIGHTNING CHARGE # Enable this module to use lightning-charge, a simple drop-in solution for - # accepting lightning payments. Only available if clightning is enabled. + # accepting lightning payments. + # Automatically enables clightning. # services.lightning-charge.enable = true; ### NANOPOS # Enable this module to use nanopos, a simple Lightning point-of-sale - # system, powered by Lightning Charge. Only available if clightning and - # lightning-charge are enabled. + # system, powered by Lightning Charge. + # Automatically enables lightning-charge. # services.nanopos.enable = true; ### WEBINDEX @@ -117,7 +119,8 @@ ### RECURRING-DONATIONS # Enable this module to send recurring donations. This is EXPERIMENTAL; it's # not guaranteed that payments are succeeding or that you will notice payment - # failure. Only available if clightning is enabled. + # failure. + # Automatically enables clightning. # services.recurring-donations.enable = true; # Specify the receivers of the donations. By default donations are every # Monday at a randomized time. Check `journalctl -eu recurring-donations` or @@ -149,6 +152,7 @@ # Enable this module to use lightninglab's non-custodial off/on chain bridge. # loopd (lightning-loop daemon) will be started automatically. Users can # interact with off/on chain bridge using `loop in` and `loop out`. + # Automatically enables lnd. # services.lightning-loop.enable = true; ### Backups diff --git a/modules/btcpayserver.nix b/modules/btcpayserver.nix index 5a6ebf0..f720076 100644 --- a/modules/btcpayserver.nix +++ b/modules/btcpayserver.nix @@ -90,13 +90,9 @@ in { }; config = mkIf cfg.btcpayserver.enable { - assertions = let - backend = cfg.btcpayserver.lightningBackend; - in [ - { assertion = (backend != null) -> cfg.${backend}.enable; - message = "btcpayserver requires ${backend}."; - } - ]; + services.bitcoind.enable = true; + services.clightning.enable = mkIf (cfg.btcpayserver.lightningBackend == "clightning") true; + services.lnd.enable = mkIf (cfg.btcpayserver.lightningBackend == "lnd") true; systemd.tmpfiles.rules = [ "d '${cfg.nbxplorer.dataDir}' 0770 ${cfg.nbxplorer.user} ${cfg.nbxplorer.group} - -" diff --git a/modules/clightning.nix b/modules/clightning.nix index d33aac0..1b560ad 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -100,6 +100,8 @@ in { }; config = mkIf cfg.enable { + services.bitcoind.enable = true; + environment.systemPackages = [ pkgs.nix-bitcoin.clightning (hiPrio cfg.cli) ]; users.users.${cfg.user} = { description = "clightning User"; diff --git a/modules/electrs.nix b/modules/electrs.nix index 960186a..83511fb 100644 --- a/modules/electrs.nix +++ b/modules/electrs.nix @@ -61,6 +61,8 @@ in { } ]; + services.bitcoind.enable = true; + environment.systemPackages = [ pkgs.nix-bitcoin.electrs ]; systemd.tmpfiles.rules = [ diff --git a/modules/joinmarket.nix b/modules/joinmarket.nix index 6738478..d1d2248 100644 --- a/modules/joinmarket.nix +++ b/modules/joinmarket.nix @@ -117,6 +117,8 @@ in { }; config = mkIf cfg.enable (mkMerge [{ + services.bitcoind.enable = true; + environment.systemPackages = [ (hiPrio cfg.cli) ]; diff --git a/modules/lightning-charge.nix b/modules/lightning-charge.nix index 8ec9521..bda008f 100644 --- a/modules/lightning-charge.nix +++ b/modules/lightning-charge.nix @@ -38,11 +38,7 @@ in { warnings = ['' The lightning-charge module is deprecated and will be removed soon. '']; - assertions = [ - { assertion = config.services.clightning.enable; - message = "lightning-charge requires clightning."; - } - ]; + services.clightning.enable = true; users.users.lightning-charge = { description = "lightning-charge User"; diff --git a/modules/lightning-loop.nix b/modules/lightning-loop.nix index af2a2fb..71f78e7 100644 --- a/modules/lightning-loop.nix +++ b/modules/lightning-loop.nix @@ -59,11 +59,7 @@ in { }; config = mkIf cfg.enable { - assertions = [ - { assertion = config.services.lnd.enable; - message = "lightning-loop requires lnd."; - } - ]; + services.lnd.enable = true; environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ]; diff --git a/modules/liquid.nix b/modules/liquid.nix index e9ddee9..5e6b1fb 100644 --- a/modules/liquid.nix +++ b/modules/liquid.nix @@ -221,6 +221,8 @@ in { }; config = mkIf cfg.enable { + services.bitcoind.enable = true; + environment.systemPackages = [ pkgs.nix-bitcoin.elementsd (hiPrio cfg.cli) diff --git a/modules/lnd.nix b/modules/lnd.nix index 6023170..c60dfa9 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -154,6 +154,8 @@ in { } ]; + services.bitcoind.enable = true; + environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ]; systemd.tmpfiles.rules = [ diff --git a/modules/nanopos.nix b/modules/nanopos.nix index 2d6aa47..30bbe3f 100644 --- a/modules/nanopos.nix +++ b/modules/nanopos.nix @@ -76,11 +76,8 @@ in { The nanopos module is deprecated and will be removed soon. You can use the btcpayserver module instead. '']; - assertions = [ - { assertion = config.services.lightning-charge.enable; - message = "nanopos requires lightning-charge."; - } - ]; + + services.lightning-charge.enable = true; environment.systemPackages = [ pkgs.nix-bitcoin.nanopos ]; diff --git a/modules/recurring-donations.nix b/modules/recurring-donations.nix index a4f9444..519aadd 100644 --- a/modules/recurring-donations.nix +++ b/modules/recurring-donations.nix @@ -79,11 +79,7 @@ in { }; config = mkIf cfg.enable { - assertions = [ - { assertion = config.services.clightning.enable; - message = "recurring-donations requires clightning."; - } - ]; + services.clightning.enable = true; users.users.recurring-donations = { description = "recurring-donations User"; diff --git a/modules/spark-wallet.nix b/modules/spark-wallet.nix index af3760f..5667a3e 100644 --- a/modules/spark-wallet.nix +++ b/modules/spark-wallet.nix @@ -52,11 +52,7 @@ in { }; config = mkIf cfg.enable { - assertions = [ - { assertion = config.services.clightning.enable; - message = "spark-wallet requires clightning."; - } - ]; + services.clightning.enable = true; environment.systemPackages = [ pkgs.nix-bitcoin.spark-wallet ]; users.users.spark-wallet = {