From c8251cdad7d511042c968cd2bda730de2ed5ca2b Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 5 Oct 2021 15:07:56 +0200 Subject: [PATCH] onion-services: don't always enable Tor Previously, Tor was always enabled because `cfg` was always nonempty (via definitions at `Set sensible defaults for some services`). Now only enable Tor if there are active onion services. Also rename var `services` -> `onionServices` to improve readability in section `Set getPublicAddressCmd ...` where the same name is also used for option `config.services`. --- modules/onion-services.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/onion-services.nix b/modules/onion-services.nix index 192ac87..490f136 100644 --- a/modules/onion-services.nix +++ b/modules/onion-services.nix @@ -43,18 +43,18 @@ let cfg = config.nix-bitcoin.onionServices; nbLib = config.nix-bitcoin.lib; - services = builtins.attrNames cfg; + onionServices = builtins.attrNames cfg; activeServices = builtins.filter (service: config.services.${service}.enable && cfg.${service}.enable - ) services; + ) onionServices; publicServices = builtins.filter (service: cfg.${service}.public) activeServices; in { inherit options; config = mkMerge [ - (mkIf (cfg != {}) { + (mkIf (activeServices != []) { # Define hidden services services.tor = { enable = true; @@ -93,7 +93,7 @@ in { publicServices' = builtins.filter (service: let srv = cfg.${service}; in srv.public && srv.enable - ) services; + ) onionServices; in genAttrs publicServices' (service: { getPublicAddressCmd = "cat ${config.nix-bitcoin.onionAddresses.dataDir}/services/${service}"; });