diff --git a/modules/clightning-plugins/clboss.nix b/modules/clightning-plugins/clboss.nix new file mode 100644 index 0000000..5a01a20 --- /dev/null +++ b/modules/clightning-plugins/clboss.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.services.clightning.plugins.clboss; in +{ + options.services.clightning.plugins.clboss = { + enable = mkEnableOption "CLBOSS (clightning plugin)"; + min-onchain = mkOption { + type = types.ints.positive; + default = 30000; + description = '' + Specify target amount (in satoshi) that CLBOSS will leave onchain. + ''; + }; + }; + + config = mkIf cfg.enable { + services.clightning.extraConfig = '' + plugin=${config.nix-bitcoin.pkgs.clboss}/bin/clboss + clboss-min-onchain=${toString cfg.min-onchain} + ''; + systemd.services.clightning.path = [ + pkgs.dnsutils + ] ++ optional config.services.clightning.enforceTor (hiPrio config.nix-bitcoin.torify); + }; +} diff --git a/modules/clightning-plugins/default.nix b/modules/clightning-plugins/default.nix index 946cdc2..4de6bb1 100644 --- a/modules/clightning-plugins/default.nix +++ b/modules/clightning-plugins/default.nix @@ -6,6 +6,7 @@ let pluginPkgs = config.nix-bitcoin.pkgs.clightning-plugins; in { imports = [ + ./clboss.nix ./prometheus.nix ./summary.nix ./zmq.nix diff --git a/modules/modules.nix b/modules/modules.nix index 7a3ddf3..4dd50eb 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -1,5 +1,6 @@ { config, pkgs, lib, ... }: +with lib; { imports = [ # Core modules @@ -33,14 +34,27 @@ disabledModules = [ "services/networking/bitcoind.nix" ]; options = { - nix-bitcoin-services = lib.mkOption { + nix-bitcoin-services = mkOption { readOnly = true; default = import ./nix-bitcoin-services.nix lib pkgs; }; - nix-bitcoin.pkgs = lib.mkOption { - type = lib.types.attrs; - default = (import ../pkgs { inherit pkgs; }).modulesPkgs; + nix-bitcoin = { + pkgs = mkOption { + type = types.attrs; + default = (import ../pkgs { inherit pkgs; }).modulesPkgs; + }; + + # Torify binary that works with custom Tor SOCKS addresses + # Related issue: https://github.com/NixOS/nixpkgs/issues/94236 + torify = mkOption { + readOnly = true; + default = pkgs.writeScriptBin "torify" '' + ${pkgs.tor}/bin/torify \ + --address ${head (splitString ":" config.services.tor.client.socksListenAddress)} \ + "$@" + ''; + }; }; }; diff --git a/pkgs/clboss/default.nix b/pkgs/clboss/default.nix new file mode 100644 index 0000000..f7f5725 --- /dev/null +++ b/pkgs/clboss/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchurl, pkgconfig, curl, libev, sqlite }: + +let + curlWithGnuTLS = curl.override { gnutlsSupport = true; sslSupport = false; }; +in +stdenv.mkDerivation rec { + pname = "clboss"; + version = "0.10"; + + src = fetchurl { + url = "https://github.com/ZmnSCPxj/clboss/releases/download/v${version}/clboss-${version}.tar.gz"; + sha256 = "1bmlpfhsjs046qx2ikln15rj4kal32752zs1s5yjklsq9xwnbciz"; + }; + + nativeBuildInputs = [ pkgconfig libev curlWithGnuTLS sqlite ]; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + description = "Automated C-Lightning Node Manager"; + homepage = "https://github.com/ZmnSCPxj/clboss"; + maintainers = with maintainers; [ nixbitcoin ]; + license = licenses.mit; + platforms = platforms.linux; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 166715d..a054663 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14,6 +14,7 @@ let self = { lightning-loop = pkgs.callPackage ./lightning-loop { }; extra-container = pkgs.callPackage ./extra-container { }; clightning-plugins = import ./clightning-plugins pkgs self.nbPython3Packages; + clboss = pkgs.callPackage ./clboss { }; nbPython3Packages = (pkgs.python3.override { packageOverrides = pySelf: super: import ./python-packages self pySelf; diff --git a/test/tests.nix b/test/tests.nix index f9924ee..ee0ae25 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -79,6 +79,7 @@ let testEnv = rec { } (mkIf config.test.features.clightningPlugins { services.clightning.plugins = { + # TODO: add clboss when https://github.com/ZmnSCPxj/clboss/issues/49 is closed helpme.enable = true; monitor.enable = true; prometheus.enable = true;