From cfbfa3a8b079f2dd1b3d10719a13600dc09c0f80 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Fri, 13 Mar 2026 00:40:46 -0400 Subject: [PATCH] clnrest ready --- .../bitcoin/modules/clightning/default.nix | 32 +---------- .../modules/clightning/plugins/clnrest.nix | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 src/system/modules/bitcoin/modules/clightning/plugins/clnrest.nix diff --git a/src/system/modules/bitcoin/modules/clightning/default.nix b/src/system/modules/bitcoin/modules/clightning/default.nix index 92f426f..f052e52 100644 --- a/src/system/modules/bitcoin/modules/clightning/default.nix +++ b/src/system/modules/bitcoin/modules/clightning/default.nix @@ -8,37 +8,7 @@ let home = "/var/lib/clightning"; domain = "ramos.codes"; - clnrest = pkgs.rustPlatform.buildRustPackage rec { - pname = "clnrest"; - version = "25.02.2"; - - src = pkgs.fetchFromGitHub { - owner = "ElementsProject"; - repo = "lightning"; - rev = "v${version}"; - hash = "sha256-SiPYB463l9279+zawsxmql1Ui/dTdah5KgJgmrWsR2A="; - }; - - cargoLock.lockFile = "${src}/Cargo.lock"; - - cargoBuildFlags = [ "-p" "clnrest" ]; - cargoTestFlags = [ "-p" "clnrest" ]; - - nativeBuildInputs = with pkgs; [ pkg-config protobuf ]; - buildInputs = [ pkgs.openssl ]; - - postInstall = '' - mkdir -p $out/libexec/c-lightning/plugins - mv $out/bin/clnrest $out/libexec/c-lightning/plugins/ - rmdir $out/bin - ''; - - meta = with lib; { - description = "REST API plugin for Core Lightning"; - homepage = "https://github.com/ElementsProject/lightning/tree/master/plugins/rest-plugin"; - license = licenses.mit; - }; - }; + clnrest = pkgs.callPackage ./plugins/clnrest.nix { }; clnConfig = pkgs.writeTextFile { name = "lightning.conf"; diff --git a/src/system/modules/bitcoin/modules/clightning/plugins/clnrest.nix b/src/system/modules/bitcoin/modules/clightning/plugins/clnrest.nix new file mode 100644 index 0000000..b4124cf --- /dev/null +++ b/src/system/modules/bitcoin/modules/clightning/plugins/clnrest.nix @@ -0,0 +1,54 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + openssl, + protobuf, +}: + +rustPlatform.buildRustPackage rec { + pname = "clnrest"; + version = "25.02.2"; + + src = fetchFromGitHub { + owner = "ElementsProject"; + repo = "lightning"; + rev = "v${version}"; + hash = "sha256-SiPYB463l9279+zawsxmql1Ui/dTdah5KgJgmrWsR2A="; + }; + + cargoLock = { + lockFile = "${src}/Cargo.lock"; + }; + + cargoBuildFlags = [ + "-p" + "clnrest" + ]; + cargoTestFlags = [ + "-p" + "clnrest" + ]; + + nativeBuildInputs = [ + pkg-config + protobuf + ]; + + buildInputs = [ openssl ]; + + postInstall = '' + mkdir -p $out/libexec/c-lightning/plugins + mv $out/bin/clnrest $out/libexec/c-lightning/plugins/ + rmdir $out/bin + ''; + + meta = { + description = "Transforms RPC calls into REST APIs"; + homepage = "https://docs.corelightning.org/docs/rest"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + mainProgram = "clnrest"; + }; +}