From e731d7123240b1354f49fb223549835b44dd8549 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 4 Mar 2020 18:09:02 +0100 Subject: [PATCH] electrs: add option 'address' --- modules/electrs.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/electrs.nix b/modules/electrs.nix index 3cd21a2..923fe74 100644 --- a/modules/electrs.nix +++ b/modules/electrs.nix @@ -34,6 +34,11 @@ in { If enabled, the electrs service will sync faster on high-memory systems (≥ 8GB). ''; }; + address = mkOption { + type = types.str; + default = "127.0.0.1"; + description = "RPC listening address."; + }; port = mkOption { type = types.ints.u16; default = 50001; @@ -76,7 +81,7 @@ in { ${pkgs.nix-bitcoin.electrs}/bin/electrs -vvv \ ${optionalString (!cfg.high-memory) "--jsonrpc-import --index-batch-size=10"} \ --db-dir '${cfg.dataDir}' --daemon-dir '${config.services.bitcoind.dataDir}' \ - --electrum-rpc-addr=127.0.0.1:${toString cfg.port} + --electrum-rpc-addr=${toString cfg.address}:${toString cfg.port} ''; User = cfg.user; Group = cfg.group; @@ -101,10 +106,18 @@ in { (mkIf cfg.TLSProxy.enable { services.nginx = { enable = true; - appendConfig = '' + appendConfig = let + address = + if cfg.address == "0.0.0.0" then + "127.0.0.1" + else if cfg.address == "::" then + "::1" + else + cfg.address; + in '' stream { upstream electrs { - server 127.0.0.1:${toString cfg.port}; + server ${address}:${toString cfg.port}; } server {