diff --git a/modules/onion-services.nix b/modules/onion-services.nix index 52c6c2f..288e673 100644 --- a/modules/onion-services.nix +++ b/modules/onion-services.nix @@ -10,6 +10,7 @@ with lib; let cfg = config.nix-bitcoin.onionServices; + nbLib = config.nix-bitcoin.lib; services = builtins.attrNames cfg; @@ -60,13 +61,10 @@ in { let service = config.services.${name}; inherit (cfg.${name}) externalPort; - in { - map = [{ - port = if externalPort != null then externalPort else service.port; - toPort = service.port; - toHost = if service.address == "0.0.0.0" then "127.0.0.1" else service.address; - }]; - version = 3; + in nbLib.mkHiddenService { + port = if externalPort != null then externalPort else service.port; + toPort = service.port; + toHost = if service.address == "0.0.0.0" then "127.0.0.1" else service.address; } ); }; diff --git a/modules/presets/secure-node.nix b/modules/presets/secure-node.nix index a0472c4..cf09b60 100644 --- a/modules/presets/secure-node.nix +++ b/modules/presets/secure-node.nix @@ -4,13 +4,8 @@ with lib; let cfg = config.services; - + nbLib = config.nix-bitcoin.lib; operatorName = config.nix-bitcoin.operator.name; - - mkHiddenService = map: { - map = [ map ]; - version = 3; - }; in { imports = [ ../modules.nix @@ -30,7 +25,7 @@ in { ]; # sshd - services.tor.hiddenServices.sshd = mkHiddenService { port = 22; }; + services.tor.hiddenServices.sshd = nbLib.mkHiddenService { port = 22; }; nix-bitcoin.onionAddresses.access.${operatorName} = [ "sshd" ]; services.bitcoind = { diff --git a/pkgs/lib.nix b/pkgs/lib.nix index 75409bf..ab8bfb0 100644 --- a/pkgs/lib.nix +++ b/pkgs/lib.nix @@ -65,4 +65,9 @@ let self = { type = types.str; default = "exec"; }; + + mkHiddenService = map: { + map = [ map ]; + version = 3; + }; }; in self