move mkHiddenService to lib

This commit is contained in:
Erik Arvstedt 2021-02-03 22:44:42 +01:00 committed by nixbitcoin
parent a26ed03d77
commit a344ae95c9
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA
3 changed files with 12 additions and 14 deletions

View File

@ -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 = [{
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;
}];
version = 3;
}
);
};

View File

@ -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 = {

View File

@ -65,4 +65,9 @@ let self = {
type = types.str;
default = "exec";
};
mkHiddenService = map: {
map = [ map ];
version = 3;
};
}; in self