From 4824cb3372add1efd98ed13cb39515a286a2308a Mon Sep 17 00:00:00 2001 From: oyindamola oladapo Date: Sat, 12 Jul 2025 22:21:51 +0100 Subject: [PATCH 1/2] ci: fix and simplify cln-plugin job - Correct YAML indentation - Fix Poetry installation (no --user, avoids not found errors) - Remove unnecessary steps and sudo usage - Modularize CLN cache jobs - Run `poetry run make` concurrently to speed up build --- .github/workflows/cln-plugin.yaml | 39 ++++++++++++++++++------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cln-plugin.yaml b/.github/workflows/cln-plugin.yaml index 6b710ab..9451239 100644 --- a/.github/workflows/cln-plugin.yaml +++ b/.github/workflows/cln-plugin.yaml @@ -11,8 +11,22 @@ env: cln_version: "24.11.1" jobs: + check-cln-cache: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Check CLN cache + id: cache + uses: actions/cache@v4 + with: + path: lightning + key: ${{ runner.os }}-build-cache-cln-dev-v${{ env.cln_version }} + cache-cln: runs-on: ubuntu-latest + needs: check-cln-cache + if: ${{ needs.check-cln-cache.outputs.cache-hit != 'true' }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -23,26 +37,22 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Create CLN cache - id: cache-cln uses: actions/cache@v4 - env: - cache-name: cache-cln-dev with: path: lightning - key: ${{ runner.os }}-build-${{ env.cache-name }}-v${{ env.cln_version }} + key: ${{ runner.os }}-build-cache-cln-dev-v${{ env.cln_version }} - name: Compile CLN env: PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring - if: ${{ steps.cache-cln.outputs.cache-hit != 'true' }} run: | sudo apt-get update && sudo apt-get install -y gettext git clone https://github.com/ElementsProject/lightning.git && cd lightning && git checkout v${{ env.cln_version }} pip install --user poetry && poetry install - cargo update -p time - ./configure && poetry run make + ./configure && poetry run make -j 8 cln-plugin: needs: cache-cln + if: ${{ always() }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -56,7 +66,7 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: 1.81.0 + toolchain: stable components: rustfmt, clippy - name: Install bitcoind run: | @@ -66,15 +76,12 @@ jobs: - name: Load CLN cache id: cache-cln uses: actions/cache@v4 - env: - cache-name: cache-cln-dev with: path: lightning - key: ${{ runner.os }}-build-${{ env.cache-name }}-v${{ env.cln_version }} - - name: Link CLN - run: | - source $HOME/.cargo/env - cd lightning && sudo make install + key: ${{ runner.os }}-build-cache-cln-dev-v${{ env.cln_version }} + - name: Link CLN + run: | + cd lightning && sudo PATH=$PATH make install - name: Install teos and the plugin run: | cargo install --locked --path teos @@ -82,7 +89,7 @@ jobs: - name: Add test dependencies run: | cd watchtower-plugin/tests - pip install --user poetry && poetry install + pip install --user poetry && poetry install --no-root - name: Run tests run: | cd watchtower-plugin/tests From 70ea8b5625e5c327e35e1b0e9e65a890a1874a5d Mon Sep 17 00:00:00 2001 From: Joseph Goulden Date: Wed, 8 Oct 2025 22:12:40 +0100 Subject: [PATCH 2/2] Add nix flake to build teos with nixpkgs 25.05 --- .github/workflows/build.yaml | 15 ++++- .gitignore | 3 +- flake.lock | 116 +++++++++++++++++++++++++++++++++++ flake.nix | 114 ++++++++++++++++++++++++++++++++++ 4 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 88768c1..e80276c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -66,4 +66,17 @@ jobs: uses: psf/black@stable with: src: "./watchtower-plugin/tests" - options: "--check -l 120" \ No newline at end of file + options: "--check -l 120" + + check-flake: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Check Nix flake inputs + uses: DeterminateSystems/flake-checker-action@v12 + - name: Install Nix + uses: cachix/install-nix-action@v31 + - name: Check flake + run: nix flake check + diff --git a/.gitignore b/.gitignore index 3b7e0f7..599e08c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ target __pycache__ .vscode -.idea \ No newline at end of file +.idea +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ca135b2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1758758545, + "narHash": "sha256-NU5WaEdfwF6i8faJ2Yh+jcK9vVFrofLcwlD/mP65JrI=", + "owner": "ipetkov", + "repo": "crane", + "rev": "95d528a5f54eaba0d12102249ce42f4d01f4e364", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1758782550, + "narHash": "sha256-olCvyP5r6+HQTl2EUudtjlA5UammsBpkzAl0l9+utZc=", + "owner": "nix-community", + "repo": "fenix", + "rev": "32f4e350c03cc5762be811e9c700e8696cd13c02", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1758589230, + "narHash": "sha256-zMTCFGe8aVGTEr2RqUi/QzC1nOIQ0N1HRsbqB4f646k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d1d883129b193f0b495d75c148c2c3a7d95789a0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1758620797, + "narHash": "sha256-Ly4rHgrixFMBnkbMursVt74mxnntnE6yVdF5QellJ+A=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "905641f3520230ad6ef421bcf5da9c6b49f2479b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a272a74 --- /dev/null +++ b/flake.nix @@ -0,0 +1,114 @@ +{ + description = "Build teos (The Eye of Satoshi) server and plugin"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + + crane.url = "github:ipetkov/crane"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + nixpkgs, + crane, + fenix, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + inherit (pkgs) lib; + + craneLib = (crane.mkLib pkgs).overrideToolchain fenix.packages.${system}.stable.minimalToolchain; + + env = { + PROTOC = "${pkgs.protobuf}/bin/protoc"; + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; + LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.openssl.out ]; + }; + commonArgs = { + inherit env; + strictDeps = true; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.rustfmt # needed for tonic build + pkgs.cacert + pkgs.openssl.dev + ]; + + buildInputs = + [ ] + ++ lib.optionals pkgs.stdenv.isDarwin [ + # Additional darwin specific inputs can be set here + pkgs.libiconv + ]; + }; + + fileSetForCrate = + crate: + lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./Cargo.toml + ./Cargo.lock + ./teos-common + ./teos + ./watchtower-plugin + crate + ]; + }; + + plugin = craneLib.buildPackage ( + commonArgs + // { + pname = "watchtower-plugin"; + cargoExtraArgs = "-p watchtower-plugin"; + src = fileSetForCrate ./watchtower-plugin; + inherit (craneLib.crateNameFromCargoToml { cargoToml = ./watchtower-plugin/Cargo.toml; }) version; + } + ); + teos = craneLib.buildPackage ( + commonArgs + // { + pname = "teos"; + cargoExtraArgs = "-p teos"; + src = fileSetForCrate ./teos; + inherit (craneLib.crateNameFromCargoToml { cargoToml = ./teos/Cargo.toml; }) version; + } + ); + in + { + packages = { + inherit plugin teos; + default = teos; + }; + + apps = { + plugin = flake-utils.lib.mkApp { drv = plugin; }; + teos = flake-utils.lib.mkApp { drv = teos; }; + }; + + formatter = pkgs.nixfmt-tree; + + checks = { + inherit teos plugin; + }; + + devShells.default = craneLib.devShell { + inherit env; + packages = commonArgs.buildInputs ++ commonArgs.nativeBuildInputs; + }; + } + ); +}