diff --git a/examples/configuration.nix b/examples/configuration.nix index 4d92217..5d79067 100644 --- a/examples/configuration.nix +++ b/examples/configuration.nix @@ -28,6 +28,10 @@ # LND and electrs are not compatible with pruning. # services.bitcoind.prune = 100000; # + # Set this to accounce the onion service address to peers. + # The onion service allows accepting incoming connections via Tor. + # nix-bitcoin.onionServices.bitcoind.public = true; + # # You can add options that are not defined in modules/bitcoind.nix as follows # services.bitcoind.extraConfig = '' # maxorphantx=110 diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index a4bb90b..061560a 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -67,6 +67,14 @@ in { default = 8333; description = "Port to listen for peer connections."; }; + getPublicAddressCmd = mkOption { + type = types.str; + default = ""; + description = '' + Bash expression which outputs the public service address to announce to peers. + If left empty, no address is announced. + ''; + }; package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.bitcoind; @@ -328,6 +336,10 @@ in { ${extraRpcauth} ${/* Enable bitcoin-cli for group 'bitcoin' */ ""} printf "rpcuser=${cfg.rpc.users.privileged.name}\nrpcpassword="; cat "${secretsDir}/bitcoin-rpcpassword-privileged"; + echo + ${optionalString (cfg.getPublicAddressCmd != "") '' + echo "externalip=$(${cfg.getPublicAddressCmd})" + ''} ) confFile='${cfg.dataDir}/bitcoin.conf' if [[ ! -e $confFile || $cfg != $(cat $confFile) ]]; then