diff --git a/README.md b/README.md index 827204ce9..7ce3d57c0 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ NixOS modules ([src](modules/modules.nix)) * [prometheus](https://github.com/lightningd/plugins/tree/master/prometheus): lightning node exporter for the prometheus timeseries server * [rebalance](https://github.com/lightningd/plugins/tree/master/rebalance): keeps your channels balanced * [summary](https://github.com/lightningd/plugins/tree/master/summary): print a nice summary of the node status + * [teos-watchtower-plugin](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin): watchtower client plugin to interact with an Eye of Satoshi tower * [zmq](https://github.com/lightningd/plugins/tree/master/zmq): publishes notifications via ZeroMQ to configured endpoints * [clightning-rest](https://github.com/Ride-The-Lightning/c-lightning-REST): REST server for clightning * [lnd](https://github.com/lightningnetwork/lnd) with support for announcing an onion service and [static channel backups](https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md) diff --git a/modules/clightning-plugins/default.nix b/modules/clightning-plugins/default.nix index 86698605d..758d562b0 100644 --- a/modules/clightning-plugins/default.nix +++ b/modules/clightning-plugins/default.nix @@ -17,6 +17,7 @@ in { ./feeadjuster.nix ./prometheus.nix ./summary.nix + ./teos-watchtower-plugin.nix ./zmq.nix ]; diff --git a/modules/clightning-plugins/teos-watchtower-plugin.nix b/modules/clightning-plugins/teos-watchtower-plugin.nix new file mode 100644 index 000000000..353aa8289 --- /dev/null +++ b/modules/clightning-plugins/teos-watchtower-plugin.nix @@ -0,0 +1,52 @@ +{ config, lib, ... }: + +with lib; +let cfg = config.services.clightning.plugins.teos-watchtower-plugin; in +{ + options.services.clightning.plugins.teos-watchtower-plugin = { + enable = mkEnableOption "TEoS - watchtower (clightning plugin)"; + package = mkOption { + type = types.package; + default = config.nix-bitcoin.pkgs.teos.teos-watchtower-plugin; + defaultText = "config.nix-bitcoin.pkgs.teos.teos-watchtower-plugin"; + description = "The package providing TEoS watchtower plugin binaries."; + }; + port = mkOption { + type = types.int; + default = config.services.teos.api.port; + description = "tower API port."; + }; + dataDir = mkOption { + type = types.path; + default = "${config.services.clightning.dataDir}/.watchtower"; + description = "The data directory for teos-watchtower-plugin."; + }; + watchtowerMaxRetryTime = mkOption { + type = types.int; + default = 900; + description = "the maximum time a retry strategy will try to reach a temporary unreachable tower before giving up."; + }; + }; + + config = mkIf cfg.enable { + services.clightning.extraConfig = '' + plugin=${cfg.package}/bin/watchtower-client + watchtower-port=${toString cfg.port} + watchtower-max-retry-time=${toString cfg.watchtowerMaxRetryTime} + ''; + + # FIXME: Some better way to propagate this env variable to clightning + # service? Unfortunately it seems the teos-watchtower-plugin does not + # support specifying the data directory using a plugin configuration in + # clightning's config. + # + # Ref.: https://github.com/talaia-labs/rust-teos/blob/master/watchtower-plugin/README.md#config-file-data-folder-and-first-bootstrap + # Without this configuration, the plugin fails to load because it can't + # access its home directory - thanks to service hardening, specifically + # options: + # ProtectHome=true, isSystemUser=true + systemd.services.clightning.environment = { + TOWERS_DATA_DIR = cfg.dataDir; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index f0d38b4d9..7c35f50b5 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -21,7 +21,6 @@ let self = { secp256k1 = pkgs.callPackage ./secp256k1 { }; spark-wallet = pkgs.callPackage ./spark-wallet { }; teos = pkgs.callPackage ./teos { }; - teos-watchtower-plugin = pkgs.callPackage ./teos { }; nbPython3Packages = (pkgs.python3.override { packageOverrides = import ./python-packages self; diff --git a/test/tests.nix b/test/tests.nix index 5f2244efd..4ec33783d 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -62,6 +62,7 @@ let nbPkgs = config.nix-bitcoin.pkgs; pluginPkgs = nbPkgs.clightning-plugins // { clboss.path = "${nbPkgs.clboss}/bin/clboss"; + teos-watchtower-plugin.path = "${nbPkgs.teos.teos-watchtower-plugin}/bin/watchtower-client"; }; in map (plugin: pluginPkgs.${plugin}.path) enabled; # Torified 'dig' subprocesses of clboss don't respond to SIGTERM and keep