add curated clightning plugins
This commit is contained in:
27
modules/clightning-plugins/default.nix
Normal file
27
modules/clightning-plugins/default.nix
Normal 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}")
|
||||
];
|
||||
};
|
||||
}
|
||||
21
modules/clightning-plugins/prometheus.nix
Normal file
21
modules/clightning-plugins/prometheus.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
39
modules/clightning-plugins/summary.nix
Normal file
39
modules/clightning-plugins/summary.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
42
modules/clightning-plugins/zmq.nix
Normal file
42
modules/clightning-plugins/zmq.nix
Normal 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)}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user