nix-bitcoin/pkgs/clightning-plugins/default.nix

91 lines
2.7 KiB
Nix
Raw Normal View History

2020-11-19 02:01:45 +00:00
pkgs: nbPython3Packages:
let
inherit (pkgs) lib;
2023-07-23 17:45:19 +00:00
src = pkgs.fetchFromGitHub {
owner = "lightningd";
repo = "plugins";
rev = "ce078bb74e10b5dea779fcd9fbe77e1d3e72db7a";
hash = "sha256-SCHSJzXe1l14hVT47SU3lWDxKCKwwICjXjSDpjUX96U";
2020-11-19 02:01:45 +00:00
};
2023-07-23 17:45:19 +00:00
version = builtins.substring 0 7 src.rev;
2020-11-19 02:01:45 +00:00
plugins = with nbPython3Packages; {
currencyrate = {
description = "Currency rate fetcher and converter";
extraPkgs = [ requests cachetools ];
};
feeadjuster = {
description = "Dynamically changes channel fees to keep your channels more balanced";
};
helpme = {
description = "Walks you through setting up a c-lightning node, offering advice for common problems";
};
monitor = {
description = "Helps you analyze the health of your peers and channels";
extraPkgs = [ packaging ];
};
2020-11-19 02:01:45 +00:00
prometheus = {
description = "Lightning node exporter for the prometheus timeseries server";
2020-11-19 02:01:45 +00:00
extraPkgs = [ prometheus_client ];
patchRequirements =
2023-07-08 13:33:04 +00:00
"--replace prometheus-client==0.6.0 prometheus-client==0.16.0"
+ " --replace pyln-client~=0.9.3 pyln-client~=23.02";
2020-11-19 02:01:45 +00:00
};
rebalance = {
description = "Keeps your channels balanced";
};
2020-11-19 02:01:45 +00:00
summary = {
description = "Prints a summary of the node status";
2020-11-19 02:01:45 +00:00
extraPkgs = [ packaging requests ];
};
zmq = {
description = "Publishes notifications via ZeroMQ to configured endpoints";
2020-11-19 02:01:45 +00:00
scriptName = "cl-zmq";
extraPkgs = [ twisted txzmq ];
};
};
basePkgs = [ nbPython3Packages.pyln-client ];
mkPlugin = name: plugin: let
python = pkgs.python3.withPackages (_: basePkgs ++ (plugin.extraPkgs or []));
script = "${plugin.scriptName or name}.py";
drv = pkgs.stdenv.mkDerivation {
pname = "clightning-plugin-${name}";
inherit version;
buildInputs = [ python ];
buildCommand = ''
cp --no-preserve=mode -r '${src}/${name}' "$out"
cd "$out"
2020-11-19 02:01:45 +00:00
${lib.optionalString (plugin ? patchRequirements) ''
substituteInPlace requirements.txt ${plugin.patchRequirements}
''}
# Check that requirements are met
PYTHONPATH='${toString python}/${python.sitePackages}' \
2023-07-08 13:33:04 +00:00
${pkgs.python3Packages.pip}/bin/pip install -r requirements.txt --no-cache --no-index --break-system-packages
2020-11-19 02:01:45 +00:00
chmod +x '${script}'
patchShebangs '${script}'
2020-11-19 02:01:45 +00:00
'';
passthru.path = "${drv}/${script}";
meta = with lib; {
inherit (plugin) description;
homepage = "https://github.com/lightningd/plugins";
license = licenses.bsd3;
maintainers = with maintainers; [ nixbitcoin erikarvstedt ];
platforms = platforms.unix;
};
2020-11-19 02:01:45 +00:00
};
in drv;
in
builtins.mapAttrs mkPlugin plugins