From 0bede274a8054f126d8f2bf811ced45efd7cbbe9 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 23 Feb 2022 20:32:01 +0100 Subject: [PATCH] clightning-plugins/commando: add module --- README.md | 1 + modules/clightning-plugins/commando.nix | 37 +++++++++++++++++++++++++ modules/clightning-plugins/default.nix | 1 + test/tests.nix | 5 ++++ 4 files changed, 44 insertions(+) create mode 100644 modules/clightning-plugins/commando.nix diff --git a/README.md b/README.md index 09f4b47..a798fb1 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ NixOS modules ([src](modules/modules.nix)) * [clightning](https://github.com/ElementsProject/lightning) with support for announcing an onion service\ Available plugins: * [clboss](https://github.com/ZmnSCPxj/clboss): automated C-Lightning Node Manager + * [commando](https://github.com/lightningd/plugins/tree/master/commando): control your node over lightning * [helpme](https://github.com/lightningd/plugins/tree/master/helpme): walks you through setting up a fresh c-lightning node * [monitor](https://github.com/renepickhardt/plugins/tree/master/monitor): helps you analyze the health of your peers and channels * [prometheus](https://github.com/lightningd/plugins/tree/master/prometheus): lightning node exporter for the prometheus timeseries server diff --git a/modules/clightning-plugins/commando.nix b/modules/clightning-plugins/commando.nix new file mode 100644 index 0000000..b9c19f4 --- /dev/null +++ b/modules/clightning-plugins/commando.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.services.clightning.plugins.commando; in +{ + options.services.clightning.plugins.commando = { + enable = mkEnableOption "commando (clightning plugin)"; + readers = mkOption { + type = with types; listOf str; + default = []; + example = [ "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518" ]; + description = '' + IDs of nodes which can execute read-only commands (list*, get*, ...). + ''; + }; + writers = mkOption { + type = with types; listOf str; + default = []; + example = [ "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518" ]; + description = '' + IDs of nodes which can execute any commands. + ''; + }; + }; + + config = mkIf cfg.enable { + services.clightning.extraConfig = '' + plugin=${config.nix-bitcoin.pkgs.clightning-plugins.commando.path} + '' + + concatMapStrings (reader: '' + commando_reader=${reader} + '') cfg.readers + + concatMapStrings (writer: '' + commando_writer=${writer} + '') cfg.writers; + }; +} diff --git a/modules/clightning-plugins/default.nix b/modules/clightning-plugins/default.nix index 9a39782..da30464 100644 --- a/modules/clightning-plugins/default.nix +++ b/modules/clightning-plugins/default.nix @@ -13,6 +13,7 @@ let in { imports = [ ./clboss.nix + ./commando.nix ./prometheus.nix ./summary.nix ./zmq.nix diff --git a/test/tests.nix b/test/tests.nix index 7f06a16..b746295 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -132,6 +132,11 @@ let prometheus.enable = true; rebalance.enable = true; summary.enable = true; + commando = { + enable = true; + readers = [ "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518" ]; + writers = [ "0336efaa22b8ba77ae721a25d589e1c5f2486073dd2f041add32a23316150e8b62" ]; + }; zmq = let tcpEndpoint = "tcp://127.0.0.1:5501"; in { enable = true; channel-opened = tcpEndpoint;