From f280d54bb88e2d0e9603f9cc4214ff536c9944b8 Mon Sep 17 00:00:00 2001 From: nixbitcoin Date: Mon, 15 Jun 2020 10:34:11 +0000 Subject: [PATCH] add module assertions --- modules/electrs.nix | 6 ++++++ modules/hardware-wallets.nix | 9 +++++++++ modules/lightning-charge.nix | 6 ++++++ modules/lnd.nix | 6 ++++++ modules/nanopos.nix | 6 ++++++ modules/nix-bitcoin-webindex.nix | 6 ++++++ modules/recurring-donations.nix | 6 ++++++ modules/spark-wallet.nix | 6 ++++++ 8 files changed, 51 insertions(+) diff --git a/modules/electrs.nix b/modules/electrs.nix index bf81cd7..13b886a 100644 --- a/modules/electrs.nix +++ b/modules/electrs.nix @@ -61,6 +61,12 @@ in { }; config = mkIf cfg.enable (mkMerge [{ + assertions = [ + { assertion = config.services.bitcoind.prune == 0; + message = "electrs does not support bitcoind pruning."; + } + ]; + environment.systemPackages = [ pkgs.nix-bitcoin.electrs ]; systemd.tmpfiles.rules = [ diff --git a/modules/hardware-wallets.nix b/modules/hardware-wallets.nix index 8337e5c..4d53884 100644 --- a/modules/hardware-wallets.nix +++ b/modules/hardware-wallets.nix @@ -33,6 +33,15 @@ in { config = mkMerge [ (mkIf (cfg.ledger || cfg.trezor) { + assertions = [ + { assertion = (config.services.bitcoind.disablewallet == null || !config.services.bitcoind.disablewallet); + message = '' + Hardware-Wallets are not compatible with bitcoind.disablewallet. + Note that this option is active when enabling electrs.high-memory. + ''; + } + ]; + environment.systemPackages = with pkgs; [ nix-bitcoin.hwi # Provides lsusb for debugging diff --git a/modules/lightning-charge.nix b/modules/lightning-charge.nix index d5d1d67..e2d4ce5 100644 --- a/modules/lightning-charge.nix +++ b/modules/lightning-charge.nix @@ -24,6 +24,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.clightning.enable; + message = "lightning-charge requires clightning."; + } + ]; + users.users.lightning-charge = { description = "lightning-charge User"; group = "lightning-charge"; diff --git a/modules/lnd.nix b/modules/lnd.nix index 8f60a16..ef60dcb 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -83,6 +83,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.bitcoind.prune == 0; + message = "lnd does not support bitcoind pruning."; + } + ]; + environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ]; systemd.tmpfiles.rules = [ diff --git a/modules/nanopos.nix b/modules/nanopos.nix index 2f30446..91af50c 100644 --- a/modules/nanopos.nix +++ b/modules/nanopos.nix @@ -52,6 +52,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.lightning-charge.enable; + message = "nanopos requires lightning-charge."; + } + ]; + environment.systemPackages = [ pkgs.nix-bitcoin.nanopos ]; systemd.services.nanopos = { description = "Run nanopos"; diff --git a/modules/nix-bitcoin-webindex.nix b/modules/nix-bitcoin-webindex.nix index a857ffb..39ba9b9 100644 --- a/modules/nix-bitcoin-webindex.nix +++ b/modules/nix-bitcoin-webindex.nix @@ -47,6 +47,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.nanopos.enable; + message = "nix-bitcoin-webindex requires nanopos."; + } + ]; + systemd.tmpfiles.rules = [ "d /var/www 0755 nginx nginx - -" ]; diff --git a/modules/recurring-donations.nix b/modules/recurring-donations.nix index 659891a..901c8f7 100644 --- a/modules/recurring-donations.nix +++ b/modules/recurring-donations.nix @@ -78,6 +78,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.clightning.enable; + message = "recurring-donations requires clightning."; + } + ]; + users.users.recurring-donations = { description = "recurring-donations User"; group = "recurring-donations"; diff --git a/modules/spark-wallet.nix b/modules/spark-wallet.nix index a329def..477bdfd 100644 --- a/modules/spark-wallet.nix +++ b/modules/spark-wallet.nix @@ -46,6 +46,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + { assertion = config.services.clightning.enable; + message = "spark-wallet requires clightning."; + } + ]; + environment.systemPackages = [ pkgs.nix-bitcoin.spark-wallet ]; users.users.spark-wallet = { description = "spark-wallet User";