mirror of
https://github.com/fort-nix/nix-bitcoin.git
synced 2024-11-27 02:12:45 +03:00
109dccca27
Enable markdown syntax (instead of docbook) for descriptions. This only affects external doc tooling that renders the descriptions.
51 lines
1.1 KiB
Nix
51 lines
1.1 KiB
Nix
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
let
|
|
options.services.clightning.plugins.zmq = {
|
|
enable = mkEnableOption "ZMQ (clightning plugin)";
|
|
} // lib.genAttrs endpoints mkEndpointOption;
|
|
|
|
cfg = config.services.clightning.plugins.zmq;
|
|
|
|
nbLib = config.nix-bitcoin.lib;
|
|
|
|
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 = mdDoc "Endpoint for ${name}";
|
|
};
|
|
|
|
setEndpoint = ep:
|
|
let value = builtins.getAttr ep cfg; in
|
|
optionalString (value != null) ''
|
|
zmq-pub-${ep}=${value}
|
|
'';
|
|
in
|
|
{
|
|
inherit options;
|
|
|
|
config = mkIf cfg.enable {
|
|
services.clightning.extraConfig = ''
|
|
plugin=${config.nix-bitcoin.pkgs.clightning-plugins.zmq.path}
|
|
${concatStrings (map setEndpoint endpoints)}
|
|
'';
|
|
|
|
# The zmq server requires AF_NETLINK
|
|
systemd.services.clightning.serviceConfig.RestrictAddressFamilies =
|
|
mkForce nbLib.allowNetlink.RestrictAddressFamilies;
|
|
};
|
|
}
|