add curated clightning plugins
This commit is contained in:
63
pkgs/clightning-plugins/default.nix
Normal file
63
pkgs/clightning-plugins/default.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
pkgs: nbPython3Packages:
|
||||
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "lightningd";
|
||||
repo = "plugins";
|
||||
rev = "6cd472636926f05a9c472139fabe1ff11c90aa6a";
|
||||
sha256 = "1lisx85vzsfzjhdc6zdz0l6bcrdgg6rp5xbc5jmx93mv8qqg2cns";
|
||||
};
|
||||
|
||||
version = builtins.substring 0 7 src.rev;
|
||||
|
||||
plugins = with nbPython3Packages; {
|
||||
helpme = {};
|
||||
monitor = {};
|
||||
prometheus = {
|
||||
extraPkgs = [ prometheus_client ];
|
||||
patchRequirements = "--replace prometheus-client==0.6.0 prometheus-client==0.8.0";
|
||||
};
|
||||
rebalance = {};
|
||||
summary = {
|
||||
extraPkgs = [ packaging requests ];
|
||||
};
|
||||
zmq = {
|
||||
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
|
||||
${lib.optionalString (plugin ? patchRequirements) ''
|
||||
substituteInPlace requirements.txt ${plugin.patchRequirements}
|
||||
''}
|
||||
|
||||
# Check that requirements are met
|
||||
PYTHONPATH=${toString python}/${python.sitePackages} \
|
||||
${pkgs.python3Packages.pip}/bin/pip install -r requirements.txt --no-cache --no-index
|
||||
|
||||
chmod +x ${script}
|
||||
patchShebangs ${script}
|
||||
'';
|
||||
|
||||
passthru.path = "${drv}/${script}";
|
||||
};
|
||||
in drv;
|
||||
|
||||
in
|
||||
builtins.mapAttrs mkPlugin plugins
|
||||
14
pkgs/clightning-plugins/get-sha256.sh
Executable file
14
pkgs/clightning-plugins/get-sha256.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p git
|
||||
set -euo pipefail
|
||||
|
||||
archive_hash () {
|
||||
repo=$1
|
||||
rev=$2
|
||||
nix-prefetch-url --unpack "https://github.com/${repo}/archive/${rev}.tar.gz" 2> /dev/null | tail -n 1
|
||||
}
|
||||
|
||||
echo "Fetching latest lightningd/plugins release"
|
||||
latest=$(git ls-remote https://github.com/lightningd/plugins master | cut -f 1)
|
||||
echo "rev: ${latest}"
|
||||
echo "sha256: $(archive_hash lightningd/plugins $latest)"
|
||||
@@ -13,6 +13,7 @@ let self = {
|
||||
netns-exec = pkgs.callPackage ./netns-exec { };
|
||||
lightning-loop = pkgs.callPackage ./lightning-loop { };
|
||||
extra-container = pkgs.callPackage ./extra-container { };
|
||||
clightning-plugins = import ./clightning-plugins pkgs self.nbPython3Packages;
|
||||
|
||||
nbPython3Packages = (pkgs.python3.override {
|
||||
packageOverrides = pySelf: super: import ./python-packages self pySelf;
|
||||
@@ -23,4 +24,8 @@ let self = {
|
||||
lib = import ./lib.nix { inherit (pkgs) lib; };
|
||||
|
||||
modulesPkgs = self // self.pinned;
|
||||
|
||||
# Used in ../.travis.yml
|
||||
clightning-plugins-all = pkgs.writeText "clightning-plugins"
|
||||
(pkgs.lib.concatMapStringsSep "\n" toString (builtins.attrValues self.clightning-plugins));
|
||||
}; in self
|
||||
|
||||
Reference in New Issue
Block a user