add curated clightning plugins

This commit is contained in:
Ian Shipman
2020-11-19 03:01:45 +01:00
parent 4640821f96
commit 1d44b99340
14 changed files with 295 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.clightning.plugins;
pluginPkgs = config.nix-bitcoin.pkgs.clightning-plugins;
in {
imports = [
./prometheus.nix
./summary.nix
./zmq.nix
];
options.services.clightning.plugins = {
helpme.enable = mkEnableOption "Help me (clightning plugin)";
monitor.enable = mkEnableOption "Monitor (clightning plugin)";
rebalance.enable = mkEnableOption "Rebalance (clightning plugin)";
};
config = {
services.clightning.extraConfig = mkMerge [
(mkIf cfg.helpme.enable "plugin=${pluginPkgs.helpme.path}")
(mkIf cfg.monitor.enable "plugin=${pluginPkgs.monitor.path}")
(mkIf cfg.rebalance.enable "plugin=${pluginPkgs.rebalance.path}")
];
};
}

View File

@@ -0,0 +1,21 @@
{ config, lib, ... }:
with lib;
let cfg = config.services.clightning.plugins.prometheus; in
{
options.services.clightning.plugins.prometheus = {
enable = mkEnableOption "Prometheus (clightning plugin)";
listen = mkOption {
type = types.str;
default = "0.0.0.0:9750";
description = "Address and port to bind to.";
};
};
config = mkIf cfg.enable {
services.clightning.extraConfig = ''
plugin=${config.nix-bitcoin.pkgs.clightning-plugins.prometheus.path}
prometheus-listen=${cfg.listen}
'';
};
}

View File

@@ -0,0 +1,39 @@
{ config, lib, ... }:
with lib;
let cfg = config.services.clightning.plugins.summary; in
{
options.services.clightning.plugins.summary = {
enable = mkEnableOption "Summary (clightning plugin)";
currency = mkOption {
type = types.str;
default = "USD";
description = "The currency to look up on btcaverage.";
};
currencyPrefix = mkOption {
type = types.str;
default = "USD $";
description = "The prefix to use for the currency.";
};
availabilityInterval = mkOption {
type = types.int;
default = 300;
description = "How often in seconds the availability should be calculated.";
};
availabilityWindow = mkOption {
type = types.int;
default = 72;
description = "How many hours the availability should be averaged over.";
};
};
config = mkIf cfg.enable {
services.clightning.extraConfig = ''
plugin=${config.nix-bitcoin.pkgs.clightning-plugins.summary.path}
summary-currency="${cfg.currency}"
summary-currency-prefix="${cfg.currencyPrefix}"
summary-availability-interval=${toString cfg.availabilityInterval}
summary-availability-window=${toString cfg.availabilityWindow}
'';
};
}

View File

@@ -0,0 +1,42 @@
{ config, lib, ... }:
with lib;
let
cfg = config.services.clightning.plugins.zmq;
endpoints = [
"channel-opened"
"connect"
"disconnect"
"invoice-payment"
"warning"
"forward-event"
"sendpay-success"
"sendpay-failure"
];
mkEndpointOption = name:
mkOption {
type = types.nullOr types.str;
default = null;
description = "Endpoint for ${name}";
};
setEndpoint = ep:
let value = builtins.getAttr ep cfg; in
optionalString (value != null) ''
zmq-pub-${ep}=${value}
'';
in
{
options.services.clightning.plugins.zmq = {
enable = mkEnableOption "ZMQ (clightning plugin)";
} // lib.genAttrs endpoints mkEndpointOption;
config = mkIf cfg.enable {
services.clightning.extraConfig = ''
plugin=${config.nix-bitcoin.pkgs.clightning-plugins.zmq.path}
${concatStrings (map setEndpoint endpoints)}
'';
};
}