diff --git a/.dockerignore b/.dockerignore
index 85eb02fb567b..14b8a9115711 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,11 +1,6 @@
-config.vars
-.cargo/
-.vscode/
-.venv/
-dist/
-target/
-release/
-focal/
-jammy/
-noble/
-resolute/
+# The runtime Dockerfile needs only the entrypoint from the main context;
+# release artifacts and bitcoin-cli arrive as named build contexts. There are
+# no builder images in the tree any more -- the release is a Nix derivation --
+# so nothing else has to stay visible.
+*
+!tools/docker-entrypoint.sh
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
deleted file mode 100644
index fb9a51abfa33..000000000000
--- a/.github/workflows/docker-build.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-name: Docker build
-
-on:
- workflow_call:
- inputs:
- version:
- type: string
- required: true
- dh-repository-owner:
- type: string
- required: true
- platforms-to-build:
- type: string
- required: true
-
-jobs:
- # Turn the comma-separated platforms-to-build input into a JSON matrix array,
- # so we can fan out per-platform without hardcoding the list twice.
- plan:
- name: Plan platform matrix
- runs-on: ubuntu-24.04
- outputs:
- platforms: ${{ steps.plan.outputs.platforms }}
- steps:
- - id: plan
- env:
- PLATFORMS_TO_BUILD: ${{ inputs.platforms-to-build }}
- run: |
- IFS=',' read -ra ARR <<< "$PLATFORMS_TO_BUILD"
- JSON=$(printf '%s\n' "${ARR[@]}" | jq -R . | jq -sc .)
- echo "platforms=$JSON" >> "$GITHUB_OUTPUT"
-
- build:
- name: Build ${{ matrix.target == 'lightningd-vls-signer' && 'vls' || 'normal' }} / ${{ matrix.platform }}
- needs: plan
- strategy:
- fail-fast: false
- matrix:
- target:
- - lightningd
- - lightningd-vls-signer
- platform: ${{ fromJson(needs.plan.outputs.platforms) }}
- runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }}
- steps:
- - name: Checkout repository
- uses: actions/checkout@v7
- with:
- fetch-depth: 0
-
- - name: Set up QEMU
- if: matrix.platform == 'linux/arm/v7'
- uses: docker/setup-qemu-action@v4
-
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: Log in to Docker Hub
- uses: docker/login-action@v4
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
-
- - name: Build single-platform image, push by digest
- id: build
- uses: docker/build-push-action@v7
- with:
- context: .
- file: ./Dockerfile
- target: ${{ matrix.target }}
- platforms: ${{ matrix.platform }}
- build-args: |
- VERSION=${{ inputs.version }}
- outputs: type=image,name=${{ inputs.dh-repository-owner }}/lightningd,push-by-digest=true,name-canonical=true,push=true
- cache-from: type=gha,scope=${{ matrix.target }}-${{ matrix.platform }}
- cache-to: type=gha,mode=max,scope=${{ matrix.target }}-${{ matrix.platform }}
-
- - name: Save digest
- run: |
- mkdir -p /tmp/digests
- echo "${{ steps.build.outputs.digest }}" > /tmp/digests/digest.txt
-
- - name: Upload digest
- uses: actions/upload-artifact@v7
- with:
- name: digest_${{ matrix.target }}_${{ strategy.job-index }}
- path: /tmp/digests/digest.txt
- if-no-files-found: error
- retention-days: 1
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
deleted file mode 100644
index 9aee3a2a186a..000000000000
--- a/.github/workflows/docker-publish.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-name: Docker publish
-
-on:
- workflow_call:
- inputs:
- version:
- type: string
- required: true
- dh-repository-owner:
- type: string
- required: true
- push-latest:
- type: string
- required: true
-
-jobs:
- publish:
- name: Tag and publish ${{ matrix.target }}
- runs-on: ubuntu-22.04
- strategy:
- fail-fast: false
- matrix:
- include:
- - target: lightningd
- tag_suffix: ''
- - target: lightningd-vls-signer
- tag_suffix: '-vls'
- steps:
- - name: Setup Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: Log in to Docker Hub
- uses: docker/login-action@v4
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
-
- - name: Download platform digests for this target
- uses: actions/download-artifact@v8
- with:
- pattern: digest_${{ matrix.target }}_*
- path: /tmp/digests
- merge-multiple: false
-
- - name: Set up values
- env:
- DH_REPOSITORY_OWNER: ${{ inputs.dh-repository-owner }}
- PUSH_LATEST: ${{ inputs.push-latest }}
- VERSION: ${{ inputs.version }}
- REF_TYPE: ${{ github.ref_type }}
- run: |
- DIGEST_REFS=""
- for f in /tmp/digests/*/digest.txt; do
- D=$(cat "$f")
- DIGEST_REFS="$DIGEST_REFS ${DH_REPOSITORY_OWNER}/lightningd@${D}"
- done
- echo "DIGEST_REFS=$DIGEST_REFS" >> $GITHUB_ENV
-
- if [[ "$PUSH_LATEST" == "true" ]] ||
- ([[ "$REF_TYPE" == "tag" ]] && [[ ! "$VERSION" =~ rc ]]); then
- echo "PUSHLATEST=true" >> $GITHUB_ENV
- else
- echo "PUSHLATEST=false" >> $GITHUB_ENV
- fi
-
- - name: Create and push real tag(s)
- env:
- DH_REPOSITORY_OWNER: ${{ inputs.dh-repository-owner }}
- VERSION: ${{ inputs.version }}
- TAG_SUFFIX: ${{ matrix.tag_suffix }}
- run: |
- TAG_ARGS=(-t "${DH_REPOSITORY_OWNER}/lightningd:${VERSION}${TAG_SUFFIX}")
- if [[ "$PUSHLATEST" == "true" ]]; then
- TAG_ARGS+=(-t "${DH_REPOSITORY_OWNER}/lightningd:latest${TAG_SUFFIX}")
- fi
- docker buildx imagetools create "${TAG_ARGS[@]}" $DIGEST_REFS
diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml
deleted file mode 100644
index 57102c5c3177..000000000000
--- a/.github/workflows/release-build.yml
+++ /dev/null
@@ -1,106 +0,0 @@
-name: Release binaries build
-
-on:
- workflow_call:
- inputs:
- version:
- type: string
- required: true
- skip_validation:
- type: boolean
- required: true
-
-jobs:
- releases:
- name: Releases
- runs-on: ${{ matrix.runner }}
- strategy:
- fail-fast: false
- matrix:
- # dir is where build-release.sh puts the target's output; arch picks
- # the merged artifact, since each architecture is checksummed and
- # signed separately.
- include:
- - { target: 'bin-Fedora', runner: 'ubuntu-24.04', arch: 'amd64', dir: 'release' }
- - { target: 'bin-Ubuntu-jammy', runner: 'ubuntu-24.04', arch: 'amd64', dir: 'release' }
- - { target: 'bin-Ubuntu-noble', runner: 'ubuntu-24.04', arch: 'amd64', dir: 'release' }
- - { target: 'bin-Ubuntu-resolute', runner: 'ubuntu-24.04', arch: 'amd64', dir: 'release' }
- # arm64 builds natively on an arm64 runner.
- - { target: 'bin-Ubuntu-jammy-arm64', runner: 'ubuntu-24.04-arm', arch: 'arm64', dir: 'release-arm64' }
- - { target: 'bin-Ubuntu-noble-arm64', runner: 'ubuntu-24.04-arm', arch: 'arm64', dir: 'release-arm64' }
- - { target: 'bin-Ubuntu-resolute-arm64', runner: 'ubuntu-24.04-arm', arch: 'arm64', dir: 'release-arm64' }
- # armv7 cross-compiles in the amd64 builder image (see
- # tools/repro-build.armv7.sh), with qemu for the few armv7 programs
- # the build runs.
- - { target: 'bin-Ubuntu-jammy-armv7', runner: 'ubuntu-24.04', arch: 'armv7', dir: 'release-armv7' }
- - { target: 'bin-Ubuntu-noble-armv7', runner: 'ubuntu-24.04', arch: 'armv7', dir: 'release-armv7' }
- - { target: 'bin-Ubuntu-resolute-armv7', runner: 'ubuntu-24.04', arch: 'armv7', dir: 'release-armv7' }
- steps:
- - name: Git checkout
- uses: actions/checkout@v7
- with:
- fetch-depth: 0
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v4
- with:
- platforms: arm
- if: endsWith(matrix.target, '-armv7')
-
- - name: Build environment setup
- run: |
- distribution=$(echo ${{ matrix.target }} | cut -d'-' -f3)
- # Same naming as contrib/cl-repro.sh: arm64 images are suffixed.
- suffix=""
- [ "$(dpkg --print-architecture)" = arm64 ] && suffix="-arm64"
- sudo docker run --rm -v $(pwd):/build ubuntu:${distribution} bash -c "\
- apt-get update && \
- apt-get install -y debootstrap && \
- debootstrap ${distribution} /build/${distribution}"
- sudo tar -C ${distribution} -c . | docker import - ${distribution}
- docker build -t cl-repro-${distribution}${suffix} - < contrib/reprobuild/Dockerfile.${distribution}
- if: contains(matrix.target, 'Ubuntu')
-
- - name: Build release
- env:
- SKIP_VALIDATION: ${{ inputs.skip_validation }}
- INPUT_VERSION: ${{ inputs.version }}
- run: |
- if [[ "$SKIP_VALIDATION" == "true" ]]; then
- tools/build-release.sh ${{ matrix.target }} --force-version "$INPUT_VERSION" --force-unclean --force-mtime "$(date +%Y-%m-%d)"
- else
- tools/build-release.sh ${{ matrix.target }}
- fi
-
- - name: Upload target artifacts
- uses: actions/upload-artifact@v7
- with:
- path: ${{ matrix.dir }}/
- name: ${{ matrix.arch }}-${{ matrix.target }}
- if-no-files-found: error
-
- artifact:
- name: Construct release artifact
- needs: releases
- runs-on: ubuntu-24.04
- steps:
- - name: Merge amd64 artifacts
- uses: actions/upload-artifact/merge@v7
- with:
- name: c-lightning-${{ inputs.version }}
- pattern: amd64-bin-*
- delete-merged: true
-
- - name: Merge arm64 artifacts
- uses: actions/upload-artifact/merge@v7
- with:
- name: c-lightning-${{ inputs.version }}-arm64
- pattern: arm64-bin-*
- delete-merged: true
-
- - name: Merge armv7 artifacts
- uses: actions/upload-artifact/merge@v7
- with:
- name: c-lightning-${{ inputs.version }}-armv7
- pattern: armv7-bin-*
- delete-merged: true
diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml
deleted file mode 100644
index 1e8aa44d4fbd..000000000000
--- a/.github/workflows/release-publish.yml
+++ /dev/null
@@ -1,117 +0,0 @@
-name: Release publish
-
-on:
- workflow_call:
- inputs:
- version:
- type: string
- required: true
- create_release:
- type: boolean
- required: true
-
-jobs:
- release:
- name: Sign and prepare release draft
- runs-on: ubuntu-24.04
- steps:
- - name: Git checkout
- uses: actions/checkout@v7
- with:
- fetch-depth: 0
-
- - name: Download artifact
- uses: actions/download-artifact@v8
- with:
- name: c-lightning-${{ inputs.version }}
- path: release/
-
- - name: Download arm64 artifact
- uses: actions/download-artifact@v8
- with:
- name: c-lightning-${{ inputs.version }}-arm64
- path: release-arm64/
-
- - name: Download armv7 artifact
- uses: actions/download-artifact@v8
- with:
- name: c-lightning-${{ inputs.version }}-armv7
- path: release-armv7/
-
- - name: Import GPG keys
- id: gpg
- uses: crazy-max/ghaction-import-gpg@v7
- with:
- gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- passphrase: ${{ secrets.GPG_PASSPHRASE }}
- trust_level: 5
-
- - name: Set default GPG key
- env:
- GPG_KEYID: ${{ steps.gpg.outputs.keyid }}
- run: echo "default-key $GPG_KEYID" >> ~/.gnupg/gpg.conf
-
- - name: Sign release
- env:
- INPUT_VERSION: ${{ inputs.version }}
- run: |
- tools/build-release.sh --without-zip sign
- for arch in arm64 armv7; do
- tools/sign-release-arm.sh "$INPUT_VERSION" "$arch"
- # Their manifests and signatures sit next to the amd64 ones.
- mv release-"$arch"/SHA256SUMS-* release/
- done
-
- - name: Upload signed artifact
- uses: actions/upload-artifact@v7
- with:
- name: c-lightning-${{ inputs.version }}
- overwrite: true
- path: release/
-
- - name: Upload arm64 artifact
- uses: actions/upload-artifact@v7
- with:
- name: c-lightning-${{ inputs.version }}-arm64
- overwrite: true
- path: release-arm64/
-
- - name: Upload armv7 artifact
- uses: actions/upload-artifact@v7
- with:
- name: c-lightning-${{ inputs.version }}-armv7
- overwrite: true
- path: release-armv7/
-
- - name: Determine release data
- id: release_data
- env:
- INPUT_VERSION: ${{ inputs.version }}
- run: |
- VERSION="$INPUT_VERSION"
- CHANGELOG_VERSION=${VERSION#v}
- CHANGELOG_TITLE=$(grep "## \[${CHANGELOG_VERSION}\]" CHANGELOG.md)
- RELEASE_TITLE=$(echo $CHANGELOG_TITLE | cut -d'"' -f2)
- echo "release_title=$RELEASE_TITLE" >> "$GITHUB_OUTPUT"
-
- # Never replace what is already on the release: release captains add
- # their signatures to the .asc files by hand, and a re-run must keep
- # them. tools/publish-release-assets.sh uploads only missing files,
- # refuses any that differ from the published copy, and appends our
- # signature to an existing .asc instead of overwriting it.
- - name: Prepare release draft
- if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.create_release) }}
- env:
- GH_TOKEN: ${{ github.token }}
- INPUT_VERSION: ${{ inputs.version }}
- RELEASE_TITLE: ${{ steps.release_data.outputs.release_title }}
- run: |
- if ! gh release view "$INPUT_VERSION" >/dev/null 2>&1; then
- PRERELEASE=""
- case "$INPUT_VERSION" in *-rc*) PRERELEASE=--prerelease;; esac
- # --target only matters for an untagged test run: gh then
- # creates the tag, as the previous upload action did.
- gh release create "$INPUT_VERSION" --draft --target "$GITHUB_SHA" $PRERELEASE \
- --title "$INPUT_VERSION $RELEASE_TITLE" --notes ""
- fi
- tools/publish-release-assets.sh "$INPUT_VERSION" release/* release-arm64/* release-armv7/*
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7bb09de679b8..8b7bfa7282a0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,5 +1,21 @@
---
# https://docs.corelightning.org/docs/release-checklist
+#
+# The release *binaries* are no longer built or signed here: they are produced
+# and signed locally by `tools/reprobuild`, from one static build per
+# architecture, and published from the release captain's machine. The jobs that
+# built the old per-distribution tarballs, drafted the release and signed it
+# with the project key are gone with the scripts they called.
+#
+# The Docker images are gone from here too. They are built locally by
+# `tools/reprobuild docker` -- a Dockerfile over the digest-pinned
+# debian:trixie-slim, consuming the static tarball that was just signed, so the
+# image compiles nothing -- and pushed by `tools/reprobuild publish` with
+# `skopeo copy --all --preserve-digests`, which is what makes the digests users
+# pull the digests the release manifests signed. `latest` is a deliberate
+# `--latest` flag, never applied automatically and never to an rc.
+#
+# What is left here is the tag check and PyPI.
name: "Release 🚀"
on:
push:
@@ -17,20 +33,6 @@ on:
description: Skip release validation for untagged commit testing
default: false
type: boolean
- create_release:
- description: Create a draft release
- default: false
- type: boolean
- dh-repository-owner:
- description: 'Dockerhub repository owner'
- default: 'elementsproject'
- platforms-to-build:
- description: 'List of platforms to build'
- default: 'linux/amd64,linux/arm64,linux/arm/v7'
- push-latest:
- description: 'Push the latest Docker tag'
- type: boolean
- default: false
dist-location:
description: 'PyPI distribution location'
type: choice
@@ -48,16 +50,6 @@ jobs:
skip_validation: ${{ github.event.inputs.skip_validation == 'true' }}
- docker-build:
- name: Docker build
- needs: check-version
- uses: ./.github/workflows/docker-build.yml
- with:
- version: ${{ needs.check-version.outputs.version }}
- dh-repository-owner: ${{ github.event.inputs.dh-repository-owner || 'elementsproject' }}
- platforms-to-build: ${{ github.event.inputs.platforms-to-build || 'linux/amd64,linux/arm64,linux/arm/v7' }}
- secrets: inherit
-
pypi-build:
name: PyPI build
needs: check-version
@@ -66,46 +58,12 @@ jobs:
version: ${{ needs.check-version.outputs.version }}
secrets: inherit
- release-build:
- name: Release binaries build
- needs: check-version
- uses: ./.github/workflows/release-build.yml
- with:
- version: ${{ needs.check-version.outputs.version }}
- skip_validation: ${{ github.event.inputs.skip_validation == 'true' }}
- secrets: inherit
-
- gate:
- name: All builds succeeded
- needs: [docker-build, pypi-build, release-build]
- runs-on: ubuntu-24.04
- steps:
- - run: echo "All three build paths succeeded — proceeding to publish."
-
- docker-publish:
- name: Docker publish
- needs: [check-version, gate]
- uses: ./.github/workflows/docker-publish.yml
- with:
- version: ${{ needs.check-version.outputs.version }}
- dh-repository-owner: ${{ github.event.inputs.dh-repository-owner || 'elementsproject' }}
- push-latest: ${{ github.event.inputs.push-latest }}
- secrets: inherit
-
pypi-publish:
name: PyPI publish
- needs: [check-version, gate]
+ needs: [check-version, pypi-build]
uses: ./.github/workflows/pypi-publish.yml
with:
version: ${{ needs.check-version.outputs.version }}
dist-location: ${{ github.event.inputs.dist-location }}
secrets: inherit
- release-publish:
- name: Release sign + draft
- needs: [check-version, gate]
- uses: ./.github/workflows/release-publish.yml
- with:
- version: ${{ needs.check-version.outputs.version }}
- create_release: ${{ github.event.inputs.create_release == 'true' }}
- secrets: inherit
diff --git a/.github/workflows/repro.yml b/.github/workflows/repro.yml
deleted file mode 100644
index ee4913c293d3..000000000000
--- a/.github/workflows/repro.yml
+++ /dev/null
@@ -1,114 +0,0 @@
----
-# https://docs.corelightning.org/docs/repro
-name: Repro Build Nightly
-on:
- # 05:00 Berlin, 03:00 UTC, 23:00 New York, 20:00 Los Angeles
- schedule:
- - cron: "0 3 * * *"
- workflow_dispatch:
-
-jobs:
- ubuntu:
- name: "Ubuntu repro build: ${{ matrix.version }}"
- runs-on: ubuntu-22.04
- strategy:
- fail-fast: false # Let each build finish.
- matrix:
- version: ['jammy', 'noble', 'resolute']
- steps:
- - name: Git checkout
- uses: actions/checkout@v7
-
- - name: Build environment setup - ${{ matrix.version }}
- run: |
- echo "Building base image for ${{ matrix.version }}"
- echo "STEP=Build environment setup" >> "$GITHUB_ENV"
- sudo docker run --rm -v $(pwd):/build ubuntu:${{ matrix.version }} bash -c "\
- apt-get update && \
- apt-get install -y debootstrap && \
- debootstrap ${{ matrix.version }} /build/${{ matrix.version }}"
- sudo tar -C ${{ matrix.version }} -c . | docker import - ${{ matrix.version }}
-
- - name: Builder image setup - ${{ matrix.version }}
- run: |
- echo "STEP=Builder image setup" >> "$GITHUB_ENV"
- docker build -t cl-repro-${{ matrix.version }} - < contrib/reprobuild/Dockerfile.${{ matrix.version }}
-
- - name: Build reproducible image and store Git state - ${{ matrix.version }}
- run: |
- echo "STEP=Build reproducible image and store Git state" >> "$GITHUB_ENV"
-
- # Create release directory.
- mkdir $GITHUB_WORKSPACE/release
-
- # Perform the repro build.
- docker run --name cl-build -v $GITHUB_WORKSPACE:/repo -e FORCE_MTIME=$(date +%F) -t cl-repro-${{ matrix.version }}
-
- # Commit the image in order to inspect the build later.
- docker commit cl-build cl-repro
-
- # Inspect the version.
- docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "make version > /repo/release/version.txt"
-
- # Inspect the Git tree state.
- docker run --rm -v $GITHUB_WORKSPACE:/repo -t cl-repro bash -c "\
- git --no-pager status > /repo/release/git.log && \
- git --no-pager diff >> /repo/release/git.log"
-
- # Change permissions on the release files for access by the runner environment.
- sudo chown -R runner $GITHUB_WORKSPACE/release
-
- - name: Assert clean version - ${{ matrix.version }}
- run: |
- echo "STEP=Assert clean version" >> "$GITHUB_ENV"
- echo 'Version:'
- cat release/version.txt
- echo -e
-
- releasefile=$(ls release/clightning-*)
- echo 'Release file:'
- ls -al release/clightning-*
- echo -e
- if [ -n "$(cat release/version.txt | sed -n '/-modded/p')" ] || \
- [ -n "$(echo $releasefile | sed -n '/-modded/p')" ]; then
- echo "Git Status and Diff:"
- cat release/git.log
- echo -e
- echo 'Error: release modded / dirty tree.'
- exit 1
- else
- echo 'Success! Clean release.'
- fi
-
- - name: Upload release artifact - ${{ matrix.version }}
- uses: actions/upload-artifact@v7
- with:
- name: release-${{ matrix.version }}
- path: release
- retention-days: 3 # Automatically delete after 3 days
-
- - name: Send email on failure
- if: ${{ failure() }}
- uses: dawidd6/action-send-mail@v23
- with:
- server_address: smtp.gmail.com
- server_port: 465
- secure: true
- username: ${{ secrets.EMAIL_USERNAME }}
- password: ${{ secrets.EMAIL_PASSWORD }}
- from: ${{ secrets.EMAIL_USERNAME }}
- to: ${{ vars.DISTRIBUTION_LIST }}
- subject: "CI Failure: Step ${{ env.STEP }} failed for distro ${{ matrix.version }}"
- convert_markdown: true
- html_body: |
-
-
- GitHub Workflow ${{ github.workflow }} Failed! For more details, click on the action below.
- Failure Details:
- Event: ${{ github.event_name }}
- Job: ${{ github.job }}
- Distro: ${{ matrix.version }}
- Step: ${{ env.STEP }}
- Action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
-
-
diff --git a/Dockerfile b/Dockerfile
index b6285d8bc6a2..3d4b19b9b560 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,287 +1,82 @@
-# syntax=docker/dockerfile:1.7-labs
-
-FROM --platform=${BUILDPLATFORM} debian:bookworm-slim AS base-host
-
-SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
-
-FROM --platform=${TARGETPLATFORM} debian:bookworm-slim AS base-target
-
-SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
-
-FROM base-host AS downloader-linux-amd64
-
-ARG target_arch=x86_64-linux-gnu
-
-FROM base-host AS downloader-linux-arm64
-
-ARG target_arch=aarch64-linux-gnu
-
-FROM base-host AS downloader-linux-arm
-
-ARG target_arch=arm-linux-gnueabihf
-
-FROM downloader-${TARGETOS}-${TARGETARCH} AS downloader
-
-RUN apt-get update && \
- apt-get install -qq -y --no-install-recommends \
- gnupg
-
-ARG BITCOIN_VERSION=27.1
-ARG BITCOIN_URL=https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}
-ARG BITCOIN_TARBALL=bitcoin-${BITCOIN_VERSION}-${target_arch}.tar.gz
-
-WORKDIR /opt/bitcoin
-
-ADD ${BITCOIN_URL}/${BITCOIN_TARBALL} .
-ADD ${BITCOIN_URL}/SHA256SUMS .
-ADD ${BITCOIN_URL}/SHA256SUMS.asc .
-COPY contrib/keys/bitcoin/ gpg/
-
-RUN gpg --quiet --import gpg/* && \
- gpg --verify SHA256SUMS.asc SHA256SUMS && \
- sha256sum -c SHA256SUMS --ignore-missing
-
-RUN tar xzf ${BITCOIN_TARBALL} --strip-components=1
-
-FROM base-host AS base-builder
-
-RUN apt-get update && \
- apt-get install -qq -y --no-install-recommends \
- build-essential \
- ca-certificates \
- wget \
- git \
- autoconf \
- automake \
- bison \
- flex \
- jq \
- libtool \
- gettext
-
-WORKDIR /opt
-
-ADD --chmod=750 https://astral.sh/uv/install.sh install-uv.sh
-ADD --chmod=750 https://sh.rustup.rs install-rust.sh
-
-WORKDIR /opt/lightningd
-
-COPY --exclude=.git/ . .
-
-FROM base-builder AS base-builder-linux-amd64
-
-ARG target_arch=x86_64-linux-gnu
-ARG target_arch_gcc=x86-64-linux-gnu
-ARG target_arch_dpkg=amd64
-ARG target_arch_rust=x86_64-unknown-linux-gnu
-ARG COPTFLAGS="-O2 -march=x86-64"
-
-FROM base-builder AS base-builder-linux-arm64
-
-ARG target_arch=aarch64-linux-gnu
-ARG target_arch_gcc=aarch64-linux-gnu
-ARG target_arch_dpkg=arm64
-ARG target_arch_rust=aarch64-unknown-linux-gnu
-ARG COPTFLAGS="-O2 -march=armv8-a"
-
-FROM base-builder AS base-builder-linux-arm
-
-ARG target_arch=arm-linux-gnueabihf
-ARG target_arch_gcc=arm-linux-gnueabihf
-ARG target_arch_dpkg=armhf
-ARG target_arch_rust=armv7-unknown-linux-gnueabihf
-ARG COPTFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
-
-FROM base-builder-${TARGETOS}-${TARGETARCH} AS builder
-
-ENV LIGHTNINGD_VERSION=master
-
-RUN dpkg --add-architecture ${target_arch_dpkg}
-
-# Install architecture-independent libraries
-RUN apt-get update && \
- apt-get install -qq -y --no-install-recommends \
- python3-dev \
- lowdown
-
-# Install target-arch libraries
-RUN apt-get install -qq -y --no-install-recommends \
- pkg-config:${target_arch_dpkg} \
- libffi-dev:${target_arch_dpkg} \
- libicu-dev:${target_arch_dpkg} \
- zlib1g-dev:${target_arch_dpkg} \
- libsqlite3-dev:${target_arch_dpkg} \
- libpq-dev:${target_arch_dpkg} \
- libsodium-dev:${target_arch_dpkg} \
- crossbuild-essential-${target_arch_dpkg}
-
-ARG AR=${target_arch}-ar
-ARG AS=${target_arch}-as
-ARG CC=${target_arch}-gcc
-ARG CXX=${target_arch}-g++
-ARG LD=${target_arch}-ld
-ARG STRIP=${target_arch}-strip
-ARG TARGET=${target_arch_rust}
-ARG RUST_PROFILE=release
-ARG VERSION
-ENV VERSION=${VERSION}
-
-#TODO: set all the following cargo config options via env variables (https://doc.rust-lang.org/cargo/reference/environment-variables.html)
-RUN mkdir -p .cargo && tee .cargo/config.toml </bin/bitcoin-cli, pre-verified by `tools/reprobuild fetch`
+# vls remote_hsmd_socket-${VLS_VERSION}-{amd64,arm64,armhf}
+#
+# and the build args VERSION, VLS_VERSION, SOURCE_DATE_EPOCH, CREATED, REVISION.
+# The main context only supplies tools/docker-entrypoint.sh (see .dockerignore).
+
+# Base pinned by index digest; bumped deliberately, like a package pin.
+FROM debian:trixie-slim@sha256:d7e12182ce18b85b93007c1dedf31f2d29e01ccf3182cc4017c709b6259bc132 AS base
+
+# --- arch selector: Docker's TARGETARCH -> the matrix's arch token and the
+# Bitcoin Core release triplet. ARGs propagate to the derived stages.
+FROM base AS arch-linux-amd64
+ARG cl_arch=amd64
+ARG bitcoin_triplet=x86_64-linux-gnu
+
+FROM base AS arch-linux-arm64
+ARG cl_arch=arm64
+ARG bitcoin_triplet=aarch64-linux-gnu
+
+FROM base AS arch-linux-arm
+ARG cl_arch=armhf
+ARG bitcoin_triplet=arm-linux-gnueabihf
+
+# --- lightningd: the published image
+FROM arch-${TARGETOS}-${TARGETARCH} AS lightningd
ARG VERSION
-ARG VLS_VERSION=v0.14.0
-
-# Install cross-compilation toolchain (same as builder stage)
-RUN dpkg --add-architecture ${target_arch_dpkg}
+ARG CREATED
+ARG REVISION
+# The one unpinned, network-touching input: the entrypoint's
+# runtime deps plus xz-utils (trixie-slim has no xz, the tarball needs it).
+# Everything apt leaves behind that is not package content is
+# removed so the layer depends on the package set only.
RUN apt-get update && \
- apt-get install -qq -y --no-install-recommends \
- protobuf-compiler \
- pkg-config:${target_arch_dpkg} \
- crossbuild-essential-${target_arch_dpkg} && \
+ apt-get install -y --no-install-recommends bash inotify-tools socat jq xz-utils && \
apt-get clean && \
- rm -rf /var/lib/apt/lists/*
-
-ENV PATH="/root/.cargo/bin:/root/.local/bin:${PATH}"
-ENV PKG_CONFIG_PATH=/usr/lib/${target_arch}/pkgconfig
-ENV PKG_CONFIG_LIBDIR=/usr/lib/${target_arch}/pkgconfig
-
-WORKDIR /opt
-
-RUN ./install-uv.sh -q
-RUN ./install-rust.sh -y -q --profile minimal --component rustfmt --target ${target_arch_rust}
-
-RUN git clone --depth 1 --branch ${VLS_VERSION} https://gitlab.com/lightning-signer/validating-lightning-signer.git
-WORKDIR /opt/validating-lightning-signer
-
-RUN mkdir -p .cargo && tee .cargo/config.toml < $TMPCFILE
+ # Needs a main(). Without one the link fails -- "undefined reference to
+ # `main'" -- on every platform, not just a fully static one against musl's
+ # crt1.o, so the probe answered "no" however capable the toolchain was.
+ echo "int foo(void); int foo(void) { return 0; } int main(void) { return foo(); }" > $TMPCFILE
# We *want* this to fail if we get a warning, hence use -Werror.
$1 $2 -Werror -ffunction-sections -Wl,--gc-sections $TMPCFILE -o $TMPOBJFILE
}
@@ -258,7 +276,10 @@ usage()
echo " Note: On macOS, -g is used instead of -g3 for libbacktrace compatibility"
fi
usage_with_default "CONFIGURATOR_CC" "${CONFIGURATOR_CC:-$CC}"
- echo " To override compile line for configurator itself"
+ echo " To override compile line for configurator itself (it runs on"
+ echo " the build machine, so set it to a native compiler when cross-compiling)"
+ usage_with_default "CONFIGURATOR_WRAPPER" "$CONFIGURATOR_WRAPPER"
+ echo " Command prefix to run configurator's test programs, e.g. qemu-aarch64-static -L /"
usage_with_default "PYTEST" "$PYTEST"
usage_with_default "VALGRIND" "$VALGRIND"
usage_with_default "SED" "$SED"
@@ -324,6 +345,7 @@ for opt in "$@"; do
;;
CC=*) CC="${opt#CC=}";;
CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";;
+ CONFIGURATOR_WRAPPER=*) CONFIGURATOR_WRAPPER="${opt#CONFIGURATOR_WRAPPER=}";;
CWARNFLAGS=*) CWARNFLAGS="${opt#CWARNFLAGS=}";;
CDEBUGFLAGS=*) CDEBUGFLAGS="${opt#CDEBUGFLAGS=}";;
COPTFLAGS=*) COPTFLAGS="${opt#COPTFLAGS=}";;
@@ -400,8 +422,11 @@ else
fi
# We assume warning flags don't affect congfigurator that much!
+# The configurator itself runs here, on the build machine, so it is compiled
+# with CONFIGURATOR_CC (defaults to CC; a native compiler when cross-compiling).
+# Its test programs are compiled with CC and run via CONFIGURATOR_WRAPPER.
echo -n "Compiling $CONFIGURATOR..."
-$CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS $LDFLAGS -o $CONFIGURATOR $CONFIGURATOR.c
+$CONFIGURATOR_CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS $LDFLAGS -o $CONFIGURATOR $CONFIGURATOR.c
echo "done"
if [ "$CLANG_COVERAGE" = "1" ]; then
@@ -441,11 +466,20 @@ if command -v "${PKG_CONFIG}" >/dev/null; then
SODIUM_LDLIBS="$("${PKG_CONFIG}" --silence-errors --libs libsodium || :)"
fi
-POSTGRES_INCLUDE=""
-POSTGRES_LDLIBS=""
+# Anything that did not come from the environment is re-probed, exactly as a
+# first run would: see POSTGRES_*_FROM_ENV above.
+[ -n "$POSTGRES_LDLIBS_FROM_ENV" ] || unset POSTGRES_LDLIBS
+[ -n "$POSTGRES_INCLUDE_FROM_ENV" ] || unset POSTGRES_INCLUDE
if command -v "${PG_CONFIG}" >/dev/null; then
- POSTGRES_INCLUDE="-I$("${PG_CONFIG}" --includedir)"
- POSTGRES_LDLIBS="-L$("${PG_CONFIG}" --libdir) -lpq"
+ : ${POSTGRES_INCLUDE="-I$("${PG_CONFIG}" --includedir)"}
+ : ${POSTGRES_LDLIBS="-L$("${PG_CONFIG}" --libdir) -lpq"}
+else
+ # No pg_config, but the environment may still say how to reach libpq --
+ # which is how a static or cross build states it (the comment above).
+ # Assigning here unconditionally would throw that answer away and
+ # silently drop PostgreSQL support, so default rather than assign.
+ : ${POSTGRES_INCLUDE=}
+ : ${POSTGRES_LDLIBS=}
fi
# Clean up on exit.
@@ -455,7 +489,7 @@ CONFIGURATOR_PATH_FLAGS=
[ -z "$CPATH" ] || CONFIGURATOR_PATH_FLAGS="$CONFIGURATOR_PATH_FLAGS -I$CPATH"
[ -z "$LIBRARY_PATH" ] || CONFIGURATOR_PATH_FLAGS="$CONFIGURATOR_PATH_FLAGS -L$LIBRARY_PATH"
-$CONFIGURATOR --extra-tests --autotools-style --var-file=$CONFIG_VAR_FILE.$$ --header-file=$CONFIG_HEADER.$$ --configurator-cc="$CONFIGURATOR_CC" --wrapper="$CONFIGURATOR_WRAPPER" "$CC" ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS $CSANFLAGS $CONFIGURATOR_PATH_FLAGS $SQLITE3_CFLAGS $SODIUM_CFLAGS $POSTGRES_INCLUDE <-arm64 targets resolve. amd64 keeps its bare name.
- SUFFIX=""
- [ "$(dpkg --print-architecture)" = arm64 ] && SUFFIX="-arm64"
- # shellcheck disable=SC2024
- sudo docker build --no-cache -t cl-repro-$v$SUFFIX - < "$LIGHTNING_DIR"/contrib/reprobuild/Dockerfile.$v
-done
diff --git a/contrib/docker/Dockerfile.builder.fedora b/contrib/docker/Dockerfile.builder.fedora
deleted file mode 100644
index 3a51e0f33e29..000000000000
--- a/contrib/docker/Dockerfile.builder.fedora
+++ /dev/null
@@ -1,63 +0,0 @@
-FROM fedora:40
-
-ENV UV_PYTHON=3.12
-ENV BITCOIN_VERSION=27.1
-ENV SOURCE_DATE_EPOCH=1672531200
-ENV RUSTFLAGS="-C link-arg=-Wl,--build-id=none"
-
-WORKDIR /tmp
-
-RUN dnf update -y && \
- dnf groupinstall -y \
- 'C Development Tools and Libraries' \
- 'Development Tools' && \
- dnf install -y \
- clang \
- libsq3-devel \
- redhat-lsb \
- net-tools \
- valgrind \
- wget \
- git \
- jq \
- xz \
- zlib-devel \
- libsodium-devel \
- which \
- sed \
- gettext-devel \
- gmp-devel \
- python3-devel \
- python3-pip \
- python3-poetry \
- postgresql-devel && \
- dnf clean all
-
-# Install Rust via rustup (for lockfile v4 support)
-RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.92.0
-ENV PATH="/root/.cargo/bin:${PATH}"
-
-# Install lowdown
-RUN wget https://github.com/kristapsdz/lowdown/archive/refs/tags/VERSION_1_0_2.tar.gz && \
- tar -xzf VERSION_1_0_2.tar.gz && \
- cd lowdown-VERSION_1_0_2 && \
- ./configure && \
- make && \
- make install && \
- ldconfig && \
- cd /tmp && \
- rm -rf VERSION_1_0_2.tar.gz lowdown-VERSION_1_0_2
-
-# Install Bitcoin Core
-RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz \
- -O bitcoin.tar.gz && \
- tar -xvzf bitcoin.tar.gz && \
- mv bitcoin-$BITCOIN_VERSION/bin/bitcoin* /usr/local/bin/ && \
- mv bitcoin-$BITCOIN_VERSION/lib/* /usr/local/lib/ && \
- mv bitcoin-$BITCOIN_VERSION/include/* /usr/local/include/ && \
- mv bitcoin-$BITCOIN_VERSION/share/man/man1/* /usr/share/man/man1 && \
- rm -rf bitcoin.tar.gz bitcoin-$BITCOIN_VERSION
-
-# Install uv
-ENV PATH="${PATH}:/root/.local/bin"
-RUN wget -qO- https://astral.sh/uv/install.sh | sh
diff --git a/contrib/reprobuild/Dockerfile.jammy b/contrib/reprobuild/Dockerfile.jammy
deleted file mode 100644
index e8c1c8a6356e..000000000000
--- a/contrib/reprobuild/Dockerfile.jammy
+++ /dev/null
@@ -1,87 +0,0 @@
-FROM jammy
-
-ENV TZ=UTC
-RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
-ENV SOURCE_DATE_EPOCH=1672531200
-ENV RUST_PROFILE=release
-ENV PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.cargo/bin:/root/.local/bin:$PATH
-
-RUN sed -i '/updates/d' /etc/apt/sources.list && \
- sed -i '/security/d' /etc/apt/sources.list
-
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- autoconf \
- automake \
- build-essential \
- ca-certificates \
- file \
- gettext \
- git \
- libsqlite3-dev \
- libpq-dev \
- libsodium23 \
- libsodium-dev \
- libtool \
- m4 \
- sudo \
- unzip \
- wget \
- jq \
- zip \
- && cd /tmp \
- && wget https://github.com/kristapsdz/lowdown/archive/refs/tags/VERSION_1_0_2.tar.gz \
- && tar -xzf VERSION_1_0_2.tar.gz \
- && cd lowdown-VERSION_1_0_2 \
- && ./configure \
- && make \
- && make install \
- && ldconfig \
- && cd / \
- && rm -rf /tmp/VERSION_1_0_2.tar.gz /tmp/lowdown-VERSION_1_0_2
-
-# Ensure correct ownership
-RUN chown root:root /etc/sudoers
-RUN chown root:root /etc/sudo.conf
-RUN chown root:root /usr/libexec/sudo/sudoers.so
-
-# Install Python3.10 (more reproducible than relying on python3-setuptools)
-RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv && \
- apt-get install -y --no-install-recommends \
- libbz2-dev \
- libffi-dev \
- libreadline-dev \
- libsqlite3-dev \
- libssl-dev \
- zlib1g-dev && \
- pyenv install 3.10.0 && \
- pyenv global 3.10.0
-
-RUN wget -qO- https://astral.sh/uv/install.sh | sh
-
-RUN wget https://sh.rustup.rs -O rustup-install.sh && \
- bash rustup-install.sh --default-toolchain none --quiet -y && \
- rm rustup-install.sh && \
- /root/.cargo/bin/rustup install 1.85
-
-RUN mkdir /build
-WORKDIR /build
-
-# We mount the repo into `/repo` and then we take a snapshot of it
-# first by cloning it. This ensures we're not including any
-# uncommitted changes in the working directory on the host. Notice
-# that we no longer take the zipfile.
-CMD git clone /repo . \
- && uv sync --all-extras --all-groups \
- && if [ "$REPRO_ARCH" = armv7 ]; then \
- uv run tools/repro-build.armv7.sh \
- && mkdir -p /repo/release-armv7 \
- && cp *.xz /repo/release-armv7/; \
- elif [ "$(dpkg --print-architecture)" = arm64 ]; then \
- uv run tools/repro-build.arm64.sh \
- && mkdir -p /repo/release-arm64 \
- && cp *.xz /repo/release-arm64/; \
- else \
- uv run tools/repro-build.sh \
- && cp *.xz /repo/release/; \
- fi
diff --git a/contrib/reprobuild/Dockerfile.noble b/contrib/reprobuild/Dockerfile.noble
deleted file mode 100644
index f7a1d3a4b55f..000000000000
--- a/contrib/reprobuild/Dockerfile.noble
+++ /dev/null
@@ -1,77 +0,0 @@
-FROM noble
-
-ENV TZ=UTC
-RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
-ENV SOURCE_DATE_EPOCH=1672531200
-ENV RUST_PROFILE=release
-ENV PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.cargo/bin:/root/.local/bin:$PATH
-
-RUN sed -i '/updates/d' /etc/apt/sources.list && \
- sed -i '/security/d' /etc/apt/sources.list && \
- sed -i 's/^deb \(.*\) noble main$/deb \1 noble main universe/' /etc/apt/sources.list
-
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- autoconf \
- automake \
- build-essential \
- ca-certificates \
- file \
- gettext \
- git \
- curl \
- libsqlite3-dev \
- libpq-dev \
- libsodium23 \
- libsodium-dev \
- lowdown \
- libtool \
- m4 \
- sudo \
- unzip \
- wget \
- jq \
- zip
-
-# Configure /repo/.git as 'safe.directory'
-RUN git config --global --add safe.directory /repo/.git
-
-# Install Python3.10 (more reproducible than relying on python3-setuptools)
-RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv && \
- apt-get install -y --no-install-recommends \
- libbz2-dev \
- libffi-dev \
- libreadline-dev \
- libssl-dev \
- zlib1g-dev && \
- pyenv install 3.10.0 && \
- pyenv global 3.10.0
-
-RUN wget -qO- https://astral.sh/uv/install.sh | sh
-
-RUN wget https://sh.rustup.rs -O rustup-install.sh && \
- bash rustup-install.sh --default-toolchain none --quiet -y && \
- rm rustup-install.sh && \
- /root/.cargo/bin/rustup install 1.85
-
-RUN mkdir /build
-WORKDIR /build
-
-# We mount the repo into `/repo` and then we take a snapshot of it
-# first by cloning it. This ensures we're not including any
-# uncommitted changes in the working directory on the host. Notice
-# that we no longer take the zipfile.
-CMD git clone /repo . \
- && uv sync --all-extras --all-groups \
- && if [ "$REPRO_ARCH" = armv7 ]; then \
- uv run tools/repro-build.armv7.sh \
- && mkdir -p /repo/release-armv7 \
- && cp *.xz /repo/release-armv7/; \
- elif [ "$(dpkg --print-architecture)" = arm64 ]; then \
- uv run tools/repro-build.arm64.sh \
- && mkdir -p /repo/release-arm64 \
- && cp *.xz /repo/release-arm64/; \
- else \
- uv run tools/repro-build.sh \
- && cp *.xz /repo/release/; \
- fi
diff --git a/contrib/reprobuild/Dockerfile.resolute b/contrib/reprobuild/Dockerfile.resolute
deleted file mode 100644
index 5b783dd7fa57..000000000000
--- a/contrib/reprobuild/Dockerfile.resolute
+++ /dev/null
@@ -1,77 +0,0 @@
-FROM resolute
-
-ENV TZ=UTC
-RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
-ENV SOURCE_DATE_EPOCH=1672531200
-ENV RUST_PROFILE=release
-ENV PATH=/root/.pyenv/shims:/root/.pyenv/bin:/root/.cargo/bin:/root/.local/bin:$PATH
-
-RUN sed -i '/updates/d' /etc/apt/sources.list && \
- sed -i '/security/d' /etc/apt/sources.list && \
- sed -i 's/^deb \(.*\) resolute main$/deb \1 resolute main universe/' /etc/apt/sources.list
-
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- autoconf \
- automake \
- build-essential \
- ca-certificates \
- file \
- gettext \
- git \
- curl \
- libsqlite3-dev \
- libpq-dev \
- libsodium23 \
- libsodium-dev \
- lowdown \
- libtool \
- m4 \
- sudo \
- unzip \
- wget \
- jq \
- zip
-
-# Configure /repo/.git as 'safe.directory'
-RUN git config --global --add safe.directory /repo/.git
-
-# Install Python3.10 (more reproducible than relying on python3-setuptools)
-RUN git clone https://github.com/pyenv/pyenv.git /root/.pyenv && \
- apt-get install -y --no-install-recommends \
- libbz2-dev \
- libffi-dev \
- libreadline-dev \
- libssl-dev \
- zlib1g-dev && \
- pyenv install 3.10.0 && \
- pyenv global 3.10.0
-
-RUN wget -qO- https://astral.sh/uv/install.sh | sh
-
-RUN wget https://sh.rustup.rs -O rustup-install.sh && \
- bash rustup-install.sh --default-toolchain none --quiet -y && \
- rm rustup-install.sh && \
- /root/.cargo/bin/rustup install 1.85
-
-RUN mkdir /build
-WORKDIR /build
-
-# We mount the repo into `/repo` and then we take a snapshot of it
-# first by cloning it. This ensures we're not including any
-# uncommitted changes in the working directory on the host. Notice
-# that we no longer take the zipfile.
-CMD git clone /repo . \
- && uv sync --all-extras --all-groups \
- && if [ "$REPRO_ARCH" = armv7 ]; then \
- uv run tools/repro-build.armv7.sh \
- && mkdir -p /repo/release-armv7 \
- && cp *.xz /repo/release-armv7/; \
- elif [ "$(dpkg --print-architecture)" = arm64 ]; then \
- uv run tools/repro-build.arm64.sh \
- && mkdir -p /repo/release-arm64 \
- && cp *.xz /repo/release-arm64/; \
- else \
- uv run tools/repro-build.sh \
- && cp *.xz /repo/release/; \
- fi
diff --git a/contrib/reprobuild/check.sh b/contrib/reprobuild/check.sh
new file mode 100755
index 000000000000..6a6a42b6d32d
--- /dev/null
+++ b/contrib/reprobuild/check.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+# What the driver's `check` runs on a finished tarball.
+#
+# contrib/reprobuild/check.sh release/clightning-...tar.xz
+#
+# These are properties a release must have and the build could lose silently,
+# so they are asserted on the shipped bytes rather than trusted, and `sign`
+# refuses a tarball that fails:
+#
+# * stripped -- no .symtab or .debug_* in any shipped ELF;
+# * static-pie -- pkgsStatic's stdenv appends `-static`, which quietly
+# yields a non-PIE static binary and loses ASLR;
+# * a build-id -- nixpkgs' toolchain emits none by default, and without one
+# a crash report from a stripped binary cannot be resolved at all.
+set -eu
+
+tarball=${1:?usage: check.sh }
+tmp=$(mktemp -d)
+# chmod first: a tarball built straight out of a Nix store path carries
+# read-only directories, which makes the cleanup fail.
+trap 'chmod -R u+w "$tmp" 2>/dev/null; rm -rf "$tmp"' EXIT
+tar -xf "$tarball" -C "$tmp"
+
+# The documented install is `-C /usr/local --strip-components=2`, which only
+# works when every member is usr/local/..., as in the official tarballs.
+if tar -tf "$tarball" | grep -qvE '^usr/(local/.*)?$'; then
+ echo "check: $tarball has members outside usr/local/:" >&2
+ tar -tf "$tarball" | grep -vE '^usr/(local/.*)?$' | head -5 >&2
+ exit 1
+fi
+
+# Located rather than spelled out: which prefix the tarball installs under is
+# the release derivation's business, not a second fact this script has to keep
+# in step with it.
+lightningd=$(find "$tmp" -type f -name lightningd | head -1)
+[ -n "$lightningd" ] || { echo "check: no lightningd in $tarball" >&2; exit 1; }
+
+elfs=0 bad=0 nonpie=0 nobuildid=0 stripped_bad=0
+# shellcheck disable=SC2044
+for fp in $(find "$tmp" -type f); do
+ [ "$(head -c 4 "$fp" | od -An -tx1 | tr -d ' \n')" = "7f454c46" ] || continue
+ elfs=$((elfs + 1))
+ rel=${fp#"$tmp"}
+
+ sections=$(readelf -SW "$fp" 2>/dev/null || true)
+ hdr=$(readelf -hW "$fp" 2>/dev/null || true)
+ notes=$(readelf -nW "$fp" 2>/dev/null || true)
+
+ if printf '%s' "$sections" | grep -qE '\.symtab|\.debug_'; then
+ echo "FAIL $rel: carries .symtab/.debug_*"
+ stripped_bad=$((stripped_bad + 1)); bad=$((bad + 1))
+ fi
+ if ! printf '%s' "$hdr" | grep -q 'Type:[[:space:]]*DYN'; then
+ echo "FAIL $rel: not position-independent"
+ nonpie=$((nonpie + 1)); bad=$((bad + 1))
+ fi
+ if ! printf '%s' "$notes" | grep -q 'Build ID'; then
+ echo "FAIL $rel: no build-id"
+ nobuildid=$((nobuildid + 1)); bad=$((bad + 1))
+ fi
+ # A truly static binary has no INTERP and no NEEDED entries.
+ if readelf -lW "$fp" 2>/dev/null | grep -q 'INTERP'; then
+ echo "FAIL $rel: has a PT_INTERP (dynamically linked)"
+ bad=$((bad + 1))
+ fi
+done
+
+# The arm tarballs are for the Raspberry Pi (nix/release-rows): armhf must
+# run on a Pi 2 (Cortex-A7: ARMv7, VFPv4, NEON), arm64 on a Pi 3
+# (Cortex-A53: ARMv8.0). Neither shows in the checks above.
+machine=$(readelf -hW "$lightningd" | sed -n 's/^ *Machine: *//p')
+case "$machine" in
+*AArch64*) qemu=qemu-aarch64 cpu=cortex-a53 ;;
+*ARM*) qemu=qemu-arm cpu=cortex-a7 ;;
+*) qemu='' cpu='' ;;
+esac
+
+# armhf: what each binary was compiled for. A tag above the Pi 2, or a
+# soft-float ABI, fails.
+armattr_bad=0
+if [ "$qemu" = qemu-arm ]; then
+ # shellcheck disable=SC2044
+ for fp in $(find "$tmp" -type f); do
+ [ "$(head -c 4 "$fp" | od -An -tx1 | tr -d ' \n')" = "7f454c46" ] || continue
+ rel=${fp#"$tmp"}
+ attrs=$(readelf -A "$fp" 2>/dev/null || true)
+ tag() { printf '%s\n' "$attrs" | sed -n "s/^ *$1: //p"; }
+ why=
+ [ "$(tag Tag_CPU_arch)" = v7 ] || why="$why CPU_arch=$(tag Tag_CPU_arch)"
+ case "$(tag Tag_FP_arch)" in
+ VFPv3 | VFPv3-D16 | VFPv4 | VFPv4-D16) ;;
+ *) why="$why FP_arch=$(tag Tag_FP_arch)" ;;
+ esac
+ case "$(tag Tag_Advanced_SIMD_arch)" in
+ "" | NEONv1 | "NEONv1 with Fused-MAC") ;;
+ *) why="$why Advanced_SIMD=$(tag Tag_Advanced_SIMD_arch)" ;;
+ esac
+ [ "$(tag Tag_ABI_VFP_args)" = "VFP registers" ] || why="$why not hard-float"
+ if [ -n "$why" ]; then
+ echo "FAIL $rel: not for a Raspberry Pi 2:$why"
+ armattr_bad=$((armattr_bad + 1)); bad=$((bad + 1))
+ fi
+ done
+fi
+
+# Both arm rows: run every binary on the oldest Pi's CPU. This catches
+# code the attributes do not declare (rustc's armv7 target used D16-D31
+# under a VFPv3 tag). The plugins exit with no lightningd on stdin, which
+# is fine; a signal is not. qemu is the pinned one, not the host's.
+cpu_bad=0
+if [ -n "$qemu" ]; then
+ top=$(cd "$(dirname "$0")/../.." && pwd)
+ qemudir=$(nix --extra-experimental-features 'nix-command flakes' build --impure \
+ --no-link --print-out-paths --expr \
+ "(import (builtins.getFlake \"git+file://$top?submodules=1\").inputs.nixpkgs { system = \"x86_64-linux\"; }).qemu-user" |
+ head -1)
+ [ -x "$qemudir/bin/$qemu" ] || { echo "CHECK FAILED: no $qemu in $qemudir" >&2; exit 1; }
+ echo "--- running every ELF on $cpu"
+ # shellcheck disable=SC2044
+ for fp in $(find "$tmp" -type f); do
+ [ "$(head -c 4 "$fp" | od -An -tx1 | tr -d ' \n')" = "7f454c46" ] || continue
+ rc=0
+ timeout 120 "$qemudir/bin/$qemu" -cpu "$cpu" "$fp" --version /dev/null 2>&1 || rc=$?
+ if [ "$rc" -ge 124 ]; then
+ echo "FAIL ${fp#"$tmp"}: died on $cpu (exit $rc)"
+ cpu_bad=$((cpu_bad + 1)); bad=$((bad + 1))
+ fi
+ done
+fi
+
+echo "---"
+echo "ELFs checked: $elfs"
+echo "unstripped: $stripped_bad"
+echo "non-PIE: $nonpie"
+echo "missing build-id: $nobuildid"
+if [ -n "$qemu" ]; then
+ [ "$qemu" = qemu-arm ] && echo "above Pi 2 ABI: $armattr_bad"
+ echo "crashed on $cpu: $cpu_bad"
+fi
+if [ "$elfs" = 0 ]; then
+ echo "CHECK FAILED: no ELF files found in $tarball" >&2
+ exit 1
+fi
+if [ "$bad" != 0 ]; then
+ echo "CHECK FAILED: $bad problem(s)" >&2
+ exit 1
+fi
+echo "check: OK ($elfs ELFs, all static-pie, stripped, with build-id)"
diff --git a/contrib/reprobuild/fetch-bitcoin.sh b/contrib/reprobuild/fetch-bitcoin.sh
new file mode 100755
index 000000000000..9ce37290fd39
--- /dev/null
+++ b/contrib/reprobuild/fetch-bitcoin.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# What `tools/reprobuild fetch` runs: download Bitcoin Core's release tarballs for every arch in the matrix plus
+# SHA256SUMS(.asc), verify on the host (gpg against contrib/keys/bitcoin/,
+# then sha256sum), and extract bin/bitcoin-cli per triplet into the cache
+# that `docker` hands the Dockerfile as the `bitcoin` build context.
+#
+# contrib/reprobuild/fetch-bitcoin.sh [--cache=DIR]
+#
+# Downloads land in release/cache/dl (never a build context).
+# Result: $CACHE//bin/bitcoin-cli for x86_64-linux-gnu,
+# aarch64-linux-gnu, arm-linux-gnueabihf. Idempotent: existing downloads are
+# kept, verification always re-runs.
+set -eu
+
+top=$(cd "$(dirname "$0")/../.." && pwd)
+pins=$top/contrib/reprobuild/pins
+BITCOIN_VERSION=$(sed -n 's/^BITCOIN_VERSION=//p' "$pins")
+BITCOIN_URL=$(sed -n 's/^BITCOIN_URL=//p' "$pins")
+MIN_SIGS=$(sed -n 's/^BITCOIN_MIN_SIGS=//p' "$pins")
+CACHE=$top/release/cache/bitcoin-$BITCOIN_VERSION
+for arg; do
+ case "$arg" in
+ --cache=*) CACHE=${arg#*=} ;;
+ *) echo "unknown arg $arg" >&2; exit 1 ;;
+ esac
+done
+# arch -> Bitcoin Core release triplet (the matrix's three arches)
+TRIPLETS="x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf"
+
+DL=$(dirname "$CACHE")/dl
+mkdir -p "$DL" "$CACHE"
+cd "$DL"
+# shellcheck disable=SC2086
+for f in SHA256SUMS SHA256SUMS.asc $(for t in $TRIPLETS; do echo "bitcoin-$BITCOIN_VERSION-$t.tar.gz"; done); do
+ [ -s "$f" ] && { echo "fetch: have $f"; continue; }
+ echo "fetch: $BITCOIN_URL/$f"
+ curl -fsSL -o "$f.part" "$BITCOIN_URL/$f" && mv "$f.part" "$f"
+done
+
+# gpg: throwaway keyring holding only the vendored keys; count good sigs
+# rather than trusting gpg's exit status (SHA256SUMS.asc carries many
+# signatures, most from keys we do not vendor).
+GNUPGHOME=$(mktemp -d)
+export GNUPGHOME
+trap 'rm -rf "$GNUPGHOME"' EXIT
+gpg --batch --quiet --import "$top"/contrib/keys/bitcoin/* 2>/dev/null
+status=$(gpg --batch --status-fd 1 --verify SHA256SUMS.asc SHA256SUMS 2>/dev/null || true)
+# Distinct *keys*, not signature lines: the point of a minimum is that several
+# independent maintainers vouched for these bytes, and two signatures from one
+# key -- or one key imported twice -- would otherwise count as two vouches.
+good=$(printf '%s\n' "$status" | sed -n 's/^\[GNUPG:\] VALIDSIG \([0-9A-F]*\) .*/\1/p' | sort -u | grep -c . || true)
+bad=$(printf '%s\n' "$status" | grep -c '^\[GNUPG:\] BADSIG ' || true)
+printf '%s\n' "$status" | sed -n 's/^\[GNUPG:\] GOODSIG [0-9A-F]* /fetch: good signature: /p'
+echo "fetch: $good distinct key(s) with a good signature, $bad bad (minimum $MIN_SIGS)"
+[ "$bad" -eq 0 ] || { echo "fetch: BAD signature on SHA256SUMS.asc" >&2; exit 1; }
+[ "$good" -ge "$MIN_SIGS" ] || { echo "fetch: too few good signatures" >&2; exit 1; }
+
+# sha256: only our three tarballs are present; make sure all three were checked
+checked=$(sha256sum -c --ignore-missing SHA256SUMS | tee /dev/stderr | grep -c ': OK$')
+[ "$checked" -eq 3 ] || { echo "fetch: expected 3 verified tarballs, got $checked" >&2; exit 1; }
+
+for t in $TRIPLETS; do
+ rm -rf "${CACHE:?}/$t"
+ mkdir -p "$CACHE/$t/bin"
+ tar -xzf "bitcoin-$BITCOIN_VERSION-$t.tar.gz" -C "$CACHE/$t/bin" --strip-components=2 \
+ "bitcoin-$BITCOIN_VERSION/bin/bitcoin-cli"
+ echo "fetch: $CACHE/$t/bin/bitcoin-cli ($(file -b "$CACHE/$t/bin/bitcoin-cli" | cut -d, -f1-3))"
+done
diff --git a/contrib/reprobuild/pins b/contrib/reprobuild/pins
new file mode 100644
index 000000000000..b0c299e0d6b4
--- /dev/null
+++ b/contrib/reprobuild/pins
@@ -0,0 +1,48 @@
+# Data pins for the release driver (tools/reprobuild). Bumped deliberately,
+# reviewed as a diff, exactly like every other pin on this route.
+#
+# The builder is the upstream `nixos/nix` container, pinned by *index* digest
+# so it resolves the same on every architecture. The release build runs inside
+# it, so the host needs docker, coreutils and python3 but no Nix -- and no host
+# nix.conf, whose sandbox, substituters and filter-syscalls settings would
+# otherwise be unrecorded inputs to a signed artifact. `--host-nix` is the
+# opt-in for whoever has Nix and wants the faster loop; both are expected to
+# produce the same bytes, which has been measured on two machines.
+NIX_IMAGE=nixos/nix@sha256:7a007c766426c1877758ddc5cb87a965ac131fc78c582ce0083d922d51ae945c
+NIX_IMAGE_TAG=2.35.2
+
+# The skopeo the `docker` verb uses for OCI layouts and pushes.
+# Ubuntu 22.04's skopeo 1.4.1 lacks --preserve-digests, so the pinned
+# container is the normative path (a new enough host skopeo is used if found,
+# so this is the floor and not a ceiling).
+#
+# 1.22.3 is the newest skopeo *image*, which is not the newest skopeo: there are
+# v1.23.0, v1.24.0 and v1.24.1 source releases, but no 1.23.x or 1.24.x
+# container on quay.io/skopeo/stable (all 77 tags checked), on
+# quay.io/containers/skopeo, on ghcr.io or on Docker Hub. skopeo maintains
+# several stable branches at once and backports to them -- v1.22.3 shipped the
+# same day as v1.24.1 -- and the image track follows one of those branches. So
+# do not "fix" this to 1.24.x without first checking that an image exists.
+#
+# By *index* digest, like NIX_IMAGE above -- but of the `-immutable` tag, which
+# matters more than it sounds. quay's version tags float: `v1.22.3` was
+# re-pushed on 2026-10-02 and again on 2026-10-07. Worse, quay garbage-collects
+# a manifest once no tag points at it, so a digest taken from the floating tag
+# *stops resolving*: the digest below's predecessor, 249b92db, was verified
+# working on 2026-09-30 and was `manifest unknown` by 2026-10-07, which broke the
+# docker verb. Upstream publishes `-immutable` for exactly this, and it has not
+# moved since 2026-09-21. Pin that digest, so a tag keeps the manifest alive.
+SKOPEO_IMAGE=quay.io/skopeo/stable@sha256:c0ee1f4edca5c01cb8d5611124f92f3cc47196ecab68aee5d0f90834e00574d5
+SKOPEO_IMAGE_TAG=v1.22.3-immutable
+
+# The runtime image's base digest lives in the Dockerfile itself
+# (FROM debian:trixie-slim@sha256:...), bumped deliberately like a pin.
+#
+# Bitcoin Core: `tools/reprobuild fetch` downloads the release tarballs for
+# every arch of the matrix from BITCOIN_URL, verifies SHA256SUMS.asc against
+# contrib/keys/bitcoin/ on the host, and extracts bin/bitcoin-cli into the
+# cache the Dockerfile COPYs from. Bumped at release time.
+BITCOIN_VERSION=31.1
+BITCOIN_URL=https://bitcoincore.org/bin/bitcoin-core-31.1
+# Minimum number of good signatures on SHA256SUMS.asc from the vendored keys.
+BITCOIN_MIN_SIGS=3
diff --git a/contrib/reprobuild/portability.sh b/contrib/reprobuild/portability.sh
new file mode 100755
index 000000000000..6b7f6dd36946
--- /dev/null
+++ b/contrib/reprobuild/portability.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+# The portability matrix, run against a release tarball.
+#
+# contrib/reprobuild/portability.sh release/clightning-...tar.xz
+#
+# One tarball per architecture replaced one per distribution, and the whole
+# bet is that a static binary runs anywhere. That is a claim about other
+# people's systems, so it is measured every time rather than assumed -- and
+# measured again whenever the toolchain moves, because a result obtained with
+# a different libc does not transfer.
+#
+# The arch is read off the tarball name, and picks both the set of distro
+# images and the `--platform` the foreign rows run under.
+#
+# Each row unpacks the tarball over / in a bare distro container and runs
+# smoke.sh: --version, a regtest start, and a getmanifest
+# handshake with every plugin -- the pass mark is every plugin the tarball
+# actually ships, counted at run time.
+set -eu
+
+tarball=${1:?usage: portability.sh [--images="ubuntu:26.04 ..."]}
+shift
+IMAGES_OVERRIDE=
+for arg; do
+ case "$arg" in
+ --images=*) IMAGES_OVERRIDE=${arg#*=} ;;
+ *) echo "unknown arg $arg" >&2; exit 1 ;;
+ esac
+done
+top=$(cd "$(dirname "$0")/../.." && pwd)
+smoke=$top/contrib/reprobuild/smoke.sh
+tarball=$(cd "$(dirname "$tarball")" && pwd)/$(basename "$tarball")
+
+# The matrix rows, which are the runtime promise. Fedora has no
+# armhf row (no such image); everything else is the full three-Ubuntu set.
+case "$tarball" in
+*-amd64*) ARCH=amd64; PLATFORM=linux/amd64; IMAGES="ubuntu:22.04 ubuntu:24.04 ubuntu:26.04 fedora:43" ;;
+*-arm64*) ARCH=arm64; PLATFORM=linux/arm64; IMAGES="ubuntu:22.04 ubuntu:24.04 ubuntu:26.04 fedora:43" ;;
+*-armhf*) ARCH=armhf; PLATFORM=linux/arm/v7; IMAGES="ubuntu:22.04 ubuntu:24.04 ubuntu:26.04" ;;
+*) echo "cannot tell the arch from $tarball" >&2; exit 1 ;;
+esac
+# A release run checks the newest distro only -- enough to catch "the tarball
+# does not run" -- and the full matrix is kept for the acceptance suite.
+[ -n "$IMAGES_OVERRIDE" ] && IMAGES=$IMAGES_OVERRIDE
+echo "portability: $ARCH ($PLATFORM) <- $(basename "$tarball")"
+echo "portability: images: $IMAGES"
+
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+mkdir -p "$tmp/tree"
+tar -xf "$tarball" -C "$tmp/tree"
+
+# How many plugins must answer getmanifest: counted from the tarball, not
+# written down. A hardcoded number stops meaning anything the moment a plugin
+# is added or removed -- it would either keep passing against a stale floor or
+# fail a release for a deliberate removal. The path is globbed rather than
+# spelled out so the install prefix is not baked in here too.
+plugins=$(find "$tmp/tree" -path '*/libexec/c-lightning/plugins/*' -type f | grep -c . || true)
+[ "$plugins" -gt 0 ] || { echo "portability: no plugins found in the tarball" >&2; exit 1; }
+echo "portability: $plugins plugins in the tarball; every one must answer getmanifest"
+
+# Every image at once (each container only reads the shared tree), reported
+# afterwards in the order listed. The tag goes into the file name, so ':' is
+# replaced.
+for img in $IMAGES; do
+ docker run --rm --platform "$PLATFORM" \
+ -v "$tmp/tree:/cln:ro" -v "$smoke:/smoke.sh:ro" \
+ "$img" sh /smoke.sh > "$tmp/out.$(echo "$img" | tr ':/' '__')" 2>&1 &
+done
+wait
+
+pass=0 fail=0
+for img in $IMAGES; do
+ out=$tmp/out.$(echo "$img" | tr ':/' '__')
+ echo "################ $img ($PLATFORM)"
+ ok=$(grep -c '^ok ' "$out" || true)
+ bad=$(grep -c '^FAIL ' "$out" || true)
+ ver=$(grep -m1 -A1 '=== --version' "$out" | tail -1 || true)
+ echo " version line: $ver"
+ echo " plugins: $ok ok, $bad FAIL (of $plugins in the tarball)"
+ if [ "$bad" = 0 ] && [ "$ok" -eq "$plugins" ]; then
+ echo " => PASS"
+ pass=$((pass + 1))
+ else
+ echo " => FAIL"
+ # The failing plugins first: in an image run they come last, and the
+ # 40-line head of the log would cut them off.
+ grep '^FAIL ' "$out" || true
+ sed -n '1,40p' "$out"
+ fail=$((fail + 1))
+ fi
+done
+
+echo "================ portability $ARCH: $pass pass, $fail fail"
+[ "$fail" = 0 ]
diff --git a/contrib/reprobuild/publish.vars b/contrib/reprobuild/publish.vars
new file mode 100644
index 000000000000..7d1011640c6b
--- /dev/null
+++ b/contrib/reprobuild/publish.vars
@@ -0,0 +1,38 @@
+# Where a release is published. Data, not secrets: the bucket is public-read,
+# and the credentials that write it never appear here (see below).
+#
+# The bucket is configured for public read of exact keys with *listing
+# refused*, and object versioning is off on purpose -- see the key layout
+# below for what that means for the driver.
+
+# The public base URL a downloader resolves an artifact at, and what the
+# release notes and manifest links print. No custom domain fronts the bucket;
+# moving to one later would leave earlier releases' links on this host.
+PUBLISH_BASE_URL=https://storage.googleapis.com/cln-releases
+
+# The S3-compatible endpoint and bucket that `publish` uploads to. GCS speaks
+# S3 through its interoperability API, so one client (rclone, s3 backend,
+# provider=GCS) covers it.
+REPRO_S3_ENDPOINT=https://storage.googleapis.com
+REPRO_S3_BUCKET=cln-releases
+REPRO_S3_PROVIDER=GCS
+
+# Key layout. Release artifacts go to `/`, one-to-one with the
+# staging dir `release/publish//`; `publish` refuses to overwrite an
+# existing `/` prefix, because with versioning off immutability has to be
+# a driver rule.
+#
+# The source archive gets its own prefix: `certify` `nix copy`s the
+# fixed-output source paths there and it is served as a plain Nix binary cache
+# (`nix-cache-info` at its root), listed ahead of cache.nixos.org in the
+# substituter list the driver passes. Co-signers read it **anonymously** --
+# content-addressed paths are verified by hash, so it needs no signing key and
+# no credentials.
+PUBLISH_PREFIX_ARCHIVE=nix-cache
+
+# Credentials: the HMAC key of one shared publisher account, kept in the team's
+# password manager and shared with every captain. Sourced into the environment
+# as REPRO_S3_ACCESS_KEY_ID / REPRO_S3_SECRET_ACCESS_KEY for the length of the
+# command and never written to disk. That account cannot write under `debug/`,
+# so the unstripped binaries and symbol files cannot be published even by a
+# driver bug: the bucket refuses them, not just the staging rule.
diff --git a/contrib/reprobuild/smoke.sh b/contrib/reprobuild/smoke.sh
new file mode 100644
index 000000000000..5ac977ea0ba5
--- /dev/null
+++ b/contrib/reprobuild/smoke.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Runtime smoke test of a static tarball on a foreign distro (16, 22), run by
+# portability.sh:
+# docker run --rm -v :/cln:ro \
+# -v $PWD/contrib/reprobuild/smoke.sh:/smoke.sh:ro debian:bookworm-slim sh /smoke.sh
+# Runs inside a bare debian:bookworm-slim with the extracted tree at /cln.
+set -u
+cp -a /cln/. / || exit 1
+# Found on PATH, not at a fixed path: the install prefix is the release's
+# business, and this script should not be a second place that has to know it.
+lightningd_bin=$(command -v lightningd) || { echo "lightningd not on PATH after unpacking" >&2; exit 1; }
+echo "=== ldd (expect: not a dynamic executable / static-pie)"
+ldd "$lightningd_bin" 2>&1 | head -2
+echo "=== --version"
+lightningd --version
+lightning-cli --version
+echo "=== regtest start without bitcoind (expect: bcli fails to reach bitcoin-cli, lightningd exits)"
+mkdir -p /tmp/ln
+# Through a file, not a pipe: `cmd | tail` would make $? tail's status, so
+# the exit code reported here would always be tail's 0 and this check would
+# pass however lightningd died. POSIX sh has no PIPESTATUS.
+timeout 60 lightningd --network=regtest --lightning-dir=/tmp/ln --log-level=info --disable-plugin=clnrest > /tmp/ln/start.log 2>&1
+rc=$?
+tail -25 /tmp/ln/start.log
+echo "lightningd exit=$rc"
+echo "=== plugin manifest handshake: every plugin must answer getmanifest (static Rust included)"
+plugin_dir=$(dirname "$(dirname "$lightningd_bin")")/libexec/c-lightning/plugins
+req='{"jsonrpc":"2.0","id":"cln:getmanifest#0","method":"getmanifest","params":{"allow-deprecated-apis":false}}'
+# All plugins at once. stdin stays open until the reply is in (a plugin that
+# sees EOF right after the request exits 0 without answering), and closes as
+# soon as it is: under qemu every plugin answers in about a second, so a fixed
+# wait per plugin was nearly all of this test's run time.
+handshake() {
+ out=/tmp/manifest.$(basename "$1")
+ : > "$out"
+ # The feeder polls the file the plugin writes, on purpose.
+ # shellcheck disable=SC2094
+ {
+ printf '%s\n\n' "$req"
+ i=0
+ while [ $i -lt 200 ] && ! grep -q '"result"' "$out"; do
+ sleep 0.1
+ i=$((i + 1))
+ done
+ } | timeout 25 "$1" > "$out" 2>/dev/null
+}
+for p in "$plugin_dir"/*; do handshake "$p" & done
+wait
+for p in "$plugin_dir"/*; do
+ out=/tmp/manifest.$(basename "$p")
+ if grep -q '"result"' "$out"; then
+ echo "ok $(basename "$p")"
+ else
+ got=$(head -c 200 "$out" | tr -d '\n')
+ echo "FAIL $(basename "$p"): ${got:-no output}"
+ fi
+done
diff --git a/contrib/reprobuild/two-tree-probe.sh b/contrib/reprobuild/two-tree-probe.sh
new file mode 100755
index 000000000000..ec2c05af154b
--- /dev/null
+++ b/contrib/reprobuild/two-tree-probe.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# The two-tree probe, for one row.
+#
+# contrib/reprobuild/two-tree-probe.sh [--arch=amd64] [--jobs=N] [--host-nix]
+#
+# Build the same row from two trees that differ **only** by one tracked file
+# that is never compiled and never shipped, and require identical bytes.
+#
+# Why this and not a string check: the first proposal was "zero /nix/store
+# references" as the invariant, and 40 retired it as both unreachable
+# (lightningd keeps 8 OpenSSL store-path strings deliberately) and insufficient
+# -- a variant whose bytes tracked the tree carried no offending string at all,
+# because the path reached the bytes through gcc's `-frandom-seed` and
+# `DW_AT_producer`, which `--strip-all` then deletes while keeping the
+# consequence. Only rebuilding from a second tree can see that.
+#
+# This runs on **every** row rather than one: an amd64-only probe
+# was amd64-only, and the armhf Rust binaries were separately carrying a
+# DT_RUNPATH naming their output path -- invisible on the row that was checked.
+#
+# It costs two builds of one row, so it belongs in `certify`'s acceptance suite
+# rather than in every release. The probe commits are made on a throwaway
+# branch and removed afterwards; the tree is left as it was found.
+set -eu
+
+top=$(cd "$(dirname "$0")/../.." && pwd)
+ARCH=amd64
+JOBS=$(nproc 2>/dev/null || echo 4)
+HOST_NIX=
+for arg; do
+ case "$arg" in
+ --arch=*) ARCH=${arg#*=} ;;
+ --jobs=*) JOBS=${arg#*=} ;;
+ --host-nix) HOST_NIX=--host-nix ;;
+ *) echo "unknown arg $arg" >&2; exit 1 ;;
+ esac
+done
+
+[ -z "$(git -C "$top" status --porcelain --untracked-files=no)" ] ||
+ { echo "two-tree-probe: commit first; this makes commits of its own" >&2; exit 1; }
+
+start_branch=$(git -C "$top" rev-parse --abbrev-ref HEAD)
+start_rev=$(git -C "$top" rev-parse HEAD)
+probe=probe/two-tree-$$
+out=${TMPDIR:-/tmp}/two-tree-probe.$$
+mkdir -p "$out"
+
+# Invoked by the trap below, which shellcheck does not count as a use (SC2329
+# in 0.11, SC2317 in 0.9/0.10).
+# shellcheck disable=SC2329,SC2317
+cleanup() {
+ git -C "$top" checkout -q "$start_branch" 2>/dev/null ||
+ git -C "$top" checkout -q "$start_rev" 2>/dev/null
+ git -C "$top" branch -qD "$probe" 2>/dev/null
+ rm -f "$top/TWO-TREE-PROBE.md"
+ rm -rf "$out"
+}
+trap cleanup EXIT INT TERM
+
+echo "two-tree-probe: $ARCH, from $start_rev on a throwaway branch"
+git -C "$top" checkout -q -b "$probe"
+
+build() {
+ label=$1
+ "$top/tools/reprobuild" $HOST_NIX --jobs="$JOBS" \
+ --version=probe --mtime=2020-01-01 --out="$out/$label" build "$ARCH" \
+ > "$out/$label.log" 2>&1 || {
+ echo "two-tree-probe: build $label FAILED" >&2
+ tail -n 20 "$out/$label.log" >&2
+ exit 1
+ }
+ sha256sum "$out/$label/clightning-probe-static-$ARCH.tar.xz" | cut -d' ' -f1
+}
+
+# Tree A: the commit under test, plus the probe file with one value. Both
+# builds carry the file, so what differs between them is only its *contents* --
+# a file that no compiler reads and no artifact contains.
+printf 'probe A\n' > "$top/TWO-TREE-PROBE.md"
+git -C "$top" add TWO-TREE-PROBE.md
+git -C "$top" -c user.name=probe -c user.email=probe@localhost \
+ commit -q -m "probe A"
+a=$(build A)
+echo "two-tree-probe: A $a"
+
+printf 'probe B -- one tracked, unshipped, uncompiled file, different bytes\n' \
+ > "$top/TWO-TREE-PROBE.md"
+git -C "$top" add TWO-TREE-PROBE.md
+git -C "$top" -c user.name=probe -c user.email=probe@localhost \
+ commit -q -m "probe B"
+b=$(build B)
+echo "two-tree-probe: B $b"
+
+echo "---"
+if [ "$a" = "$b" ]; then
+ echo "two-tree-probe: OK ($ARCH) -- the release bytes do not track the tree"
+ exit 0
+fi
+echo "two-tree-probe: FAILED ($ARCH) -- the bytes track the tree" >&2
+echo " A $a" >&2
+echo " B $b" >&2
+echo " Something in the build reads a path that moves with the source: check" >&2
+echo " build-ids first (nixpkgs seeds -frandom-seed from \$out), then rpaths," >&2
+echo " then panic-location strings in the Rust artifacts (40, 47)." >&2
+exit 1
diff --git a/contrib/reprobuild/vls-check.sh b/contrib/reprobuild/vls-check.sh
new file mode 100755
index 000000000000..611856f8c319
--- /dev/null
+++ b/contrib/reprobuild/vls-check.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+# check.sh's assertions for the VLS signer binary. VLS is deferred from the
+# release, so this runs only when the `vls` verb is used directly, and it
+# is part of the gate for bringing VLS back.
+#
+# contrib/reprobuild/vls-check.sh release/remote_hsmd_socket-v0.14.0-
+#
+# Same three assertions as the tarball check -- the strip, static-pie and
+# the build-id -- plus the two
+# things that are specific to this artifact:
+#
+# * it is *run*, under the closure's own qemu on a cross row, so the claim
+# is "this binary works on that arch" and not "it links". The smoke
+# test lives outside the derivation so it can be run here.
+# smoke test outside the derivation precisely so it could be run here.
+# * `--git-desc` has to name the pinned commit. vls-util/build.rs bakes
+# `git describe` into the binary, and a fixed-output source fetch has no
+# `.git`; without the shim in nix/pkgs/vls.nix every VLS we ship would
+# report the literal `git-desc-failed`. This is the assertion that the
+# shim is still doing its job.
+set -eu
+
+bin=${1:?usage: vls-check.sh }
+top=$(cd "$(dirname "$0")/../.." && pwd)
+
+[ "$(head -c 4 "$bin" | od -An -tx1 | tr -d ' \n')" = "7f454c46" ] ||
+ { echo "CHECK FAILED: $bin is not an ELF" >&2; exit 1; }
+
+bad=0
+sections=$(readelf -SW "$bin")
+hdr=$(readelf -hW "$bin")
+notes=$(readelf -nW "$bin")
+
+if printf '%s' "$sections" | grep -qE '\.symtab|\.debug_'; then
+ echo "FAIL carries .symtab/.debug_*"; bad=$((bad + 1))
+fi
+if ! printf '%s' "$hdr" | grep -q 'Type:[[:space:]]*DYN'; then
+ echo "FAIL not position-independent"; bad=$((bad + 1))
+fi
+if ! printf '%s' "$notes" | grep -q 'Build ID'; then
+ echo "FAIL no build-id"; bad=$((bad + 1))
+fi
+if readelf -lW "$bin" | grep -q 'INTERP'; then
+ echo "FAIL has a PT_INTERP (dynamically linked)"; bad=$((bad + 1))
+fi
+
+machine=$(printf '%s' "$hdr" | sed -n 's/^ *Machine: *//p')
+case "$machine" in
+*X86-64*) emu=; qemu= ;;
+# The oldest Raspberry Pi each arm row must run on (nix/release-rows).
+*AArch64*) qemu="qemu-aarch64" cpu=cortex-a53 ;;
+*ARM*)
+ qemu="qemu-arm" cpu=cortex-a7
+ echo "--- ARM build attributes"
+ readelf -A "$bin" |
+ grep -E 'Tag_CPU_arch|Tag_FP_arch|Tag_ABI_VFP_args|Tag_Advanced_SIMD|Tag_CPU_name' || true
+ ;;
+*) echo "FAIL unexpected machine: $machine"; bad=$((bad + 1)); qemu= ;;
+esac
+
+if [ -n "${qemu:-}" ]; then
+ # The emulator comes from the *pinned* nixpkgs, not the host:
+ # made the same choice inside the derivation, because a build (or a
+ # check) must not depend on how the captain's kernel registered binfmt.
+ qemudir=$(nix --extra-experimental-features 'nix-command flakes' build --impure \
+ --no-link --print-out-paths --expr \
+ "(import (builtins.getFlake \"git+file://$top?submodules=1\").inputs.nixpkgs { system = \"x86_64-linux\"; }).qemu" |
+ head -1)
+ emu="$qemudir/bin/$qemu -cpu $cpu"
+ [ -x "$qemudir/bin/$qemu" ] || { echo "CHECK FAILED: no $qemu in $qemudir" >&2; exit 1; }
+fi
+
+echo "--- run"
+desc=$($emu "$bin" --git-desc 2>&1) || {
+ echo "FAIL could not run $bin${emu:+ under $emu}: $desc"
+ bad=$((bad + 1))
+ desc=
+}
+echo " $desc"
+case "$desc" in
+*git-desc-failed* | *git-desc-error* | *git-desc-badstr*)
+ echo "FAIL GIT_DESC is the build.rs fallback -- the git shim is not working"
+ bad=$((bad + 1))
+ ;;
+"remote_hsmd_socket git_desc=v"*)
+ rev=$(sed -n 's/^ *rev = "\([0-9a-f]*\)";.*/\1/p' "$top/nix/pkgs/vls.nix")
+ short=$(printf '%s' "$rev" | cut -c1-12)
+ case "$desc" in
+ *"-g$short") ;;
+ *) echo "FAIL GIT_DESC does not name the pinned rev $short"; bad=$((bad + 1)) ;;
+ esac
+ ;;
+"") ;;
+*) echo "FAIL unexpected --git-desc output"; bad=$((bad + 1)) ;;
+esac
+
+echo "---"
+echo "size: $(stat -c %s "$bin") bytes"
+echo "sha256: $(sha256sum "$bin" | cut -c1-64)"
+echo "build-id: $(printf '%s' "$notes" | sed -n 's/.*Build ID: //p')"
+if [ "$bad" != 0 ]; then
+ echo "CHECK FAILED: $bad problem(s)" >&2
+ exit 1
+fi
+echo "check: OK (static-pie, stripped, build-id, runs, names the pinned rev)"
diff --git a/contrib/reprobuild/vls-regtest.sh b/contrib/reprobuild/vls-regtest.sh
new file mode 100755
index 000000000000..735936be9dd8
--- /dev/null
+++ b/contrib/reprobuild/vls-regtest.sh
@@ -0,0 +1,212 @@
+#! /bin/sh
+# The CLN-VLS pair, on regtest (research 14; runs it every
+# release). This is the one test that exercises the *pair* rather than either
+# binary alone, and it is why the driver builds a test-only `vlsd`:
+# `remote_hsmd_socket` is CLN's hsmd replacement and does nothing by itself but
+# listen on port 7701 for a signer to connect.
+#
+# contrib/reprobuild/vls-regtest.sh --tarball= \
+# --signer= --vlsd=/bin/vlsd \
+# --bitcoin=/bin
+#
+# It is deliberately outside the derivation: it needs bitcoind, a
+# writable directory and several minutes, none of which belong in a build.
+# `tools/reprobuild` supplies the paths -- vlsd and bitcoind from the certified
+# nixpkgs, so the test does not depend on what the host happens to have
+# installed.
+#
+# Native row only. The released lightningd for a cross row runs under the
+# host's binfmt in the portability harness; asking a qemu-emulated node and
+# signer to complete a channel open would be testing the emulator.
+#
+# What it asserts, in order of what it would catch:
+# * lightningd comes up *at all* with the signer as hsmd -- the version
+# handshake (`VLS_CLN_VERSION`) is checked by VLS itself, and research 14
+# recorded v0.14.0 against CLN 25.12+/26.x as untested upstream;
+# * `getinfo` returns a node id: the node key came from the signer;
+# * `newaddr` and `signmessage` succeed: two more signer round trips;
+# * the signer logged no policy failure.
+set -eu
+
+TARBALL=
+SIGNER=
+VLSD=
+BITCOIN_BIN=
+KEEP=0
+TIMEOUT=300
+for arg; do
+ case "$arg" in
+ --tarball=*) TARBALL=${arg#*=} ;;
+ --signer=*) SIGNER=${arg#*=} ;;
+ --vlsd=*) VLSD=${arg#*=} ;;
+ --bitcoin=*) BITCOIN_BIN=${arg#*=} ;;
+ --keep) KEEP=1 ;;
+ --timeout=*) TIMEOUT=${arg#*=} ;;
+ *) echo "unknown arg $arg" >&2; exit 1 ;;
+ esac
+done
+for v in TARBALL SIGNER VLSD BITCOIN_BIN; do
+ eval "val=\$$v"
+ [ -n "$val" ] || { echo "vls-regtest: --$(echo "$v" | tr 'A-Z_' 'a-z-') is required" >&2; exit 1; }
+done
+[ -f "$TARBALL" ] || { echo "vls-regtest: no $TARBALL" >&2; exit 1; }
+[ -x "$SIGNER" ] || { echo "vls-regtest: no $SIGNER" >&2; exit 1; }
+[ -x "$VLSD" ] || { echo "vls-regtest: no $VLSD" >&2; exit 1; }
+
+tmp=$(mktemp -d)
+# Ports are derived from the pid rather than fixed: bitcoind is started
+# detached, so a run that dies before its cleanup (the first one here did,
+# on a vlsd panic) leaves a daemon holding the port and every later run
+# fails at startup with nothing but "Error during initialization".
+RPCPORT=$((18000 + $$ % 1000))
+LNPORT=$((19000 + $$ % 1000))
+VLS_PORT=$((7700 + $$ % 100))
+# The signer panics unless BITCOIND_RPC_URL, VLS_NETWORK and VLS_CLN_VERSION
+# are all set (vls-proxy/src/util/env_var.rs), and lightningd -- which only
+# sees an hsmd that never answers -- then hangs with no error of its own. The
+# released -vls image was missing two of the three.
+VLS_NETWORK=regtest
+export VLS_PORT VLS_NETWORK
+# Set once the RPC port is known, below.
+BITCOIND_RPC_URL=
+export BITCOIND_RPC_URL
+
+cleanup() {
+ [ -n "${LN_PID:-}" ] && kill "$LN_PID" 2>/dev/null
+ [ -n "${VLSD_PID:-}" ] && kill "$VLSD_PID" 2>/dev/null
+ # bitcoind is detached, so ask it to stop rather than killing a pid that
+ # is not ours; fall back to the pid if the RPC is already gone.
+ "$BITCOIN_BIN/bitcoin-cli" -datadir="$tmp/btc" stop >/dev/null 2>&1 ||
+ { [ -n "${BTC_PID:-}" ] && kill "$BTC_PID" 2>/dev/null; }
+ sleep 2
+ if [ "$KEEP" = 1 ]; then
+ echo "vls-regtest: kept $tmp"
+ return
+ fi
+ chmod -R u+w "$tmp" 2>/dev/null
+ rm -rf "$tmp"
+}
+trap cleanup EXIT INT TERM
+
+echo "vls-regtest: $(basename "$TARBALL") + $(basename "$SIGNER")"
+# `--integration-test` makes vlsd keep its own hsm_secret (in VLS deployments
+# the signer holds the key, and CLN's hsmd only proxies), at
+# /..//hsm_secret -- a sibling of the datadir that it does
+# not create itself.
+mkdir -p "$tmp/tree" "$tmp/ln" "$tmp/vls" "$tmp/btc" "$tmp/regtest"
+tar -xf "$TARBALL" -C "$tmp/tree"
+# Located, not spelled out: the install prefix belongs to the release
+# derivation, not to this harness.
+LIGHTNINGD=$(find "$tmp/tree" -type f -name lightningd | head -1)
+CLI=$(find "$tmp/tree" -type f -name lightning-cli | head -1)
+if [ -z "$LIGHTNINGD" ] || [ -z "$CLI" ]; then
+ echo "vls-regtest: no lightningd/lightning-cli in the tarball" >&2
+ exit 1
+fi
+[ -x "$LIGHTNINGD" ] || { echo "vls-regtest: the tarball has no usr/bin/lightningd" >&2; exit 1; }
+
+# --- bitcoind ---------------------------------------------------------------
+cat > "$tmp/btc/bitcoin.conf" </dev/null
+BTC_PID=$(pgrep -n -f "bitcoind -datadir=$tmp/btc" || true)
+BITCOIND_RPC_URL="http://repro:repro@127.0.0.1:$RPCPORT"
+echo "vls-regtest: bitcoind rpc $RPCPORT, signer port $VLS_PORT"
+btccli() { "$BITCOIN_BIN/bitcoin-cli" -datadir="$tmp/btc" -rpcwait "$@"; }
+btccli createwallet repro >/dev/null 2>&1 || btccli loadwallet repro >/dev/null 2>&1 || true
+addr=$(btccli getnewaddress)
+btccli generatetoaddress 101 "$addr" >/dev/null
+echo "vls-regtest: bitcoind at height $(btccli getblockcount)"
+
+# --- the signer -------------------------------------------------------------
+#
+# VLS refuses to sign for a node whose version it was not told about, so
+# VLS_CLN_VERSION must equal exactly what this lightningd reports (research
+# 14; the -vls image bakes the same value). Reading it off the binary under
+# test is the point: a stale constant would pass while the pair was wrong.
+CLN_VERSION=$("$LIGHTNINGD" --version)
+echo "vls-regtest: lightningd $CLN_VERSION, signer $("$SIGNER" --git-desc)"
+
+( cd "$tmp/vls" && VLS_CLN_VERSION="$CLN_VERSION" "$VLSD" \
+ --connect "http://127.0.0.1:$VLS_PORT" --network regtest \
+ --integration-test --datadir "$tmp/vls" --log-level info \
+ > "$tmp/vlsd.log" 2>&1 ) &
+VLSD_PID=$!
+
+# --- lightningd, with the signer as hsmd ------------------------------------
+VLS_CLN_VERSION="$CLN_VERSION" "$LIGHTNINGD" \
+ --network=regtest --lightning-dir="$tmp/ln" \
+ --bitcoin-rpcuser=repro --bitcoin-rpcpassword=repro \
+ --bitcoin-rpcconnect=127.0.0.1 --bitcoin-rpcport="$RPCPORT" \
+ --subdaemon=hsmd:"$SIGNER" \
+ --log-level=debug --log-file="$tmp/ln/log" \
+ --addr=127.0.0.1:"$LNPORT" &
+LN_PID=$!
+
+ok=0
+waited=0
+while [ "$waited" -lt "$TIMEOUT" ]; do
+ waited=$((waited + 2))
+ if "$CLI" --lightning-dir="$tmp/ln" --network=regtest getinfo > "$tmp/getinfo" 2>/dev/null; then
+ ok=1
+ break
+ fi
+ kill -0 "$LN_PID" 2>/dev/null || break
+ sleep 2
+done
+
+fail=0
+if [ "$ok" != 1 ]; then
+ echo "FAIL lightningd never answered getinfo with the VLS signer as hsmd"
+ echo "--- lightningd log (tail)"; tail -n 40 "$tmp/ln/log" 2>/dev/null
+ echo "--- vlsd log (tail)"; tail -n 40 "$tmp/vlsd.log" 2>/dev/null
+ exit 1
+fi
+
+nodeid=$(sed -n 's/.*"id"[ ]*:[ ]*"\([0-9a-f]\{66\}\)".*/\1/p' "$tmp/getinfo" | head -1)
+if [ -n "$nodeid" ]; then
+ echo "ok node id from the signer: $nodeid"
+else
+ echo "FAIL getinfo returned no node id"; fail=1
+fi
+
+if "$CLI" --lightning-dir="$tmp/ln" --network=regtest newaddr >/dev/null 2>&1; then
+ echo "ok newaddr (signer derived a key)"
+else
+ echo "FAIL newaddr"; fail=1
+fi
+
+if "$CLI" --lightning-dir="$tmp/ln" --network=regtest \
+ signmessage "reprobuild" > "$tmp/signmessage" 2>/dev/null; then
+ echo "ok signmessage (signer signed): $(sed -n 's/.*"zbase"[ ]*:[ ]*"\([^"]*\)".*/\1/p' "$tmp/signmessage" | cut -c1-24)..."
+else
+ echo "FAIL signmessage"; fail=1
+fi
+
+# A policy violation is how VLS refuses; it is not an lightningd error and
+# would otherwise pass unnoticed.
+if grep -qiE "policy failure|VLS_.*mismatch|refus" "$tmp/vlsd.log"; then
+ echo "FAIL the signer logged a refusal:"
+ grep -iE "policy failure|VLS_.*mismatch|refus" "$tmp/vlsd.log" | head -5 | sed 's/^/ /'
+ fail=1
+fi
+
+echo "---"
+if [ "$fail" != 0 ]; then
+ echo "vls-regtest: FAILED ($fail problem(s))" >&2
+ exit 1
+fi
+echo "vls-regtest: OK (the released signer signed for the released node)"
diff --git a/doc/Makefile b/doc/Makefile
index 2775eb1c9c49..a7c2a1dbc5ed 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -205,7 +205,7 @@ OLD_MARKDOWNPAGES_WITH_EXT := $(PREFIXED_MANPAGES:=.md)
# - Generate the tables schema via plugins/sql
# - Merge both and generate final schemas/sql.json
doc/schemas/sql.json: doc/schemas/sql-template.json plugins/sql
- @plugins/sql --print-docs | jq --arg sqldata "$$(awk '{printf "%s\n", $$0}')" '.tables += [$$sqldata]' $< > "$@.tmp" && mv "$@.tmp" "$@";
+ @$(CONFIGURATOR_WRAPPER) plugins/sql --print-docs | jq --arg sqldata "$$(awk '{printf "%s\n", $$0}')" '.tables += [$$sqldata]' $< > "$@.tmp" && mv "$@.tmp" "$@";
doc-all: $(MANPAGES) doc/index.rst
diff --git a/doc/contribute-to-core-lightning/docker-images.md b/doc/contribute-to-core-lightning/docker-images.md
index 99e1bf1211a1..4fd219cff53d 100644
--- a/doc/contribute-to-core-lightning/docker-images.md
+++ b/doc/contribute-to-core-lightning/docker-images.md
@@ -75,11 +75,35 @@ Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/38
```
# Building/publishing images on Dockerhub
-1. Ensure that your multiarch setup is working
-2. Run script `tools/build-release.sh --push docker` to build `amd64`, `arm64v8`, `latest` and `multiarch` images and publish them on Dockerhub.
+Release images are built and published by the release driver, from the same
+static tarballs the release signs — the image compiles nothing:
-3. If you do not want to push the images directly on Dockerhub then run `tools/build-release.sh docker`. It will only create images locally but not push them to Dockerhub.
+1. Ensure that your multiarch setup is working (the driver smoke-tests every
+ platform of the image under `binfmt` before it is published).
+
+2. `tools/reprobuild docker` builds one multi-arch image into a local OCI layout
+ under `release/docker/` and logs its per-architecture digests. Nothing is
+ pushed, and the digests are not signed — see below.
+
+3. `tools/reprobuild publish` pushes it, with `skopeo copy --all
+ --preserve-digests`, so what users pull is what was built and smoke-tested
+ rather than a recompressed copy. Before pushing it checks the layout's own
+ OCI labels, so a layout left over from another release or another commit is
+ refused. Add `--latest` to also move the `latest` tag; it is never implied and
+ never applied to an rc.
+
+The image digests are deliberately **not** part of the signed manifests. The
+image has one unpinned, network-touching input — the `apt-get install` of the
+entrypoint's runtime dependencies — so a third party cannot rebuild it later and
+arrive at the same digest, and a signature over a hash nobody can re-derive
+would claim more than it can support. What is attested is stronger and sits one
+level down: the release tarballs are built from source under Nix, reproduce
+byte-for-byte, and carry three signatures, and the image is built from those
+signed bytes.
+
+See the [release checklist](https://docs.corelightning.org/docs/release-checklist)
+for where those steps sit in a release.
# Miscellaneous
@@ -96,26 +120,20 @@ The Core Lightning (CLN) Docker image (platforms: `linux/amd64`, `linux/arm64`,
docker run -it --rm --platform=linux/amd64 --network=host -v '/root/.lightning:/root/.lightning' -v '/root/.bitcoin:/root/.bitcoin' elementsproject/lightningd:latest --network=regtest
```
-## Test repro Dockerfiles and repro-build.sh:
-1. Once the `cl-repro-` builder image is created, you can run it with:
-
-```shell
-docker run -it -v $(pwd):/repo cl-repro-noble /bin/bash
-```
-
-2. Get the Docker container ID of the above container using:
-
-```shell
-docker container ps
-```
+## Testing the reproducible build
-3. Start a shell in the container with:
+There are no `cl-repro-` builder images any more: the release is built
+by a Nix derivation inside a digest-pinned `nixos/nix` container, and
+`tools/reprobuild` is the only entry point. To poke at the build environment:
```shell
-docker exec -it bash
+tools/reprobuild build amd64 # one row
+tools/reprobuild build amd64 --rebuild # and have Nix prove it reproduces
```
-4. You can now run `. tools/repro-build.sh` with `--force-version` and `--force-mtime` arguments as needed.
+`--host-nix` uses your own Nix instead of the container, which is faster if you
+have one. See the [reproducible builds
+page](https://docs.corelightning.org/docs/repro) for the full flow.
## Execute other scripts for testing:
@@ -162,7 +180,15 @@ export RUST_BACKTRACE=1
4. Finally, run the Core Lightning node:
-4.1 Either by utilizing our docker image flavor `elementsproject/lightningd:v25.12-vls` which comes with pre-built `remote_hsmd_socket` binaries.
+> 🚧 The `-vls` image flavour is not published at the moment
+>
+> Core Lightning offers channel splicing by default and refuses to start with a
+> signer that cannot sign splice transactions, which no released VLS does yet.
+> The `-vls` image and the released `remote_hsmd_socket` binaries are therefore
+> suspended — 4.1 below describes how they work and will work again, but for now
+> use 4.2 with a signer you built yourself.
+
+4.1 Either by utilizing our docker image flavor `elementsproject/lightningd:v25.12-vls` which comes with pre-built `remote_hsmd_socket` binaries. The image sets `VLS_ENABLED`, `VLS_CLN_VERSION` and the network for you; you still have to pass `BITCOIND_RPC_URL`, because the signer validates against the chain itself and its bitcoind need not be the node's.
```shell
docker run -it --rm -d \
diff --git a/doc/contribute-to-core-lightning/release-checklist.md b/doc/contribute-to-core-lightning/release-checklist.md
index b669bc67851f..caf63fe233bf 100644
--- a/doc/contribute-to-core-lightning/release-checklist.md
+++ b/doc/contribute-to-core-lightning/release-checklist.md
@@ -22,7 +22,7 @@ Here's a checklist for the release process.
2. Use `devtools/changelog.py` to collect the changelog entries from pull request commit messages and merge them into the manually maintained `CHANGELOG.md`. This does API queries to GitHub, which are severely ratelimited unless you use an API token: set the `GH_TOKEN` environment variable to a Personal Access Token from https://github.com/settings/tokens
3. Check that `CHANGELOG.md` is well formatted, ordered in areas, covers all significant changes, and sub-ordered approximately by user impact & coolness.
4. Manually remove any entries which were mentioned for in the previous point releases (they will be duplicates!)
-5. Create a new CHANGELOG.md heading to `vrc1`, and create a link at the bottom. Note that you should exactly copy the date and name format from a previous release, as the `build-release.sh` script relies on this.
+5. Create a new CHANGELOG.md heading to `vrc1`, and create a link at the bottom. Note that you should exactly copy the date and name format from a previous release, as the release tooling parses the date from it.
6. Update the package versions: `uv run make update-versions NEW_VERSION=vrc1`
7. Create a PR with the above.
@@ -31,16 +31,32 @@ Here's a checklist for the release process.
1. Merge the above PR.
2. Tag it `git pull && git tag -s vrc1`. Note that you should get a prompt to give this tag a 'message'. Make sure you fill this in.
3. Confirm that the tag will show up for builds with `git describe`. We don't push it to GitHub yet, just in case the following steps fail, and more fixes are required!
-4. Run `contrib/cl-repro.sh` to generate the required `cl-repro-` builder images for the reproducible build environment.
-5. Execute `tools/build-release.sh bin-Fedora bin-Ubuntu sign` to locally reproduce the release, generating a matching `SHA256SUMS-v` file and signing it with your GPG key.
-6. Push the tag to trigger the "Release 🚀" CI action, which drafts a new `vrc1` pre-release on GitHub and uploads reproducible builds alongside the `SHA256SUMS-v` file and its signature from the `cln@blockstream.com` key. The arm64 and armv7 tarballs each come with their own manifest, `SHA256SUMS-v-arm64` and `SHA256SUMS-v-armv7`, and its `.asc`. The CI never replaces a file already on the release: re-running it only adds missing files, and appends its signature to an `.asc` that already has yours.
-7. Verify your local `SHA256SUMS-v` file matches the one in the draft release, then append your local signatures to the release's `SHA256SUMS-v.asc` file to attest to the build's integrity.
+4. Build and sign the release locally: `tools/reprobuild all`. This is the whole
+ build — three static tarballs, the source zip, the multi-arch image and both
+ signed manifests — and it needs only docker, coreutils and python3. Every rc is a
+ rehearsal of the release flow, so do not skip it. The signing key has to answer
+ before the build starts, so that an hour of building cannot end on a key nobody
+ can reach. If you would rather not sit next to the machine for that hour, add
+ `--wait-for-key`: the build then runs unattended and waits (30 minutes by
+ default, `--wait-for-key=SECONDS` to change it) once it has something to sign,
+ so you only need to plug in and unlock the smartcard at the end. It polls the
+ key rather than waiting for a keypress, so this works for a detached run whose
+ log you are tailing.
+5. Publish the rc: `tools/reprobuild publish`. That is the whole publication —
+ tarballs, manifests, signatures and the source zip to the download host, the
+ multi-arch image to Docker Hub, the tag to GitHub, and the GitHub release.
+ `latest` is never applied to an rc. **The "Release 🚀" workflow must be
+ disabled** (`gh workflow disable "Release 🚀"`): pushing a tag would publish
+ the pyln modules on its own schedule, and `publish` refuses while it is
+ enabled. Re-enable it afterwards.
8. Announce rc1 release on core-lightning's release-chat channel on Discord & Telegram.
9. Use `devtools/credit --markdown v` to generate a single contributor list for the release notes. Use `devtools/credit --verbose v` for namer selection and detailed annotations.
10. Prepare release notes draft including the contributor list from above, and share with the team for editing.
11. Upgrade your personal nodes to the rc1, to help testing.
12. Github action `Publish Python 🐍 distributions 📦 to PyPI and TestPyPI` uploads the pyln modules on test PyPI server. Make sure that the action has been triggered with RC tag and that the modules have been published on `https://test.pypi.org/project/pyln-*/#history`.
-13. Docker image publishing is handled by the GitHub action `Build and push multi-platform docker images`. Ensure that this action is triggered and that the RC image has been successfully uploaded to Docker Hub after the action completes. Alternatively, you can publish Docker images by running the `tools/build-release.sh docker` script. The GitHub action takes approximately 3-4 hours, while the script takes about 6-7 hours. It is highly recommended to test your Docker setup if you haven't done so before. Prior to building docker images by `tools/build-release.sh` script, ensure that `multiarch/qemu-user-static` setup is working on your system as described [here](https://docs.corelightning.org/docs/docker-images#setting-up-multiarchqemu-user-static).
+13. The rc's Docker images were published in step 5 by `tools/reprobuild
+ publish`, which pushes one multi-arch image built from the same tarballs
+ that were signed. There is nothing to trigger in CI.
## Releasing -rc2, ..., -rcN
@@ -48,13 +64,14 @@ Here's a checklist for the release process.
2. Update the package versions: `uv run make update-versions NEW_VERSION=vrcN`
3. Add a PR with the rcN, and merge it.
4. Tag it `git pull && git tag -s vrcN && git push origin vrcN`.
-5. Pushing the tag automatically starts the "Release 🚀" CI job, creating a draft pre-release and uploading reproducible builds with their `SHA256SUMS` files signed by the project key.
-6. Set up the reproducible build environment by running the script `contrib/cl-repro.sh` to generate the necessary builder images.
-7. Use the command `tools/build-release.sh bin-Fedora bin-Ubuntu sign` to locally rebuild the release and generate a personal signature file for the checksums.
-8. After confirming the local and pre-release `SHA256SUMS-v` files match, append your signatures to the pre-release's `SHA256SUMS-v.asc` file to formally attest to the build's validity.
+5. Build, sign and publish as for rc1: `tools/reprobuild all`, then
+ `tools/reprobuild publish`.
+6. Co-signers rebuild with `tools/reprobuild verify SHA256SUMS-vrcN` and
+ send you their signatures; append them to the manifest's `.asc`.
9. Announce tagged rc release on core-lightning's release-chat channel on Discord & Telegram.
10. Upgrade your personal nodes to the rcN.
-11. Confirm that Github actions for PyPI and Docker publishing are working as expected.
+11. Confirm the PyPI action worked as expected. Docker images are published by
+ `tools/reprobuild publish`, not by CI.
## Tagging the Release
@@ -66,34 +83,52 @@ Here's a checklist for the release process.
- Set the current release version in your shell (e.g., if the current release is `v26.04`): `VERSION=26.04`
- Create a signed, annotated tag: `git tag -a -s v$VERSION -m "v$VERSION"`
- Push the tag: `git push origin v$VERSION`
-5. Pushing the tag will trigger the CI pipeline, which will draft the pre-release and upload the build artifacts with project-signed checksums.
-6. Prepare the build environments by executing the `contrib/cl-repro.sh` script.
-7. Run `tools/build-release.sh bin-Fedora bin-Ubuntu sign` (with `--sudo` if you need root to run Docker) to:
- - Create reproducible zipfile
- - Build reproducible Fedora image
- - Build reproducible Ubuntu-v22.04, Ubuntu-v24.04 and Ubuntu-v26.04 images. Follow [link](https://docs.corelightning.org/docs/repro#building-using-the-builder-image) for manually Building Ubuntu Images.
- - Build Docker images for amd64 and arm64v8. Follow [link](https://docs.corelightning.org/docs/docker-images) for more details on Docker publishing.
- - Create and sign checksums. Follow [link](https://docs.corelightning.org/docs/repro#co-signing-the-release-manifest) for manually signing the release.
-8. If you used `--sudo`, the tarballs may be owned by root, so revert ownership if necessary: `sudo chown ${USER}:${USER} *${VERSION}*`
-9. Verify the checksums match the pre-release `SHA256SUMS-v`, then append your signatures to the official signature `SHA256SUMS-v.asc` file to confirm the build's integrity.
-10. Send `SHA256SUMS-v` & `SHA256SUMS-v.asc` files to the rest of the team to check and sign the release.
-11. Team members can verify the release with the help of `build-release.sh`:
- - Copy the release captain's `SHA256SUMS-v` and `SHA256SUMS-v.asc` into the root folder (`lightning`).
- - Run `tools/build-release.sh --verify`. It will create reproducible images, verify checksums and sign.
- - Send your signatures from `release/SHA256SUMS-v.asc` to release captain.
- - Or follow [link](https://docs.corelightning.org/docs/repro#verifying-a-reproducible-build) for manual verification instructions.
-12. Append signatures shared by the team into the `SHA256SUMS-v.asc` file, verify with `gpg --verify SHA256SUMS-v.asc SHA256SUMS-v` (always pass the manifest as the second argument, otherwise `gpg` may verify a payload embedded in the `.asc` and exit successfully without ever reading the checksums) and include the file in the draft release.
+5. Do **not** push the tag by hand: `tools/reprobuild publish` pushes it, last,
+ once everything else has gone out and been verified. Confirm the
+ "Release 🚀" workflow is disabled.
+6. Build and sign everything: `tools/reprobuild all`. It ends with
+ `SHA256SUMS-v`, signed with your key. The build takes 1–2 hours for
+ all three rows.
+7. Send the manifest and your signature to the co-signers. They run
+ `tools/reprobuild verify SHA256SUMS-v` — which rebuilds from the
+ commit and timestamp the manifest names — and send back
+ `SHA256SUMS-v.asc.`.
+8. Append their signatures to `SHA256SUMS-v.asc` and check the result
+ with `gpg --verify SHA256SUMS-v.asc SHA256SUMS-v` — always
+ pass the manifest as the second argument, or `gpg` may verify a payload
+ embedded in the `.asc` and exit successfully without reading the checksums. **Three good
+ signatures** — yours plus two co-signers', distinct keys from
+ `contrib/keys/` — are required before publishing; `publish` checks. The
+ `armhf` manifest may carry only your signature, which does not hold up the
+ release (see the caveat in the [reproducible builds
+ page](https://docs.corelightning.org/docs/repro)).
+9. Publish: `tools/reprobuild publish`, or `tools/reprobuild publish --latest`
+ if this release should also become `latest` on Docker Hub. This uploads the
+ artifacts and the source zip, reads them back and checks them against the
+ signed manifest, pushes the images, pushes the tag and creates the GitHub
+ release — in that order, so the irreversible step comes last.
+10. Run the acceptance suite if you have not since certifying:
+ `tools/reprobuild accept`. It runs the portability matrix and the two-tree
+ probe; `tools/reprobuild certify` is the fuller version that rebuilds
+ everything from source without the binary cache.
13. The GitHub action `Publish Python 🐍 distributions 📦 to PyPI and TestPyPI` should upload the pyln modules to pypi.org. However, this can also be done manually by running `uv run make pyln-release`. This process requires keys for each of the `pyln-client`, `pyln-proto`, and `pyln-testing` modules to be accessible to uv. You can set the key as an environment variable and build and publish each pyln release independently:
- `export UV_PUBLISH_TOKEN=`
- `uv run make pyln-release-client`
- ... repeat for each pyln package with the appropriate token.
-14. Publish multi-arch Docker images (`elementsproject/lightningd:v${VERSION}` and `elementsproject/lightningd:latest`) to Docker Hub either using the GitHub action `Build and push multi-platform docker images` or by running the `tools/build-release.sh docker` script. Prior to building docker images by `tools/build-release.sh` script, ensure that `multiarch/qemu-user-static` setup is working on your system as described [here](https://docs.corelightning.org/docs/docker-images#setting-up-multiarchqemu-user-static).
+14. Docker images were published by `tools/reprobuild publish` in step 9; there
+ is nothing to trigger in CI, and the CI image workflow stays disabled.
+ Re-enable the "Release 🚀" workflow if the project wants it back on
+ (`gh workflow enable "Release 🚀"`).
## Performing the Release
-1. Edit the GitHub draft and include the `SHA256SUMS-v.asc` file.
-2. Publish the release as not a draft.
-3. Announce the final release on core-lightning's release-chat channel on Discord & Telegram.
+1. `tools/reprobuild publish` in the previous section already pushed the tag and
+ created the GitHub release **as a draft** — the artifacts and the tag are
+ public at that point, but the release page is not. Check that it reads the way
+ you want, publish it, and re-enable the "Release 🚀" workflow
+ (`gh workflow enable "Release 🚀"`) if the project wants it back on.
+2. Announce the final release on core-lightning's release-chat channel on Discord & Telegram.
+3. Send a mail to c-lightning mailing list (`c-lightning@lists.ozlabs.org`), using the same wording as the Release Notes in GitHub.
4. Write release blog, post it on [Blockstream](https://blog.blockstream.com/) and announce the release on Twitter.
## Post-release
@@ -118,13 +153,24 @@ Here's a checklist for the release process.
5. Create a new commit that includes the updates from `update-versions` and `CHANGELOG.md`.
6. Tag the release with `git pull && git tag -s v.`. You will be prompted to enter a tag message, ensure this is filled out.
7. Confirm that the tag is properly set up for builds by running `git describe`.
-8. Trigger the pre-release by pushing the version tag with `git push origin v.`; the CI will handle drafting the release and uploading the initial signed checksums, for amd64 (`SHA256SUMS-v`), arm64 (`SHA256SUMS-v-arm64`) and armv7 (`SHA256SUMS-v-armv7`).
-9. Generate the required builder images by running `contrib/cl-repro.sh`.
-10. Sign the release locally by running `tools/build-release.sh bin-Fedora bin-Ubuntu sign` which will sign the release contents and create `SHA256SUMS-v` and `SHA256SUMS-v.asc` in the release folder.
-11. Validate that your local checksums `SHA256SUMS-v` match the Draft release's, then add your signatures to the draft release's signature `SHA256SUMS-v.asc` file.
-12. Share the `SHA256SUMS-v` and `SHA256SUMS-v.asc` files with the team for verification and signing.
-13. Append the signatures received from the team to the `SHA256SUMS-v.asc` file. Verify the file using `gpg --verify SHA256SUMS-v.asc SHA256SUMS-v`; the manifest must be passed as the second argument, otherwise `gpg` may verify a payload embedded in the `.asc` and exit successfully without ever reading the checksums. Then re-upload the file.
+8. Do not push the tag by hand; `tools/reprobuild publish` does it. Confirm the
+ "Release 🚀" workflow is disabled.
+9. Build and sign: `tools/reprobuild all`.
+10. Send both manifests and their signatures to the co-signers, who run
+ `tools/reprobuild verify SHA256SUMS-v.` and send
+ back their detached signatures.
+11. Append their signatures; three good ones from distinct committed keys are
+ required before publishing. Check the result with `gpg --verify
+ SHA256SUMS-v..asc
+ SHA256SUMS-v.` — the manifest must be the second
+ argument, or `gpg` may verify a payload embedded in the `.asc` instead.
+12. `tools/reprobuild publish`. Add `--latest` only if this point release should
+ become `latest` on Docker Hub. It publishes the artifacts, pushes the tag and
+ creates the GitHub release.
14. Finalize and publish the release (change it from draft to public).
-15. Ensure that the GitHub Actions for `Publish Python 🐍 distributions 📦 to PyPI and TestPyPI` and `Build and push multi-platform docker images` are functioning correctly. Check that the `PyPI` modules published on `https://pypi.org/project/pyln-*` and that the Docker image has been uploaded to Docker Hub.
+15. Check that the `Publish Python 🐍 distributions 📦 to PyPI and TestPyPI`
+ action published the pyln modules on `https://pypi.org/project/pyln-*`, or
+ publish them manually with `uv run make pyln-release`. Docker images were
+ already pushed in step 12.
16. Create a PR to merge updates from `update-versions` and `CHANGELOG.md` into `master` to keep it up-to-date for the next release.
17. Announce the hotfix release in the core-lightning release-chat channel on Discord and on Telegram.
diff --git a/doc/getting-started/advanced-setup/repro.md b/doc/getting-started/advanced-setup/repro.md
index ac0579b31ef4..d7f4224ee6d4 100644
--- a/doc/getting-started/advanced-setup/repro.md
+++ b/doc/getting-started/advanced-setup/repro.md
@@ -6,7 +6,16 @@ privacy:
---
[Reproducible builds](https://reproducible-builds.org/) close the final gap in the lifecycle of open-source projects by allowing anyone to verify that a given binary was produced by compiling publicly available source code.
-Core Lightning has provided a manifest of the binaries included in a release, along with signatures from the maintainers since version 0.6.2.
+Core Lightning has provided a manifest of the binaries included in a release, along with signatures from the maintainers, since version 0.6.2.
+
+> 🚧 Status
+>
+> This page documents the Nix-based build introduced on the
+> `prototype/nix-static` branch, driven by `tools/reprobuild`. All three
+> architectures build, reproduce under `nix build --rebuild` and pass the
+> release checks, and a co-signer's `verify` has reproduced every file in
+> both manifests. What has not yet run against a real key is the signing
+> itself.
The steps involved in creating reproducible builds are:
@@ -16,105 +25,140 @@ The steps involved in creating reproducible builds are:
- Creation of a manifest (`SHA256SUMS` file containing the cryptographic hashes of the binaries and packages)
- Signing of the manifest by maintainers and volunteers that have reproduced the files in the manifest starting from the source.
-The bulk of these operations are handled by the [`repro-build.sh`](https://github.com/ElementsProject/lightning/blob/master/tools/repro-build.sh) script, but some manual operations are required to setup the build environment. Since a binary is built against platform specific libraries we also need to replicate the steps once for each OS distribution and architecture, so the majority of this guide will describe how to set up those starting from a minimal trusted base. This minimal trusted base in most cases is the official installation medium from the OS provider.
-
-Note: Since your signature certifies the integrity of the resulting binaries, please familiarize yourself with both the [`repro-build.sh`](https://github.com/ElementsProject/lightning/blob/master/tools/repro-build.sh) script, as well as with the setup instructions for the build environments before signing anything.
-
-# Build Environment Setup
-
-The build environments are a set of docker images that are created directly from the installation mediums and repositories from the OS provider. The following sections describe how to create those images. Don't worry, you only have to create each image once and can then reuse the images for future builds.
-
-## Script cl-repro
-
-The script `contrib/cl-repro.sh` covers below `Base image creation` and `Builder image setup` steps. You can skip these steps by simply running the `contrib/cl-repro.sh` script.
-
-## Base image creation
-
-Depending on the distribution that we want to build for the instructions to create a base image can vary. In the following sections we discuss the specific instructions for each distribution, whereas the instructions are identical again once we have the base image.
-
-### Debian / Ubuntu and derivative OSs
-
-For operating systems derived from Debian we can use the `debootstrap` tool to build a minimal OS image, that can then be transformed into a docker image. The packages for the minimal OS image are directly downloaded from the installation repositories operated by the OS provider.
-
-We cannot really use the `debian` and `ubuntu` images from the docker hub, mainly because it'd be yet another trusted third party, but it is also complicated by the fact that the images have some of the packages updated. The latter means that if we disable the `updates` and `security` repositories for `apt` we find ourselves in a situation where we can't install any additional packages (wrongly updated packages depending on the versions not available in
-the non-updated repos).
-
-The following table lists the codenames of distributions that we currently support:
-
-- Ubuntu 22.04:
- - Distribution Version: 22.04
- - Codename: jammy
-- Ubuntu 24.04:
- - Distribution Version: 24.04
- - Codename: noble
-- Ubuntu 26.04:
- - Distribution Version: 26.04
- - Codename: resolute
-
-Depending on your host OS release you might not have `debootstrap` manifests for versions newer than your host OS. Due to this we run the `debootstrap` commands in a container of the latest version itself:
+Note: Since your signature certifies the integrity of the resulting binaries, please familiarize yourself with the build setup before signing anything.
+
+# The available binaries
+
+Every release ships **one build per architecture**, not one per distribution. The binaries are statically linked against [musl libc](https://musl.libc.org/), so they carry no runtime dependency on the libc, OpenSSL, sqlite or libpq of the machine they run on, and the same tarball works on any Linux distribution for that architecture.
+
+| Artifact | Architecture | Runs on | Notes |
+|---|---|---|---|
+| `clightning--static-amd64.tar.xz` | x86-64 | any Linux, x86-64 | baseline x86-64; uses hardware CRC32 where the CPU reports it |
+| `clightning--static-arm64.tar.xz` | AArch64 (`arm64`) | any Linux, ARMv8-A and newer | Raspberry Pi 3, 4, 5, Zero 2 W; most ARM servers |
+| `clightning--static-armhf.tar.xz` | 32-bit ARM (`armhf`) | any Linux, **ARMv7-A** hard-float and newer | Raspberry Pi 2 and newer. **Not** Pi 1 / Zero / Zero W, which are ARMv6 |
+| `lightningd` Docker image | amd64, arm64, arm/v7 | Docker | built *from* the tarballs above, one multi-arch manifest |
+| `clightning-.zip` | — | — | source archive |
+
+What this means in practice:
+
+- **There is no distribution dimension any more.** Earlier releases shipped
+ `clightning--Ubuntu-22.04.tar.xz` and friends, one per distribution and
+ version, because the binaries were dynamically linked against that distribution's
+ libraries. Pick the tarball for your architecture instead.
+- **32-bit ARM requires ARMv7-A with hardware floating point.** Raspberry Pi 1,
+ Pi Zero and Pi Zero W are ARMv6 and are not supported; build from source there.
+ On a Pi 3, 4 or 5 prefer the `arm64` tarball, even if you run a 32-bit userland —
+ the hardware is ARMv8.
+- **PostgreSQL and sqlite are both built in.** `--wallet=postgres://…` works out of
+ the box; libpq is linked statically like everything else.
+- **The binaries are stripped**, and each one keeps its GNU build-id so a crash
+ report can still be resolved against the release. Debug symbols are not published.
+- Every executable is a **static PIE** (`static-pie`), so ASLR still applies.
+- **There is no Validating Lightning Signer binary and no `-vls` image in this
+ release.** Core Lightning offers channel splicing by default and refuses to
+ run with a signer that cannot sign splice transactions; no released VLS
+ implements that yet, so the signer binary and the image built around it
+ could only have been published unable to start. Both return, with the
+ manifest lines that go with them, once upstream VLS signs splices. The build
+ recipe stays in the tree (`tools/reprobuild vls`) for anyone who wants to
+ build one anyway.
+
+## Installing a tarball
+
+The tarballs install into `/usr/local`, where they always have:
```shell
-for v in jammy noble resolute; do
- echo "Building base image for $v"
- docker run --rm -v $(pwd):/build ubuntu:$v \
- bash -c "apt-get update && apt-get install -y debootstrap && debootstrap $v /build/$v"
- tar -C $v -c . | docker import - $v
-done
+sudo tar -xvf clightning--static-.tar.xz -C /usr/local --strip-components=2
```
-Verify that the image corresponds to our expectation and is runnable:
+Inspect one first with `tar -tvf` if you would rather see what it contains before
+unpacking it, or unpack it somewhere harmless and copy what you need.
+
+# Build environment setup
+
+The build environment is a **pinned nixpkgs revision**, recorded in `flake.lock` in
+the repository. There are no builder images to construct from installation media,
+no package pin lists to refresh and no per-distribution setup: the compiler, every
+library and every build tool are content-addressed store paths, fixed by that one
+revision, and Nix builds them in a sandbox with no network access.
+
+The one exception is Rust: the release uses the Rust project's own release
+binaries (`rustc`, `cargo`, and the standard library for each target), pinned by
+sha256 in `nix/pkgs/rust-bin.nix`. nixpkgs has no prebuilt Rust compiler for the
+static cross rows, so otherwise every arm build would compile rustc from source
+first. nixpkgs' own rustc is bootstrapped from these same binaries, so this adds
+no new trust.
+
+All you need is Nix with flakes enabled (`nix-command` and `flakes` in
+`experimental-features`). The builds above are produced with Nix 2.31.3; if your
+Nix cannot evaluate the flake, the driver can also run the whole build inside a
+digest-pinned `nixos/nix` container instead of using your own Nix.
+
+The release artifacts are built from **the same derivation as `packages.default`**,
+evaluated as a static (and, for the arm rows, cross) variant — the flake's
+`cln-release-static-amd64`, `cln-release-static-arm64` and
+`cln-release-static-armhf` attributes, which are generated from the plain table
+in `nix/release-rows`. The thing that gets tested hardest every release is
+therefore the same thing Nix users install.
+
+Two guards keep that sharing honest. `nix/release-rows` also records the nixpkgs
+revision the release is *certified* against: if `flake.lock` moves, the release
+attributes refuse to evaluate and `nix flake check` fails, in the commit that
+moved it. And each row commits a short file under `nix/release-manifests/`
+listing what that row is made of — its direct inputs with versions, the
+toolchain versions, the build flags and the environment — so a change that
+reaches the release shows up as a diff you can read without knowing Nix.
+
+# Building
+
+Check out the tag you are building and run the driver. It needs **docker,
+coreutils and python3 (3.10 or newer)**, and nothing else: the driver is a
+single standard-library script, and every Nix command runs inside a
+digest-pinned `nixos/nix` container, with a store under
+`~/.cache/cln-reprobuild`. If you have Nix yourself and want the faster loop,
+add `--host-nix`.
```shell
-docker run ubuntu:noble cat /etc/lsb-release
+tools/reprobuild build # all three rows
+tools/reprobuild build amd64 # or one
```
-Which should result in the following output for `noble`:
-
-```shell
-DISTRIB_ID=Ubuntu
-DISTRIB_RELEASE=24.04
-DISTRIB_CODENAME=noble
-DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"
-```
+The driver refuses to build a release from a tree with uncommitted changes: Nix
+caches the working tree it fetched, so the artifacts could otherwise be labelled
+with a commit they were not built from.
-## Builder image setup
+The arm rows are cross-compiled from x86-64; no emulation is involved except for
+the handful of build steps that run their own output, which use a QEMU taken from
+the pinned closure rather than from the host's `binfmt` registration. That matters
+for reproducibility: a build that relied on the host's `binfmt` would give a
+different answer on a machine configured differently.
-Once we have the clean base image we need to customize it to be able to build Core Lightning. This includes disabling the update repositories, downloading the build dependencies and specifying the steps required to perform the build.
-
-For this purpose we have a number of Dockerfiles in the [`contrib/reprobuild`](https://github.com/ElementsProject/lightning/tree/master/contrib/reprobuild) directory that have the specific instructions for each base image.
-
-We can then build the builder image by calling `docker build` and passing it the `Dockerfile`:
+Each row prints the hash of the artifact it wrote, and then checks it — every
+shipped executable must be stripped, position-independent, free of any embedded
+library search path, and still carry its build-id:
```shell
-docker build -t cl-repro-jammy - < contrib/reprobuild/Dockerfile.jammy
-docker build -t cl-repro-noble - < contrib/reprobuild/Dockerfile.noble
-docker build -t cl-repro-resolute - < contrib/reprobuild/Dockerfile.resolute
+reprobuild: wrote release/clightning-v25.12-static-amd64.tar.xz
+57666565916779e12046cf8277e31554e1ce65ea08f3cd459694fb7101f85346 release/clightning-v25.12-static-amd64.tar.xz
+check: OK (40 ELFs, all static-pie, stripped, with build-id)
```
-Since we pass the `Dockerfile` through `stdin` the build command will not create a context, i.e., the current directory is not passed to `docker` and it'll be independent of the currently checked out version. This also means that you will be able to reuse the docker image for future builds, and don't have to repeat this dance every time. Verifying the `Dockerfile` therefore is
-sufficient to ensure that the resulting `cl-repro-` image is reproducible.
-
-The dockerfiles assume that the base image has the codename as its image name.
-
-# Building using the builder image
-
-Finally, after finishing the environment setup we can perform the actual build. At this point we have a container image that has been prepared to build reproducibly. As you can see from the `Dockerfile` above we assume the source git repository gets mounted as `/repo` in the docker container. The container will clone the repository to an internal path, in order to keep the repository clean, build the artifacts there, and then copy them back to `/repo/release`.
-We'll need the release directory available for this, so create it now if it doesn't exist:`mkdir release`, then we can simply execute the following command inside the git repository (remember to checkout the tag you are trying to build):
-
-```bash
-docker run --rm -v $(pwd):/repo -ti cl-repro-jammy
-docker run --rm -v $(pwd):/repo -ti cl-repro-noble
-docker run --rm -v $(pwd):/repo -ti cl-repro-resolute
-```
-
-The last few lines of output also contain the `sha256sum` hashes of all artifacts, so if you're just verifying the build those are the lines that are of interest to you:
+The tarball is itself a Nix output, so `--rebuild` has Nix build it a second
+time and compare against the store. That is a stronger statement than running
+the driver twice, which is only a store hit, and it covers the exact bytes that
+get signed rather than a `tar` run afterwards:
```shell
-ee83cf4948228ab1f644dbd9d28541fd8ef7c453a3fec90462b08371a8686df8 /repo/release/clightning-v0.9.0rc1-Ubuntu-18.04.tar.xz
-94bd77f400c332ac7571532c9f85b141a266941057e8fe1bfa04f054918d8c33 /repo/release/clightning-v0.9.0rc1.zip
+tools/reprobuild build amd64 --rebuild
```
-Repeat this step for each distribution and each architecture you wish to sign. Once all the binaries are in the `release/` subdirectory we can sign the hashes.
+A row takes about 5 minutes on a 24-thread machine once its toolchain is in the
+store. The first `armhf` run also builds that architecture's C toolchain (gcc,
+binutils, musl and the static libraries), which adds about 10 minutes.
+
+The source archive is a Nix output too, built from the same tree rather than
+assembled on your machine, so `tools/reprobuild zip` gives the same bytes
+everywhere.
## ARM builds (arm64 and armv7)
@@ -134,62 +178,92 @@ Once the tarballs are built, `tools/sign-release-arm.sh v arm64` (or `a
# Signing the release manifest
-The release captain is in charge of creating the manifest, whereas contributors and interested bystanders may contribute their signatures to further increase trust in the binaries.
+The release captain is in charge of creating the manifest, whereas contributors and
+interested bystanders may contribute their signatures to further increase trust in
+the binaries.
-## Script build-release
-1: Pull latest code from master
+There is **one** manifest, `SHA256SUMS-` — every release file, all
+three architectures. Every co-signer is expected to reproduce and sign it.
-2: Run the `tools/build-release.sh bin-Fedora bin-Ubuntu sign` script. This will create a release directory, build binaries for Fedora, and build binaries for Ubuntu (Jammy, Noble, and Resolute). Finally, it will sign the ZIP, Fedora, and Ubuntu builds.
-
-## Manual
-The release captain creates the manifest as follows:
+The release captain writes and signs it with one command:
```shell
-cd release/
-sha256sum *v0.9.0* > SHA256SUMS
-gpg -sb --armor SHA256SUMS
+tools/reprobuild sign
```
-# Co-signing the release manifest
-
-## Script build-release
-1: Pull latest code from master.
-
-2: Rename checksum files, shared by the release captain, to `SHA256SUMS-v($VERSION)` and `SHA256SUMS-v($VERSION).asc`.
+Each manifest begins with a comment block recording what the build consumed —
+the commit, the flake's `narHash`, whether submodules were included, the
+timestamp baked into the artifacts, and the certified nixpkgs revision.
+`sha256sum` ignores those lines; they are there so that a hash is never
+reported without the tree it came from. The driver refuses to write a manifest
+whose files were not all built from the same tree.
-2: Copy above files in the lightning directory.
+# Co-signing the release manifest
-3: Run `tools/build-release.sh --verify` script. It will build binaries for Ubuntu (Jammy, Noble & Resolute), verify zip & Ubuntu builds while copying Fedora checksums from the release captain's file.
+Co-maintainers and contributors wishing to add their own signature rebuild the
+release and compare it against the captain's manifest. Hand the manifest to the
+driver and it does the rest:
-4. Then send the resulting `release/SHA256SUMS.asc` file to the release captain so it can be merged with the other signatures into `SHASUMS.asc`.
+```shell
+tools/reprobuild verify SHA256SUMS-
+```
-## Manual
-Co-maintainers and contributors wishing to add their own signature verify that the `SHA256SUMS` and `SHA256SUMS.asc` files created by the release captain matches their binaries before also signing the manifest.
+It takes the commit and the timestamp **from the manifest**, not from whatever
+you have checked out — so you need that commit in your clone, but not on your
+current branch — rebuilds every file the manifest lists, compares them, and
+writes `SHA256SUMS-.asc.` only if all of them matched. Send
+that signature to the release captain, who merges it with the others.
-Always pass **both** files to `gpg --verify`: the signature first, then the file it is supposed to cover. See [Verifying a reproducible build](doc:repro#verifying-a-reproducible-build) below for why the single-argument form is not sufficient.
+If the driver tells you that commit is not in your clone, fetch the tag first.
+The tag is on GitHub:
```shell
-cd release/
-gpg --verify SHA256SUMS.asc SHA256SUMS
-sha256sum -c SHA256SUMS
-cat SHA256SUMS | gpg -sb --armor > SHA256SUMS.new
+git fetch origin tag v
```
-Then send the resulting `SHA256SUMS.new` file to the release captain so it can be merged with the other signatures into `SHASUMS.asc`.
+You do not need to check the tag out: `verify` builds the commit the manifest
+names, wherever your working tree happens to be.
+
+Lines for image digests are reported but never block: building the images is
+optional for a co-signer.
+
+If a file differs, the driver prints both hashes and withholds the signature.
+That is the whole protocol: tell the captain what you got, and the two of you
+work out the cause before anything is published.
+
+For the second manifest, run the same command against it. If it does not match,
+do not sign it — report the hashes you got and move on. That is a
+known-possible outcome today, and withholding the signature is the correct
+response, not a reason to hold up the release.
+
+Because one tarball now covers every distribution for its architecture, a co-signer
+with an x86-64 machine can reproduce **all three** rows: the arm rows are
+cross-compiled, so no ARM hardware is needed.
+
+> **History: the `armhf` row used to diverge across machines.**
+>
+> Until the 2026 toolchain move, the 32-bit ARM Rust binaries differed
+> stably between build machines — a reordered string table in the ARM
+> exception-unwinding objects Rust links in — and those artifacts lived in
+> a separate `SHA256SUMS--armhf` manifest, which a co-signer
+> signed only if they had reproduced it. That divergence is gone: all
+> three rows now come out byte-identical across machines (different CPU
+> vendors, host Nix and pinned container alike, confirmed by independent
+> co-signers), so `armhf` co-signs like every other row. Releases from
+> the split era keep their `-armhf` manifest, and `tools/reprobuild
+> verify` still reproduces and signs those.
# Verifying a reproducible build
You can verify the reproducible build in two ways:
- Repeating the entire reproducible build, making sure from scratch that the binaries match. Just follow the instructions above for this.
-- Verifying that the downloaded binaries match the hashes in `SHA256SUMS` and that the signatures in `SHA256SUMS.asc` are valid.
+- Verifying that the downloaded binaries match the hashes in `SHA256SUMS-` and that the signatures in `SHA256SUMS-.asc` are valid.
-Each release has one manifest per architecture: `SHA256SUMS-` covers the amd64 binaries and the source zip, and `SHA256SUMS--arm64` and `SHA256SUMS--armv7` cover the ARM binaries. Each manifest's signatures are in a matching `.asc` file. Assuming you have downloaded the binaries, the manifests and the signatures into the same directory, you can verify the signatures with the following (using v26.06.9 as the example):
+Assuming you have downloaded the binaries, the manifest and the signatures into the same directory, you can verify the signatures with the following:
```shell
-gpg --verify SHA256SUMS-v26.06.9.asc SHA256SUMS-v26.06.9
-gpg --verify SHA256SUMS-v26.06.9-arm64.asc SHA256SUMS-v26.06.9-arm64
-gpg --verify SHA256SUMS-v26.06.9-armv7.asc SHA256SUMS-v26.06.9-armv7
+gpg --verify SHA256SUMS-.asc SHA256SUMS-
```
Pass both filenames explicitly. With a single argument `gpg` picks its verification mode from the packet structure of the `.asc` file: for a genuine detached signature it guesses the sibling `SHA256SUMS`, but for an inline (clear-signed or embedded) message it verifies only the payload carried inside the `.asc` itself. It never reads `SHA256SUMS` in that case, and although it prints `WARNING: not a detached signature; file 'SHA256SUMS' was NOT verified!`, it still exits with status 0 — so the warning is easy to miss by eye and invisible to any script that only checks the exit code. Naming the manifest as the second argument forces `gpg` to check the signatures against that exact file, and to fail outright if the `.asc` is not a detached signature over it.
@@ -214,61 +288,27 @@ gpg: Good signature from "Lagrang3 " [full]
gpg: Signature made Wed Oct 7 13:49:21 2026 UTC
gpg: using RSA key 616C52F99D0612B2A151B1074129A994AA7E9852
gpg: Good signature from "Core Lightning (CLN) " [full]
-gpg: Signature made Tue Oct 6 19:43:33 2026 UTC
-gpg: using EDDSA key 4E4A142F8BD3C38A56B362ED578CAC08472545C5
-gpg: Good signature from "nGoline " [full]
-gpg: aka "Níckolas Goline " [full]
-gpg: Signature made Tue Oct 6 21:51:11 2026 UTC
-gpg: using EDDSA key 13054F60BEEB87D2B9C7D77DFAFE0D6665547AD6
-gpg: issuer "jaonoctus@protonmail.com"
-gpg: Good signature from "jaonoctus " [full]
-gpg: Signature made Wed Oct 7 01:31:17 2026 UTC
-gpg: using RSA key 1A371C2C30645FAA91AA6B7DB643E61284221961
-gpg: Good signature from "Sangbida Chaudhuri " [full]
-gpg: Signature made Wed Oct 7 13:49:22 2026 UTC
-gpg: using RSA key 616C52F99D0612B2A151B1074129A994AA7E9852
-gpg: Good signature from "Core Lightning (CLN) " [full]
-gpg: Signature made Tue Oct 6 21:26:43 2026 UTC
-gpg: using EDDSA key 4E4A142F8BD3C38A56B362ED578CAC08472545C5
-gpg: Good signature from "nGoline " [full]
-gpg: aka "Níckolas Goline " [full]
-gpg: Signature made Tue Oct 6 20:52:35 2026 UTC
-gpg: using EDDSA key 13054F60BEEB87D2B9C7D77DFAFE0D6665547AD6
-gpg: issuer "jaonoctus@protonmail.com"
-gpg: Good signature from "jaonoctus " [full]
-gpg: Signature made Tue Oct 6 20:38:44 2026 UTC
-gpg: using EDDSA key 8A079421A871D0B1083511937AB4802ED5A639F3
-gpg: Good signature from "daywalker90 " [full]
-gpg: Signature made Wed Oct 7 13:49:23 2026 UTC
-gpg: using RSA key 616C52F99D0612B2A151B1074129A994AA7E9852
-gpg: Good signature from "Core Lightning (CLN) " [full]
```
-If there are any issues `gpg` will print `Bad signature`, it might be because the signatures in `SHA256SUMS.asc` do not match the `SHA256SUMS` file, and could be the result of a filename change. Do not continue using the binaries, and contact the maintainers, if this is not the case, a failure here means that the verification failed.
+If there are any issues `gpg` will print `Bad signature`, it might be because the signatures do not match the manifest, and could be the result of a filename change. Do not continue using the binaries, and contact the maintainers, if this is not the case, a failure here means that the verification failed.
Next we verify that the binaries match the ones in the manifest:
```shell
-sha256sum -c SHA256SUMS-v26.06.9 SHA256SUMS-v26.06.9-arm64 SHA256SUMS-v26.06.9-armv7
+sha256sum -c --ignore-missing SHA256SUMS-
```
Producing output similar to the following:
```shell
-clightning-v26.06.9-Fedora-40-amd64.tar.gz: OK
-clightning-v26.06.9-Ubuntu-22.04-amd64.tar.xz: OK
-clightning-v26.06.9-Ubuntu-24.04-amd64.tar.xz: OK
-clightning-v26.06.9-Ubuntu-26.04-amd64.tar.xz: OK
-clightning-v26.06.9.zip: OK
-clightning-v26.06.9-Ubuntu-22.04-arm64.tar.xz: OK
-clightning-v26.06.9-Ubuntu-24.04-arm64.tar.xz: OK
-clightning-v26.06.9-Ubuntu-26.04-arm64.tar.xz: OK
-clightning-v26.06.9-Ubuntu-22.04-armv7.tar.xz: OK
-clightning-v26.06.9-Ubuntu-24.04-armv7.tar.xz: OK
-clightning-v26.06.9-Ubuntu-26.04-armv7.tar.xz: OK
+clightning-v25.12-static-amd64.tar.xz: OK
+clightning-v25.12-static-arm64.tar.xz: OK
+clightning-v25.12.zip: OK
```
-Each file should be marked as `OK`. If you only downloaded some of the files, add `--ignore-missing` to skip the ones you don't have. A failure to verify the hash would give a warning like the following:
+`--ignore-missing` is there because the manifest lists every file in the
+release and you have probably downloaded only the ones you need. Without it,
+`sha256sum` reports the files you do not have as failures. A failure to verify the hash would give a warning like the following:
```shell
sha256sum: WARNING: 1 computed checksum did NOT match
diff --git a/doc/getting-started/getting-started/installation.md b/doc/getting-started/getting-started/installation.md
index 129a23ddc734..a13cfca2e01e 100644
--- a/doc/getting-started/getting-started/installation.md
+++ b/doc/getting-started/getting-started/installation.md
@@ -17,13 +17,25 @@ sudo snap refresh --hold bitcoin-core # To prevent automated update of bitcoin-c
sudo ln -s /snap/bitcoin-core/current/bin/bitcoin{d,-cli} /usr/local/bin/
```
-Then you can fetch a pre-compiled binary from the [releases](https://github.com/ElementsProject/lightning/releases) page on GitHub. Core Lightning provides binaries for both Ubuntu and Fedora distributions. Normally these binaries are extracted into /usr/local:
+Then you can fetch a pre-compiled binary from the [releases](https://github.com/ElementsProject/lightning/releases) page on GitHub. There is **one binary tarball per architecture**, not one per distribution: the binaries are statically linked, so the same tarball works on any Linux distribution.
+
+| Tarball | Architecture | Requires |
+|---|---|---|
+| `clightning--static-amd64.tar.xz` | x86-64 | any Linux |
+| `clightning--static-arm64.tar.xz` | AArch64 (`arm64`) | any Linux, ARMv8-A or newer — Raspberry Pi 3, 4, 5 |
+| `clightning--static-armhf.tar.xz` | 32-bit ARM (`armhf`) | any Linux, ARMv7-A hard-float or newer — Raspberry Pi 2 and newer, **not** Pi 1 / Zero / Zero W |
+
+Unsure which one you want? `dpkg --print-architecture`, or `uname -m` (`x86_64` → amd64, `aarch64` → arm64, `armv7l` → armhf). On a Raspberry Pi 3, 4 or 5 prefer `arm64` even if your userland is 32-bit, since the hardware is ARMv8.
+
+Normally these binaries are extracted into `/usr/local`:
```shell
sudo rm -R /usr/local/libexec/c-lightning/plugins # If you are upgrading run this first to avoid plugin conflicts
-sudo tar -xvf .tar.xz -C /usr/local --strip-components=2
+sudo tar -xvf clightning--static-.tar.xz -C /usr/local --strip-components=2
```
-If you're on a different distribution or OS, you can compile the source by following the instructions from [Installing from Source](doc:installation#installing-from-source).
+Both sqlite and PostgreSQL support are built in, and the binaries need no libraries from your distribution — not even a libc.
+
+If you're on an OS other than Linux, or on 32-bit ARM older than ARMv7, you can compile the source by following the instructions from [Installing from Source](doc:installation#installing-from-source).
# Docker
diff --git a/external/Makefile b/external/Makefile
index 4ff220539eb5..03d5e3791ae5 100644
--- a/external/Makefile
+++ b/external/Makefile
@@ -23,6 +23,24 @@ JSMN_HEADERS := external/jsmn/jsmn.h
GHEAP_HEADERS := external/gheap/gheap.h
LIBBACKTRACE_HEADERS := external/libbacktrace/backtrace.h
+# backtrace-supported.h is generated by libbacktrace's configure into the build
+# dir; objects that include it must wait for that build, otherwise they race it
+# (and, where the compiler ships its own copy of the header, silently pick that
+# one up instead -- as gcc's libgcc-dev does).
+#
+# Deliberately *not* in EXTERNAL_HEADERS, and an order-only prerequisite of the
+# objects. EXTERNAL_HEADERS depends on the phony submodcheck, which is always
+# newer, so every member of it is permanently out of date -- harmless for
+# checked-out headers that have no recipe, but a header we *generate* would then
+# re-run libbacktrace's configure on every single make. Order-only says what we
+# actually mean: it has to exist before anything compiles, and its timestamp is
+# not a reason to recompile.
+#
+# Like $(EXTERNAL_LIBS), and for the same reason, it also has to be named in
+# TESTPACK_EXTRAS: the testpack prunes external/, so otherwise it does not reach
+# the phase that only checks.
+EXTERNAL_GEN_HEADERS := $(TARGET_DIR)/libbacktrace-build/backtrace-supported.h
+
EXTERNAL_HEADERS := $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS) $(JSMN_HEADERS) $(GHEAP_HEADERS) $(LIBBACKTRACE_HEADERS)
EXTERNAL_LIBS := ${TARGET_DIR}/libwallycore.a ${TARGET_DIR}/libsecp256k1.a ${TARGET_DIR}/libjsmn.a ${TARGET_DIR}/libbacktrace.a
@@ -92,7 +110,10 @@ $(TARGET_DIR)/libjsmn.a: $(TARGET_DIR)/jsmn-build/jsmn.o
.INTERMEDIATE: $(TARGET_DIR)/jsmn-build/jsmn.o
# Need separate build dir: changes inside submodule make git think it's dirty.
-$(TARGET_DIR)/libbacktrace.a: external/libbacktrace/backtrace.h
+# One recipe produces the archive and the generated header, so say so with a
+# grouped target: a plain recipe-less rule would let make treat the missing
+# header as freshly made, and silently rebuild every object instead.
+$(TARGET_DIR)/libbacktrace.a $(EXTERNAL_GEN_HEADERS) &: external/libbacktrace/backtrace.h
mkdir -p $(TARGET_DIR)/libbacktrace-build
cd $(TARGET_DIR)/libbacktrace-build && $(TOP)/libbacktrace/configure CC="$(CC)" --enable-static=yes $(CROSSCOMPILE_OPTS) --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)
$(MAKE) -C $(TARGET_DIR)/libbacktrace-build DESTDIR=$$(pwd)/$(TARGET_DIR) install-exec
diff --git a/flake.lock b/flake.lock
index 5474f69f3930..f6092165a695 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,11 +3,11 @@
"advisory-db": {
"flake": false,
"locked": {
- "lastModified": 1750151065,
- "narHash": "sha256-il+CAqChFIB82xP6bO43dWlUVs+NlG7a4g8liIP5HcI=",
+ "lastModified": 1790752539,
+ "narHash": "sha256-SemOq7VmtTtujPa5IvPSIdoRn6JtlYYkXDkO9vGtlxI=",
"owner": "rustsec",
"repo": "advisory-db",
- "rev": "7573f55ba337263f61167dbb0ea926cdc7c8eb5d",
+ "rev": "9b3a3b73a7f42606494c943e95f8196e9994df46",
"type": "github"
},
"original": {
@@ -18,11 +18,11 @@
},
"crane": {
"locked": {
- "lastModified": 1750266157,
- "narHash": "sha256-tL42YoNg9y30u7zAqtoGDNdTyXTi8EALDeCB13FtbQA=",
+ "lastModified": 1789760033,
+ "narHash": "sha256-jtT4yxZpR8seYnlCMMWSSPlFN92zO6ICuZ8pJrmi86k=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "e37c943371b73ed87faf33f7583860f81f1d5a48",
+ "rev": "73b980519cefc727a5f6cc8e5c0947a2f9be6edd",
"type": "github"
},
"original": {
@@ -36,11 +36,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
- "lastModified": 1749398372,
- "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
+ "lastModified": 1788450739,
+ "narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
"owner": "hercules-ci",
"repo": "flake-parts",
- "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
+ "rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
"type": "github"
},
"original": {
@@ -51,11 +51,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1761373498,
- "narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=",
+ "lastModified": 1790689126,
+ "narHash": "sha256-ilerN1WLSvF+HMjziC/Wv99J5y02maDH+6hZPwsORKg=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce",
+ "rev": "b4fd65b198c599cbe814fcb9f42d25d021595ec9",
"type": "github"
},
"original": {
@@ -67,11 +67,11 @@
},
"nixpkgs-lib": {
"locked": {
- "lastModified": 1748740939,
- "narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",
+ "lastModified": 1788057806,
+ "narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
- "rev": "656a64127e9d791a334452c6b6606d17539476e2",
+ "rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
"type": "github"
},
"original": {
@@ -96,11 +96,11 @@
]
},
"locked": {
- "lastModified": 1761311587,
- "narHash": "sha256-Msq86cR5SjozQGCnC6H8C+0cD4rnx91BPltZ9KK613Y=",
+ "lastModified": 1786901030,
+ "narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
"owner": "numtide",
"repo": "treefmt-nix",
- "rev": "2eddae033e4e74bf581c2d1dfa101f9033dbd2dc",
+ "rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index 9cd4aad229b5..797dc373e306 100644
--- a/flake.nix
+++ b/flake.nix
@@ -49,7 +49,9 @@
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
- overlays = [ (final: prev: { craneLib = (inputs.crane.mkLib pkgs); }) ];
+ overlays = [
+ (final: prev: { craneLib = (inputs.crane.mkLib pkgs); })
+ ];
};
};
};
diff --git a/mkdocs.yml b/mkdocs.yml
index 7112dac569f2..47593d08576a 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -54,7 +54,7 @@ nav:
- "Fuzzing": FUZZING.md
- Maintainers:
- "Making Releases": MAKING-RELEASES.md
- - "Reproducible Builds": REPRODUCIBLE.md
+ - "Reproducible Builds": getting-started/advanced-setup/repro.md
- Reference:
- reference/index.md
diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix
index 8820741b9432..36f2a3219fe0 100644
--- a/nix/pkgs/default.nix
+++ b/nix/pkgs/default.nix
@@ -4,59 +4,228 @@
pkgs,
config,
postgresSupport ? false,
+ # Release mode.
+ #
+ # The release artifacts are built from *this* derivation, as a static and/or
+ # cross variant of it, rather than from a second release-only derivation that
+ # could drift from what `nix build .#cln` produces. `release = true` switches
+ # on everything the release needs and nothing an ordinary build wants:
+ #
+ # * version/mtime come from the driver (REPRO_VERSION / REPRO_MTIME),
+ # not from `.version` and `self.lastModifiedDate` -- bit-identity
+ # across two runs of different checkouts depends on it;
+ # * one `make install` builds the Rust plugins itself,
+ # so the crane side-build and NO_PYTHON=1 are off and cargo is fed
+ # an offline vendor dir instead of the network;
+ # * -static-pie on the compiler driver, with PIE_LDFLAGS overridden
+ # (the Makefile's trailing -pie turns -static-pie into
+ # a *dynamic* link);
+ # * strip --strip-all on every shipped ELF.
+ release ? false,
+ releaseVersion ? null,
+ releaseMtime ? null,
+ # The row's arch token from nix/release-rows (amd64, arm64,
+ # armhf). It only names the artifact; which package set the
+ # row builds under is decided by the caller.
+ releaseArch ? null,
}:
with pkgs;
let
- version = builtins.readFile ../../.version;
- py3 = python3.withPackages (p: [
+ version = if release then releaseVersion else builtins.readFile ../../.version;
+ mtime = if release then releaseMtime else self.lastModifiedDate;
+ # Build-machine tools. `with pkgs;` bypasses callPackage's splicing, so
+ # under pkgsStatic a bare `cargo`/`python3` is the *static* build of that
+ # tool (cargo's is even marked broken) rather than the native one that
+ # targets musl. For a native package set buildPackages == pkgs, so this
+ # is a no-op off the release path.
+ bp = pkgs.buildPackages;
+ py3 = bp.python3.withPackages (p: [
p.grpcio-tools
p.mako
]);
-in
-stdenv.mkDerivation {
- name = "cln";
- src = ../../.;
- inherit version;
- makeFlags = [
- "VERSION=${version}"
- "MTIME=${self.lastModifiedDate}"
- "NO_PYTHON=1"
- ];
+ # Offline cargo vendor dir. A Nix sandbox has no network, so "fetches are
+ # allowed as long as the lockfile pins them" becomes a vendor derivation keyed
+ # on Cargo.lock: the same inputs, pinned the same way, fetched earlier.
+ cargoVendor = buildPackages.rustPlatform.importCargoLock {
+ lockFile = ../../Cargo.lock;
+ };
+ rustTarget = stdenv.hostPlatform.rust.rustcTarget;
+ rustTargetEnv = lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] rustTarget);
+ # The cross rows.
+ #
+ # `canExecute` is nixpkgs' name for a fact this build had to discover the
+ # hard way: the build machine cannot run what a cross row produces, and
+ # CLN's build *does* run its own output in five places (the configurator's
+ # test programs, tools/headerversions, `plugins/sql --print-docs`, ...).
+ # On the host those had been running silently under the kernel's binfmt
+ # registration -- which is `F`-flagged here, so it reaches inside the Nix
+ # sandbox too. A release build must not depend on how the captain's
+ # kernel happens to be configured, so the emulator comes from *this
+ # closure*: `hostPlatform.emulator buildPackages` is the qemu-user binary
+ # nixpkgs would use, pinned by the same revision as everything else.
+ crossRow = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform);
+ emulator = stdenv.hostPlatform.emulator bp;
+ # How a release binary is linked lives in static-pie.nix, imported here and
+ # by vls.nix so the signer links exactly as Core Lightning does. That file
+ # carries the reasoning for each wrapper; these are just the names it exports.
+ inherit (import ./static-pie.nix { inherit pkgs lib; })
+ arm32
+ extraObjsManifest
+ staticPieFlags
+ staticPieCc
+ releaseCc
+ rustStaticPieCc
+ rustTargetFlags
+ noRpathEnv
+ ;
+ rustBin = import ./rust-bin.nix { inherit pkgs lib; };
+ # The row's libpq, bound once.
+ #
+ # This used to carry `hardeningDisable = [ "pie" ]` on the 32-bit ARM row,
+ # because postgres could not even *configure* there: its "whether the C
+ # compiler works" test links an executable, and nixpkgs' `pie` hardening plus
+ # pkgsStatic's `-static` made gcc pick the non-PIE crtbeginT.o for a PIE link
+ # ("relocation R_ARM_MOVW_ABS_NC against a local symbol can not be used when
+ # making a shared object"). `pie` is no longer one of nixpkgs' hardening
+ # flags, so naming it now aborts evaluation outright, and there is nothing
+ # left to disable under that name. Dropped rather than translated: the flag
+ # it would translate to is not obviously the same flag, and the 32-bit ARM
+ # row is what decides whether the problem is back.
+ #
+ # Still bound to a name rather than written inline in buildInputs, because
+ # `POSTGRES_LDLIBS` below has to refer to the *same* derivation -- naming
+ # `libpq` twice pulled two of them into the closure.
+ libpqRow = libpq;
# when building on darwin we need cctools to provide the correct libtool
# as libwally-core detects the host as darwin and tries to add the -static
# option to libtool, also we have to add the modified gsed package.
- nativeBuildInputs = [
- autoconf
- autogen
- automake
- gettext
- gitMinimal
- libtool
- # lowdown calls sandbox_init(3) on darwin, which fails inside a nix build.
- lowdown-unsandboxed
- pkgconf
- py3
- unzip
- which
- ]
- ++ lib.optionals postgresSupport [
- libpq
- libpq.pg_config
- ]
- ++ lib.optionals stdenv.isDarwin [
- cctools
- darwin.autoSignDarwinBinariesHook
- ];
+ nativeInputs =
+ with bp;
+ [
+ autoconf
+ # No GNU autogen: libwally's tools/autogen.sh is a shell script that runs
+ # autoreconf, and nothing in this build invokes the autogen program. It
+ # was pulling guile 2.2.7 and its boehm-gc into the closure, which is
+ # broken under pkgsStatic in current nixpkgs.
+ automake
+ gettext
+ gitMinimal
+ libtool
+ # lowdown calls sandbox_init(3) on darwin, which fails inside a nix build.
+ lowdown-unsandboxed
+ pkgconf
+ py3
+ unzip
+ which
+ ]
+ ++ lib.optionals (postgresSupport && !release) [
+ pkgs.libpq
+ pkgs.libpq.pg_config
+ ]
+ ++ lib.optionals release [
+ rustBin
+ protobuf
+ file
+ # configure needs a jq it can *run* ("*** We need jq!"); the one in
+ # buildInputs is the musl-static target build. The Alpine builder
+ # same requirement for the Alpine builder.
+ jq
+ # A build-platform C compiler reachable as plain `cc`. cargo compiles
+ # build scripts and proc macros *for the build machine* and asks rustc
+ # for its default linker, which is `cc`; the cross stdenv only puts
+ # `x86_64-unknown-linux-musl-gcc` on PATH, so every build script fails
+ # with "linker `cc` not found". Same class as CC_FOR_BUILD below.
+ stdenv.cc
+ ]
+ ++ lib.optionals stdenv.isDarwin [
+ cctools
+ darwin.autoSignDarwinBinariesHook
+ ];
- buildInputs = [
+ hostInputs = [
gmp
jq
libsodium
sqlite
zlib
+ ]
+ ++ lib.optionals (postgresSupport && release) [
+ libpqRow
+ # libpq.a is linked, not loaded, so *its* dependencies become ours:
+ # nixpkgs records them in libpq's own `LIBS` as
+ # `-lpgcommon -lpgport -lssl -lcrypto -lz -lm`. zlib is already here;
+ # OpenSSL is not, and libpq propagates only its `-dev` output (whose
+ # `lib/` holds nothing but pkgconfig), so without this the link path
+ # has no `libssl.a`/`libcrypto.a` at all.
+ openssl
+ ];
+
+ # Everything make is told on the release path except version and mtime,
+ # which are per-release labels; both are listed in the input manifest.
+ releaseMakeFlags =
+ lib.optionals release [
+ "RUST_PROFILE=release"
+ "PIE_LDFLAGS=-static-pie"
+ "TARGET=${rustTarget}"
+ # $(AR) has no assignment in the Makefile, so it would fall back to
+ # make's built-in `ar` -- the *build* machine's, which cannot index a
+ # foreign archive. Stated rather than left to the stdenv's exported AR.
+ "AR=${stdenv.cc.targetPrefix}ar"
+ ]
+ ++ lib.optionals (release && crossRow) [
+ # external/Makefile switches to --host/--build only when BUILD is set;
+ # without it libwally/libbacktrace configure as if native and their own
+ # run-tests decide wrong. CC_FOR_BUILD is there because
+ # cdump-enumstr is a build-machine program (it is *run* to generate
+ # source), so it must not be cross-compiled.
+ "BUILD=${stdenv.buildPlatform.config}"
+ "MAKE_HOST=${stdenv.hostPlatform.config}"
+ "CC_FOR_BUILD=cc"
+ ];
+
+ # -O2 on the release path. CLN's configure defaults COPTFLAGS to -Og, which
+ # is "optimise without getting in the debugger's way" -- roughly -O1, and not
+ # what a shipped binary wants. Measured on this tree: three interleaved pairs
+ # of runs, +17% on listpays and grpc getinfo, +8% and +7% on grpc listpeers
+ # and listinvoices, with identical RSS. Only the C half was affected; Rust
+ # already builds with RUST_PROFILE=release.
+ configureFlags =
+ [ "--disable-valgrind" ]
+ ++ lib.optionals release [
+ "--prefix=/usr/local"
+ "COPTFLAGS=-O2"
];
+ # Environment the release build needs set; also listed in the input
+ # manifest, since each of these moves release bytes.
+ releaseEnv = {
+ NIX_OUTPATH_USED_AS_RANDOM_SEED = "cln-release";
+ }
+ // noRpathEnv;
+ # Stated once so the input manifest can list it: these reach every Rust
+ # artifact's bytes, and a reviewer who does not read Nix should see a diff
+ # when they change. The vendor path itself is deliberately *not*
+ # in the manifest line -- remapping is what stops it mattering -- but its
+ # presence is.
+ vendorRemap = "--remap-path-prefix=${cargoVendor}=/home/clightning/vendor";
+ rustflagsShape = "--remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1${rustTargetFlags}";
+
+in
+stdenv.mkDerivation {
+ name = "cln";
+ src = ../../.;
+ inherit version;
+ makeFlags = [
+ "VERSION=${version}"
+ "MTIME=${mtime}"
+ ]
+ ++ lib.optionals (!release) [ "NO_PYTHON=1" ]
+ ++ releaseMakeFlags;
+
+ nativeBuildInputs = nativeInputs;
+ buildInputs = hostInputs;
+
# this causes some python trouble on a darwin host so we skip this step.
# also we have to tell libwally-core to use sed instead of gsed.
postPatch =
@@ -76,22 +245,303 @@ stdenv.mkDerivation {
substituteInPlace external/libwally-core/configure.ac --replace gsed sed
'';
- configureFlags = [ "--disable-valgrind" ];
+ # The unpacked source directory is named after the *source
+ # store path* (`-source`), so its name changes with any tree
+ # change, shipped or not. It reaches the shipped bytes through rustc panic
+ # locations, DWARF `comp_dir` and -- once a -ffile-prefix-map names it --
+ # `CCAN_CFLAGS` in the generated `ccan/config.h`; the latter two move the
+ # link-time `--build-id=sha1` and are then stripped away, so a build-id is
+ # all that is left to see. A constant name removes all of them, and the
+ # $NIX_BUILD_TOP map below then yields a constant `/home/clightning/source`.
+ ${if release then "postUnpack" else null} = ''
+ mv -- "$sourceRoot" source
+ export sourceRoot=source
+ '';
+
+ inherit configureFlags;
+
+ # CLN's ./configure is hand-rolled, not autotools: it rejects the flags
+ # nixpkgs' configurePhase adds for a static cross build
+ # (`--enable-static --disable-shared`, `--build=`, `--host=`) with
+ # "Unknown option". Suppress them and hand it the one prefix it wants;
+ # `prefix` (not a configureFlags entry) so nixpkgs emits it exactly once.
+ # The tarball must unpack over `/`, so the release installs to a DESTDIR
+ # with --prefix=/usr/local -- where CLN has always documented its binaries,
+ # and where a hand-built `make install` puts them. A release tarball is not
+ # the place to move a project's install directory.
+ # `prefix` is not the knob to use here: nixpkgs feeds it to configure
+ # *and* runs `mkdir -p "$prefix"` in installPhase, so an absolute prefix
+ # fails with "mkdir: cannot create directory: Permission denied".
+ # Suppress nixpkgs' own --prefix and pass ours in configureFlags; $out
+ # stays the prefix nixpkgs creates, and DESTDIR + --prefix=/usr/local gives
+ # a tarball that unpacks over `/`.
+ dontAddPrefix = release;
+ dontAddStaticConfigureFlags = release;
+ configurePlatforms = [ ];
+
+ preConfigure =
+ lib.optionalString release ''
+ export PYTEST=
+ export SOURCE_DATE_EPOCH LANG=C LC_ALL=C TZ=UTC
+
+ # cargo, offline, against the vendored crates.
+ export CARGO_HOME=$NIX_BUILD_TOP/cargo-home
+ mkdir -p $CARGO_HOME
+ cat > $CARGO_HOME/config.toml <` to every
+ # C compilation, gcc records its switches in DW_AT_producer, and
+ # `--build-id=sha1` hashes the *unstripped* output -- so every shipped C
+ # binary's build-id was a function of the output store path, which moves
+ # when any tracked file moves, compiled or not. The `--strip-all` below then
+ # deletes the evidence and keeps the consequence. The hook reads
+ # NIX_OUTPATH_USED_AS_RANDOM_SEED first; one constant for this package is
+ # what the hook's own comment contemplates.
+ // lib.optionalAttrs release releaseEnv;
- postInstall = ''
- cp ${config.packages.rust}/bin/cln-grpc $out/libexec/c-lightning/plugins
- cp ${config.packages.rust}/bin/clnrest $out/libexec/c-lightning/plugins
+ # Release installs into a DESTDIR with --prefix=/usr/local, so the tarball
+ # unpacks over `/` and lands where CLN has always documented it. The DESTDIR is in
+ # the build directory, not $out: $out holds only the tarball.
+ preInstall = lib.optionalString release ''
+ dest=$NIX_BUILD_TOP/dest
+ installFlagsArray+=("DESTDIR=$dest")
'';
+ # Every shipped ELF is stripped, and the result is asserted rather than
+ # assumed. It keeps the tarballs small and matches what every other release
+ # of this project shipped; the build-id survives, so a crash in a stripped
+ # binary is still resolvable against the unstripped twin kept beside it.
+ #
+ # nixpkgs' own fixupPhase is not enough on its own: it runs
+ # `--strip-debug` over bin/ and lib/, keeping .symtab, and its behaviour
+ # across cross/static stdenvs is not something the release should depend
+ # on. So: strip everything explicitly with --strip-all, then *assert* the
+ # result over the whole tree. If the assertion ever fails the build
+ # fails; nothing unstripped can reach a tarball.
+ postInstall =
+ if release then
+ ''
+ strip_one() {
+ ${stdenv.cc.targetPrefix}strip --strip-all --preserve-dates "$1" \
+ || { echo "strip failed on $1" >&2; exit 1; }
+ }
+ find "$dest" -type f -print0 | while IFS= read -r -d "" fp; do
+ case "$(head -c 4 "$fp" | od -An -tx1 | tr -d " \n")" in
+ 7f454c46) strip_one "$fp" ;;
+ esac
+ done
+
+ # The assertion. Every ELF: no .symtab, no .debug_*, and a
+ # build-id still present (the build-id is kept so a crash
+ # report stays resolvable -- it carries no function names).
+ fail=0
+ find "$dest" -type f -print0 | while IFS= read -r -d "" fp; do
+ case "$(head -c 4 "$fp" | od -An -tx1 | tr -d " \n")" in
+ 7f454c46) ;;
+ *) continue ;;
+ esac
+ sections=$(${stdenv.cc.targetPrefix}readelf -SW "$fp" 2>/dev/null || true)
+ if printf '%s' "$sections" | grep -qE '\.symtab|\.debug_'; then
+ echo "STRIP CHECK FAILED: $fp still carries .symtab/.debug_*" >&2
+ fail=1
+ fi
+ if readelf_dyn=$(${stdenv.cc.targetPrefix}readelf -dlW "$fp" 2>/dev/null) \
+ && printf '%s' "$readelf_dyn" | grep -qE 'RPATH|RUNPATH|INTERP'; then
+ echo "STATIC CHECK FAILED: $fp has an rpath or interpreter" >&2
+ fail=1
+ fi
+ if ! printf '%s' "$sections" | grep -q '\.note\.gnu\.build-id'; then
+ echo "STRIP CHECK FAILED: $fp has no build-id" >&2
+ fail=1
+ fi
+ [ "$fail" = 0 ] || exit 1
+ done
+
+ # The tarball is this derivation's output, so `nix build
+ # --rebuild` covers the bytes that are signed and no host's tar or xz
+ # sits inside the promise. The recipe:
+ # the artifact name, sorted entries, fixed mtime, numeric root
+ # ownership, and usr/ only (no leading ./, like the official
+ # tarballs, so `-C /usr/local --strip-components=2` works). --mode
+ # normalises what `make install` left, so unpacking over `/` never
+ # leaves /usr unwritable. xz is pinned to one thread: since xz 5.4
+ # the default is multi-threaded, whose block layout depends on the
+ # machine's core count.
+ mkdir -p $out
+ tar --sort=name --mtime="${mtime} 00:00Z" \
+ --owner=0 --group=0 --numeric-owner --mode='u+rwX,go=rX' \
+ -cf - -C "$dest" usr \
+ | xz -T1 -6 -c > $out/clightning-${version}-static-${releaseArch}.tar.xz
+ ''
+ else
+ ''
+ cp ${config.packages.rust}/bin/cln-grpc $out/libexec/c-lightning/plugins
+ cp ${config.packages.rust}/bin/clnrest $out/libexec/c-lightning/plugins
+ '';
+
+ # What this row's release build is made of, in words a
+ # reviewer who does not read Nix can diff. Only *direct* inputs: anything
+ # transitive cannot change without a nixpkgs bump, which the certified-rev
+ # guard already catches. The flake compares it with the committed
+ # nix/release-manifests/cln- and `tools/reprobuild certify` rewrites
+ # that file.
+ passthru.releaseManifest =
+ let
+ nv = d: "${lib.getName d} ${lib.getVersion d}";
+ section = title: lines: "${title}\n" + lib.concatMapStrings (l: " ${l}\n") lines;
+ in
+ lib.optionalString release (
+ section "row" (
+ [
+ "arch ${releaseArch}"
+ "host ${stdenv.hostPlatform.config}"
+ ]
+ ++ lib.optional (stdenv.hostPlatform.gcc ? fpu) "fpu ${stdenv.hostPlatform.gcc.fpu}"
+ )
+ # The recipe itself, by content hash. Everything below describes the
+ # build's *inputs* -- which package versions, which flags -- and says
+ # nothing about the files that decide what is done with them. Without
+ # this, an edit to static-pie.nix could change how every shipped binary
+ # is linked, move the output bytes, and leave this manifest
+ # byte-identical, so guard 2 would not fire: the compiler wrapper
+ # reaches the build through configureFlagsArray in the build phase and
+ # the Rust linker through an exported variable, and neither is in the
+ # configureFlags attribute the flags section below is built from.
+ + section "recipe" [
+ "default.nix ${builtins.hashFile "sha256" ./default.nix}"
+ "static-pie.nix ${builtins.hashFile "sha256" ./static-pie.nix}"
+ "rust-bin.nix ${builtins.hashFile "sha256" ./rust-bin.nix}"
+ "flake-module.nix ${builtins.hashFile "sha256" ./flake-module.nix}"
+ # flake.nix too: its overlays reach every package in the row, which is
+ # not hypothetical -- a fetchurl overlay lived there and changed how
+ # every source tarball was fetched.
+ "flake.nix ${builtins.hashFile "sha256" ../../flake.nix}"
+ ]
+ + section "toolchain" (
+ [
+ "gcc ${stdenv.cc.cc.version}"
+ "rustc ${rustBin.version}"
+ "python ${bp.python3.version}"
+ ]
+ ++ extraObjsManifest
+ ++ rustBin.manifestLines
+ )
+ + section "nativeBuildInputs" (lib.sort lib.lessThan (map nv nativeInputs))
+ + section "buildInputs" (lib.sort lib.lessThan (map nv hostInputs))
+ + section "flags" (
+ [
+ "configure ${lib.concatStringsSep " " configureFlags}"
+ "dontBuild true"
+ "dontPatchELF true"
+ "strip --strip-all"
+ ]
+ ++ [ "rustflags ${rustflagsShape}" ]
+ ++ lib.mapAttrsToList (k: v: "env ${k}=${v}") releaseEnv
+ ++ map (f: "make ${f}") releaseMakeFlags
+ )
+ );
+
meta = with lib; {
description = "Core Lightning (CLN): A specification compliant Lightning Network implementation in C";
homepage = "https://github.com/ElementsProject/lightning";
diff --git a/nix/pkgs/flake-module.nix b/nix/pkgs/flake-module.nix
index 31e2353b363d..9b9d1f1f0a8a 100644
--- a/nix/pkgs/flake-module.nix
+++ b/nix/pkgs/flake-module.nix
@@ -1,7 +1,172 @@
-{ self, ... }:
+{ self, inputs, ... }:
{
perSystem =
- { pkgs, config, ... }:
+ {
+ pkgs,
+ config,
+ lib,
+ system,
+ ...
+ }:
+ let
+ # the release
+ # matrix is data: `nix/release-rows`, read here with no tooling and by
+ # tools/reprobuild with `while read`. Every release attribute below is
+ # generated from it; none is written by hand.
+ rowsText = builtins.readFile ../release-rows;
+ rowLines = lib.filter (l: l != "" && !(lib.hasPrefix "#" l)) (
+ map lib.trim (lib.splitString "\n" rowsText)
+ );
+ fields = l: lib.filter (f: f != "") (lib.splitString " " (lib.replaceStrings [ "\t" ] [ " " ] l));
+ rows = map (
+ l:
+ let
+ f = fields l;
+ in
+ {
+ arch = builtins.elemAt f 0;
+ pkgsPath = builtins.elemAt f 1;
+ platform = builtins.elemAt f 2;
+ }
+ ) (lib.filter (l: !(lib.hasPrefix "@" l)) rowLines);
+ directive =
+ name:
+ let
+ hits = lib.filter (l: lib.hasPrefix "@${name} " l) rowLines;
+ in
+ assert lib.assertMsg (
+ builtins.length hits == 1
+ ) "nix/release-rows: expected exactly one @${name} line";
+ builtins.elemAt (fields (builtins.head hits)) 1;
+
+ # --- guard 1: the certified nixpkgs rev --------------------
+ #
+ # A contributor's `nix flake update`, run to fix a dev-shell paper cut,
+ # would otherwise move gcc, rustc and openssl under three signed
+ # tarballs without a word. The error names every way out: a guard
+ # whose message does not is a guard people delete.
+ certifiedRev = directive "nixpkgs";
+ lockedRev = inputs.nixpkgs.rev;
+ revOk = certifiedRev == lockedRev;
+ revMsg = ''
+ The release is certified against nixpkgs ${certifiedRev}
+ (nix/release-rows), but flake.lock pins ${lockedRev}.
+
+ Release bytes built from an uncertified nixpkgs are refused. Either:
+ * tools/reprobuild certify re-certify: from-source build + acceptance suite
+ * tools/reprobuild certify --no-verify record the new rev without the suite (visible in review)
+ * git checkout flake.lock put the certified nixpkgs back
+ '';
+
+ # --- guard 2: the committed input manifests -----------------
+ manifestFile = name: ../release-manifests + "/${name}";
+ manifestOk =
+ name: drv:
+ builtins.pathExists (manifestFile name)
+ && builtins.readFile (manifestFile name) == drv.releaseManifest;
+ manifestMsg = name: ''
+ nix/release-manifests/${name} does not match what the ${name} release
+ derivation is made of (or is missing). A change reached the release
+ path; make it visible in review. Either:
+ * tools/reprobuild certify regenerate the manifests + acceptance suite
+ * tools/reprobuild certify --no-verify regenerate the manifests only
+ * revert the change to nix/ that moved it
+ '';
+
+ # Package sets a row can name besides nixpkgs' own. The armv7 tarball
+ # is for the Raspberry Pi 2 and later, and every one of those has NEON
+ # and VFPv4 with 32 D registers; nixpkgs' armv7l-hf-multiplatform is
+ # Debian's VFPv3-D16 without NEON. The FPU is baked into gcc
+ # (--with-fpu), so this is a separate package set, not a flag.
+ releaseSets = {
+ pkgsCrossRaspberryPi = import inputs.nixpkgs {
+ localSystem = system;
+ crossSystem = lib.systems.examples.armv7l-hf-multiplatform // {
+ gcc = {
+ arch = "armv7-a";
+ fpu = "neon-vfpv4";
+ };
+ };
+ };
+ };
+
+ pkgsFor =
+ row:
+ lib.attrByPath (lib.splitString "." row.pkgsPath)
+ (throw "nix/release-rows: no package set ${row.pkgsPath}")
+ (pkgs // releaseSets);
+
+ # Unguarded: what certify reads to regenerate the manifests, and what
+ # the guards compare against.
+ rawCln =
+ row:
+ let
+ staticPkgs = pkgsFor row;
+ in
+ staticPkgs.callPackage ./default.nix {
+ inherit self config;
+ pkgs = staticPkgs;
+ postgresSupport = true;
+ release = true;
+ releaseArch = row.arch;
+ # Defaults for a bare `nix build`; the driver always overrides both.
+ # `.version` ends in a newline, which readFile keeps.
+ releaseVersion = lib.removeSuffix "\n" (builtins.readFile ../../.version);
+ releaseMtime =
+ let
+ d = self.lastModifiedDate;
+ in
+ "${builtins.substring 0 4 d}-${builtins.substring 4 2 d}-${builtins.substring 6 2 d}";
+ };
+ # the source zip is a release artifact too, so it is a
+ # derivation like the others -- built from the flake source, not from
+ # the host's working tree.
+ rawZip = pkgs.callPackage ./source-zip.nix {
+ releaseVersion = lib.removeSuffix "\n" (builtins.readFile ../../.version);
+ releaseMtime =
+ let
+ d = self.lastModifiedDate;
+ in
+ "${builtins.substring 0 4 d}-${builtins.substring 4 2 d}-${builtins.substring 6 2 d}";
+ };
+
+ rawVls =
+ row:
+ let
+ staticPkgs = pkgsFor row;
+ in
+ staticPkgs.callPackage ./vls.nix {
+ pkgs = staticPkgs;
+ releaseArch = row.arch;
+ };
+
+ # the signer daemon `remote_hsmd_socket` talks to, built only
+ # so the regtest smoke test has something to test against (46 runs it
+ # every release). Never shipped, never signed, never in a manifest --
+ # and built from the same pin, vendor dir and toolchain as the artifact,
+ # so the pair under test is the pair released. Native row only: the
+ # test runs lightningd and bitcoind on the build machine.
+ rawVlsd =
+ let
+ staticPkgs = pkgs.pkgsStatic;
+ in
+ staticPkgs.callPackage ./vls.nix {
+ pkgs = staticPkgs;
+ releaseArch = "amd64";
+ vlsBinary = "vlsd";
+ vlsCargoPackage = "vlsd";
+ };
+
+ # Guarded: the release attributes refuse to evaluate on either guard.
+ # Only here -- `nix build .#cln`, the dev shells and the other checks
+ # are untouched.
+ guard =
+ name: drv:
+ lib.throwIfNot revOk revMsg (lib.throwIfNot (manifestOk name drv) (manifestMsg name) drv);
+
+ releaseSystem = system == "x86_64-linux";
+ perRow = f: lib.listToAttrs (lib.concatMap f rows);
+ in
{
packages = rec {
# This package depends on git submodules so use a shell command like 'nix build .?submodules=1'.
@@ -12,6 +177,44 @@
};
rust = pkgs.callPackage ./rust.nix { craneLib = pkgs.craneLib; };
default = cln;
+ }
+ // lib.optionalAttrs releaseSystem {
+ # The zip carries no per-row input manifest (its only inputs are the
+ # source and `zip` itself), but it is still refused on an uncertified
+ # nixpkgs, like every other signed artifact.
+ cln-release-source-zip = lib.throwIfNot revOk revMsg rawZip;
+ vls-test-vlsd = rawVlsd;
+ }
+ // lib.optionalAttrs releaseSystem (
+ perRow (row: [
+ (lib.nameValuePair "cln-release-static-${row.arch}" (guard "cln-${row.arch}" (rawCln row)))
+ (lib.nameValuePair "vls-release-static-${row.arch}" (guard "vls-${row.arch}" (rawVls row)))
+ ])
+ );
+
+ # What tools/reprobuild reads without building anything: the certified
+ # and locked revs, and the manifests as the derivations would write
+ # them (`certify` copies these into nix/release-manifests/).
+ legacyPackages.release = lib.optionalAttrs releaseSystem {
+ inherit certifiedRev lockedRev;
+ manifests = perRow (row: [
+ (lib.nameValuePair "cln-${row.arch}" (rawCln row).releaseManifest)
+ (lib.nameValuePair "vls-${row.arch}" (rawVls row).releaseManifest)
+ ]);
+ };
+
+ # The tripwires: evaluation fails in milliseconds, in the commit that
+ # moved flake.lock or the release derivation, not on release day.
+ checks = lib.optionalAttrs releaseSystem {
+ release-nixpkgs-certified = lib.throwIfNot revOk revMsg (
+ pkgs.runCommand "release-nixpkgs-certified" { } "touch $out"
+ );
+ release-manifests = lib.foldl' (
+ acc: row:
+ lib.throwIfNot (manifestOk "cln-${row.arch}" (rawCln row)) (manifestMsg "cln-${row.arch}") (
+ lib.throwIfNot (manifestOk "vls-${row.arch}" (rawVls row)) (manifestMsg "vls-${row.arch}") acc
+ )
+ ) (pkgs.runCommand "release-manifests" { } "touch $out") rows;
};
};
}
diff --git a/nix/pkgs/rust-bin.nix b/nix/pkgs/rust-bin.nix
new file mode 100644
index 000000000000..350ced2edaf0
--- /dev/null
+++ b/nix/pkgs/rust-bin.nix
@@ -0,0 +1,139 @@
+# The release's Rust toolchain: the Rust project's own release binaries.
+#
+# nixpkgs builds rustc from source for any package set Hydra does not
+# cover, and `pkgsCross..pkgsStatic` is one of them: every arm64 and
+# armhf build compiled a full rustc first. The upstream dist tarballs are
+# the same compiler for all three rows (one host rustc/cargo, one rust-std
+# per target), fixed-output, and are what nixpkgs' own rustc bootstraps
+# from anyway, so they add no trust the release did not already extend.
+#
+# Bumping: take the sha256s from
+# https://static.rust-lang.org/dist/channel-rust-.toml
+# after checking its .asc against the Rust release key.
+{ lib, pkgs }:
+let
+ inherit (pkgs) stdenv;
+ bp = pkgs.buildPackages;
+
+ version = "1.98.1";
+ date = "2026-09-03";
+ commit = "48a229ceaefd4985c50990b14116b6d856af0985";
+ sha256 = {
+ "rustc-x86_64-unknown-linux-gnu" =
+ "e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4";
+ "cargo-x86_64-unknown-linux-gnu" =
+ "ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4";
+ "rust-std-x86_64-unknown-linux-gnu" =
+ "fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561";
+ "rust-std-x86_64-unknown-linux-musl" =
+ "bd9f35880de21dab0e387e84009c00001ae7836a4ba565cb16823f13f75f325f";
+ "rust-std-aarch64-unknown-linux-musl" =
+ "7e0ad2e67817f224b7a6331e48d6397303fc050edaccf81784ed786ffddc884a";
+ "rust-std-armv7-unknown-linux-musleabihf" =
+ "dd0efa4210a6da6350a6b05d8ffa43eae4baecf2397cc00a3b028bdf56cdb1ce";
+ };
+
+ buildTarget = stdenv.buildPlatform.rust.rustcTarget;
+ target = stdenv.hostPlatform.rust.rustcTarget;
+
+ component =
+ name: t:
+ let
+ key = "${name}-${t}";
+ in
+ bp.fetchurl {
+ url = "https://static.rust-lang.org/dist/${date}/${name}-${version}-${t}.tar.xz";
+ sha256 = sha256.${key} or (throw "nix/pkgs/rust-bin.nix: no sha256 for ${key}");
+ };
+
+ componentKeys = lib.unique [
+ [
+ "rustc"
+ buildTarget
+ ]
+ [
+ "cargo"
+ buildTarget
+ ]
+ [
+ "rust-std"
+ buildTarget
+ ]
+ [
+ "rust-std"
+ target
+ ]
+ ];
+ components = map (k: component (builtins.elemAt k 0) (builtins.elemAt k 1)) componentKeys;
+
+ # The musl objects rustc links self-contained are swapped for the row's
+ # own, as nixpkgs' static rustc does: the C code and the Rust plugins then
+ # link one libc, and upstream's (an older musl) never reaches a binary.
+ # crtbegin/crtend and libunwind stay upstream's; the row's musl has none.
+ musl = stdenv.cc.libc;
+ muslObjects = [
+ "crt1.o"
+ "crti.o"
+ "crtn.o"
+ "libc.a"
+ "rcrt1.o"
+ "Scrt1.o"
+ ];
+in
+bp.stdenv.mkDerivation {
+ pname = "rust-bin-${target}";
+ inherit version;
+ srcs = components;
+ sourceRoot = ".";
+
+ nativeBuildInputs = [ bp.autoPatchelfHook ];
+ buildInputs = [
+ bp.stdenv.cc.cc.lib
+ bp.zlib
+ ];
+
+ dontConfigure = true;
+ dontBuild = true;
+ # Stripping damages the .rmeta sections inside rlibs.
+ dontStrip = true;
+
+ installPhase = ''
+ runHook preInstall
+ for d in */; do
+ bash "$d/install.sh" --prefix=$out --disable-ldconfig
+ done
+ rm -f $out/lib/rustlib/install.log $out/lib/rustlib/uninstall.sh
+
+ sc=$out/lib/rustlib/${target}/lib/self-contained
+ if [ -d "$sc" ]; then
+ for o in ${lib.concatStringsSep " " muslObjects}; do
+ [ -e "$sc/$o" ] || { echo "rust-bin: upstream has no $sc/$o" >&2; exit 1; }
+ install -m 0444 ${musl}/lib/$o "$sc/$o"
+ done
+ fi
+ runHook postInstall
+ '';
+
+ passthru = {
+ inherit date commit;
+ # For the input manifests: every fetched component, by hash.
+ manifestLines = [
+ "rust-dist ${version} ${date} ${commit}"
+ ]
+ ++ map (
+ k:
+ let
+ key = "${builtins.elemAt k 0}-${builtins.elemAt k 1}";
+ in
+ "rust-dist ${key} ${sha256.${key}}"
+ ) componentKeys
+ ++ [ "rust-dist musl-objects ${lib.getName musl} ${lib.getVersion musl}" ];
+ };
+
+ meta = {
+ description = "Rust ${version} upstream release binaries for ${target}";
+ homepage = "https://www.rust-lang.org/";
+ sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
+ platforms = [ "x86_64-linux" ];
+ };
+}
diff --git a/nix/pkgs/source-zip.nix b/nix/pkgs/source-zip.nix
new file mode 100644
index 000000000000..5a868628bbab
--- /dev/null
+++ b/nix/pkgs/source-zip.nix
@@ -0,0 +1,72 @@
+# the source zip, as a derivation.
+#
+# The tarball is a Nix output so `nix build --rebuild` covers the
+# bytes that are signed. The zip is signed too, and it was the last artifact
+# still assembled on the host -- out of `git ls-files --recurse-submodules` of
+# the *working tree*, which is not the rev the manifest names. A co-signer
+# standing on a different commit therefore rebuilt a different zip and looked
+# like a reproducibility failure (caught by `verify` on 2026-09-23).
+#
+# Built from the flake source, so its content is exactly the tree at that rev
+# with its submodules, and nothing on the host (zip version, locale, umask)
+# sits inside the signed bytes.
+{
+ lib,
+ stdenvNoCC,
+ zip,
+ releaseVersion,
+ releaseMtime,
+}:
+stdenvNoCC.mkDerivation {
+ pname = "clightning-source-zip";
+ version = releaseVersion;
+ src = ../../.;
+
+ nativeBuildInputs = [ zip ];
+
+ dontConfigure = true;
+ dontBuild = true;
+ dontFixup = true;
+
+ # Same rename as the tarball derivation: the unpacked directory
+ # is named after the source store path, and that name would otherwise be the
+ # top-level directory inside the zip.
+ postUnpack = ''
+ mv -- "$sourceRoot" source
+ export sourceRoot=source
+ '';
+
+ installPhase = ''
+ runHook preInstall
+
+ dir=clightning-${releaseVersion}
+ mkdir -p "$NIX_BUILD_TOP/stage/$dir"
+ cp -a . "$NIX_BUILD_TOP/stage/$dir/"
+ cd "$NIX_BUILD_TOP/stage"
+
+ # zip records a date on directories as well as files, and reads it in
+ # *local* time -- TZ is fixed here so the recorded stamps do not follow
+ # the builder's zone. Modes are normalised for the same reason the
+ # tarball normalises them: the store is read-only, and a release should
+ # not hand anyone a tree they cannot write to.
+ export TZ=UTC
+ find "$dir" -print0 | xargs -0r touch --no-dereference --date="${releaseMtime}"
+ find "$dir" -type d -print0 | xargs -0r chmod 755
+ find "$dir" -type f -perm -100 -print0 | xargs -0r chmod 755
+ find "$dir" -type f ! -perm -100 -print0 | xargs -0r chmod 644
+
+ # -X drops uid/gid and extra timestamp fields; the entry order is fixed by
+ # feeding a sorted list rather than letting `zip -r` walk the tree, which
+ # has no defined order.
+ find "$dir" | LC_ALL=C sort > "$NIX_BUILD_TOP/filelist"
+ mkdir -p $out
+ zip -q -X -@ "$out/clightning-${releaseVersion}.zip" < "$NIX_BUILD_TOP/filelist"
+
+ runHook postInstall
+ '';
+
+ meta = with lib; {
+ description = "Core Lightning source zip for a release";
+ license = licenses.mit;
+ };
+}
diff --git a/nix/pkgs/static-pie.nix b/nix/pkgs/static-pie.nix
new file mode 100644
index 000000000000..81abc773b235
--- /dev/null
+++ b/nix/pkgs/static-pie.nix
@@ -0,0 +1,190 @@
+# How a release binary is linked: statically, as position-independent code.
+#
+# This is the shared half of one recipe, not a layer or an abstraction. It is
+# its own file for exactly one reason: both `default.nix` (Core Lightning) and
+# `vls.nix` (the VLS signer) import it, and the two must link identically. VLS
+# is a separate upstream project, but it is the same rustc, the same musl
+# targets and the same 32-bit ARM gcc gap, so a second copy of what follows
+# would be a second thing to keep in step.
+#
+# Everything here is a workaround for one of two upstream gaps:
+#
+# * nixpkgs' gcc cannot link static-pie for 32-bit ARM, and fails quietly;
+# * rustc will not emit static-pie for the ARM musl targets at all.
+#
+# Each is closed by a generated wrapper script that rewrites the compiler's
+# arguments, because what has to change is argument *order*, which a flag
+# cannot express. Both are commented where they are defined.
+#
+# `pkgs` is the row's package set -- pkgsStatic, or
+# pkgsCross..pkgsStatic -- so every value below is per-row.
+#
+# Exports: arm32, extraObjsManifest, staticPieFlags, staticPieCc, releaseCc,
+# rustStaticPieCc, rustTargetFlags and noRpathEnv, all consumed by
+# default.nix and vls.nix.
+{ pkgs, lib }:
+let
+ inherit (pkgs) stdenv;
+ bp = pkgs.buildPackages;
+in
+rec {
+ # The first of the two gaps: gcc on the 32-bit ARM row.
+ #
+ # nixpkgs' gcc 14.3.0 cannot link static-pie for 32-bit arm, and fails
+ # *quietly*: `-static-pie` produces a **dynamically** linked PIE asking for
+ # /lib/ld-musl-armhf.so.1, and `-static -pie` produces a static ET_EXEC.
+ # The same wrapper on aarch64 gives a real static-pie, so this is gcc's ARM
+ # spec dropping the PIE in a static link, not nixpkgs. ld is perfectly
+ # able: the recipe below (`-Wl,-pie` straight to the linker, no dynamic
+ # linker, and the PIE crt objects named explicitly, since `-static` makes
+ # gcc choose the non-PIE crt1.o/crtbeginT.o pair) yields ET_DYN, no INTERP,
+ # and runs under qemu-arm. Verified on a one-line program before being
+ # committed to a build.
+ #
+ # Static-pie on every row is what this preserves. The alternatives were to
+ # drop the 32-bit ARM row, or to ship it without ASLR.
+ arm32 = stdenv.hostPlatform.isAarch32;
+ # rustc ignores the row's gcc.fpu: its armv7 musl target is VFPv3 with
+ # NEON off, yet LLVM still uses D16-D31, so neither the Debian nor the
+ # Raspberry Pi baseline came out. Say it explicitly, from the same fpu.
+ # Leading space, so the other rows' RUSTFLAGS stay byte-identical.
+ rustTargetFlags =
+ if !arm32 then
+ ""
+ else
+ {
+ "neon-vfpv4" = " -C target-feature=+vfp4,+neon";
+ }
+ .${stdenv.hostPlatform.gcc.fpu or ""}
+ or (throw "static-pie.nix: no rustc flags for this 32-bit ARM fpu");
+ # musl's malloc made the static lightningd 16% slower than a glibc build,
+ # most of it in sqlite3_expanded_sql's alloc/copy churn. The object, not
+ # libmimalloc.a: an archive member is only pulled for an undefined symbol,
+ # so libc.a could win the race and musl's malloc would ship silently.
+ mimalloc = pkgs.mimalloc;
+ # musl's x86_64 memcpy is `rep movsq` with byte loops either side, ~5x
+ # slower than LLVM libc's for the short copies sqlite's string building
+ # makes. The arm rows' musl memcpy is already an optimised one. memmove
+ # must come too: musl's calls `__memcpy_fwd`, which would pull in musl's
+ # memcpy.o and clash with ours. Built by clang, not the row's gcc: gcc's
+ # memmove came out 3-4x slower on large copies. Baseline x86-64 (SSE2),
+ # since a static binary has no ifunc to pick a wider one at run time.
+ llvmLibc = bp.llvmPackages.libc;
+ llvmMem = bp.runCommand "llvm-libc-memcpy-${llvmLibc.version}" { } ''
+ clang=${bp.llvmPackages.clang-unwrapped}/bin/clang++
+ mkdir -p $out
+ for f in memcpy memmove; do
+ $clang --target=${stdenv.hostPlatform.config} -march=x86-64 -std=c++17 -O2 \
+ -fPIC -ffreestanding -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector \
+ -nostdinc -isystem "$($clang -print-resource-dir)/include" \
+ -DLIBC_NAMESPACE=__llvm_libc_cln -DLIBC_COPT_PUBLIC_PACKAGING \
+ -I${llvmLibc.src}/libc -c ${llvmLibc.src}/libc/src/string/$f.cpp -o $out/$f.o
+ done
+ install -m644 ${llvmLibc.src}/libc/LICENSE.TXT $out/
+ '';
+ extraObjs = [
+ "${mimalloc}/lib/mimalloc.o"
+ ]
+ ++ lib.optionals stdenv.hostPlatform.isx86_64 [
+ "${llvmMem}/memcpy.o"
+ "${llvmMem}/memmove.o"
+ ];
+ extraObjsArgs = lib.concatStringsSep " " extraObjs;
+ # Listed in the input manifests next to the toolchain.
+ extraObjsManifest = [
+ "mimalloc ${mimalloc.version}"
+ ]
+ ++ lib.optional stdenv.hostPlatform.isx86_64 "llvm-libc memcpy+memmove ${llvmLibc.version}";
+ gccLibDir = "${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${stdenv.cc.cc.version}";
+ muslLibDir = "${stdenv.cc.libc}/lib";
+ # How "link this statically, as a PIE" is spelled for this row.
+ staticPieFlags = if arm32 then "-static -Wl,-pie -Wl,--no-dynamic-linker" else "-static-pie";
+ # On arm32 the crt objects must also be named, and *in order* -- crtendS.o
+ # and crtn.o belong after the user's objects, which a flag string cannot
+ # express. Hence a wrapper, used as CC only on that row: the other two
+ # rows keep `cc -static-pie` verbatim, so their proven bytes do not move.
+ staticPieCc = bp.writeShellScriptBin "${stdenv.cc.targetPrefix}static-pie-cc" ''
+ # Only a *link* gets this treatment. A compile-only or -shared
+ # invocation passes straight through -- CLN's Makefile uses $(CC) for
+ # both, and the crt objects would break a `-c`.
+ for a in "$@"; do
+ case "$a" in
+ -c | -E | -S | -M | -MM | -MD | -shared)
+ exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc "$@"
+ ;;
+ esac
+ done
+ exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc \
+ ${staticPieFlags} -nostartfiles \
+ ${muslLibDir}/rcrt1.o ${muslLibDir}/crti.o ${gccLibDir}/crtbeginS.o \
+ ${extraObjsArgs} "$@" \
+ ${gccLibDir}/crtendS.o ${muslLibDir}/crtn.o
+ '';
+ # What configure is handed as the compiler for the release link.
+ releaseCc =
+ if arm32 then
+ "${staticPieCc}/bin/${stdenv.cc.targetPrefix}static-pie-cc"
+ else
+ # -Wl, so a compile-only invocation ignores the objects instead of warning.
+ "${stdenv.cc.targetPrefix}cc ${staticPieFlags} ${
+ lib.concatMapStringsSep " " (o: "-Wl,${o}") extraObjs
+ }";
+ # The second gap: rustc.
+ #
+ # rustc links a crt-static musl target with plain `-static` unless the
+ # target spec claims static-pie support, which x86_64-unknown-linux-musl
+ # does and the aarch64/armv7 musl targets still do not. The first arm64
+ # artifact said it plainly: 33 C binaries ET_DYN, the seven Rust plugins
+ # ET_EXEC, where the release wants static-pie on all of them. `-static`
+ # also wins gcc's crt selection, so it has to be *removed* from the link
+ # rather than overridden.
+ #
+ # nixpkgs' link wrapper classifies a link as `static-pie` only if it sees
+ # the literal `-static-pie` flag, and only then does it filter rpaths.
+ # The arm32 spelling above (`-static -Wl,-pie`) is classified `static`, so
+ # the wrapper kept stdenv's self-rpath (`-rpath $out/lib`, from
+ # NIX_LDFLAGS) and added one for the musl lib dir -- a DT_RUNPATH naming
+ # the *output store path* in every Rust plugin and in VLS. Harmless at
+ # run time, since the binary is static, but it made those bytes a function
+ # of $out and so of the tree -- exactly the class of difference the two-tree
+ # probe exists to catch, and one an amd64-only probe cannot see. These go
+ # in the derivation's env on the 32-bit ARM row only, so the other rows'
+ # derivations are untouched.
+ noRpathEnv = lib.optionalAttrs arm32 {
+ NIX_NO_SELF_RPATH = "1";
+ "NIX_DONT_SET_RPATH_${stdenv.cc.suffixSalt}" = "1";
+ };
+
+ rustStaticPieCc = bp.writeShellScriptBin "${stdenv.cc.targetPrefix}rust-cc" ''
+ # A `-shared` link passes through untouched: cargo links proc macros
+ # and cdylibs through a linker too, and a wrapper that forced a static
+ # link onto those cost a whole build. The name matters as
+ # well -- a wrapper whose name ends in `-ld` makes rustc switch to its
+ # raw-ld flavour and emit a different link line entirely.
+ for a in "$@"; do
+ if [ "$a" = -shared ]; then
+ exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc "$@"
+ fi
+ done
+ # Dropping `-static` is not enough, as the first arm64 artifact showed:
+ # rustc links a musl target *self-contained*, passing the crt objects
+ # from its own `rustlib//lib/self-contained` dir by path. Those
+ # are the non-PIE pair, so the link stays ET_EXEC however the driver is
+ # invoked. The objects themselves are PIC, so the fix is to rewrite the
+ # link into the static-pie one --
+ # crt1.o -> rcrt1.o, crtbegin.o -> crtbeginS.o, `-static`/`-no-pie`
+ # dropped, `-static-pie` added. (Both replacement objects ship in
+ # nixpkgs' cross rustc, checked before relying on them.)
+ args=()
+ for a in "$@"; do
+ case "$a" in
+ -static | -no-pie) ;;
+ */crt1.o) args+=("''${a%crt1.o}rcrt1.o") ;;
+ */crtbegin.o) args+=("''${a%crtbegin.o}crtbeginS.o") ;;
+ *) args+=("$a") ;;
+ esac
+ done
+ # Rust's default System allocator calls malloc, so this covers it too.
+ exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc ${staticPieFlags} ${extraObjsArgs} "''${args[@]}"
+ '';
+}
diff --git a/nix/pkgs/vls.nix b/nix/pkgs/vls.nix
new file mode 100644
index 000000000000..efef33da0da0
--- /dev/null
+++ b/nix/pkgs/vls.nix
@@ -0,0 +1,369 @@
+# VLS's `remote_hsmd_socket`, one static
+# binary per release row.
+#
+# built this as a `vls` *pseudo-distro*: hooks only
+# (`contrib/reprobuild/vls/build.sh` + `pins`), no image of its own,
+# borrowing the Alpine static builder's sysroot, its `-clang`
+# wrappers and its pinned protoc. The Nix switch removed the thing it
+# borrowed.
+#
+# What replaces it: a derivation generated over the same
+# rows as CLN, so `nix build --rebuild` covers the bytes that are *signed*,
+# the strip is asserted in-derivation, and the per-arch cargo
+# target comes from the package set rather than a hand-written `arches` row.
+#
+# The one thing that makes this different from a fourth row of CLN: VLS is a
+# **third-party repository at a pinned commit**, so it has its own source and
+# its own crate closure. Both are fixed-output derivations -- the network
+# rule is satisfied the same way 35 satisfied it for cargo, by
+# hashing before the build rather than trusting the build not to fetch.
+{
+ lib,
+ pkgs,
+ # the row's arch token from nix/release-rows; names the artifact.
+ releaseArch,
+ # which binary of the VLS workspace to build.
+ #
+ # `remote_hsmd_socket` is the released artifact. `vlsd` is
+ # the **signer daemon it talks to**, and it is built only so the release can
+ # be *tested*: `remote_hsmd_socket` is CLN's hsmd replacement and does
+ # nothing on its own but listen on port 7701 for vlsd to connect, so the
+ # regtest smoke test -- which 46 runs every release -- has no signer without
+ # it. A test binary is never installed under a release name, never listed
+ # in a manifest and never signed; it shares this file (and so the pin, the
+ # vendor dir and the toolchain) precisely so the thing under test is built
+ # from the same inputs as the thing shipped.
+ # NB the `vls` prefix: `callPackage` supplies any argument whose name exists
+ # in nixpkgs, and nixpkgs has a package called `binary` (`binary-5.3`), so a
+ # plain `binary ? "remote_hsmd_socket"` default was silently replaced by that
+ # derivation -- surfacing as an unsupported gobject-introspection four levels
+ # into GTK, while building the *released* signer. (`cargoPackage` is free
+ # today; it is prefixed anyway, because the next name might not be.)
+ vlsBinary ? "remote_hsmd_socket",
+ vlsCargoPackage ? "vls-proxy",
+}:
+let
+ inherit (pkgs) stdenv;
+ bp = pkgs.buildPackages;
+ inherit (import ./static-pie.nix { inherit pkgs lib; }) rustStaticPieCc rustTargetFlags noRpathEnv extraObjsManifest;
+ rustBin = import ./rust-bin.nix { inherit pkgs lib; };
+
+ # --- the pin -------------
+ #
+ # Which VLS version ships is a release decision with its own review
+ # cadence, not a toolchain refresh: in-tree, the rev can only change by
+ # someone editing this block, and `nix flake update` cannot move it.
+ #
+ # `rev` is the *peeled* v0.14.0 tag (the annotated tag is unsigned --
+ # research 14 -- so the commit is the pin, not the tag), and it is the same
+ # commit built. `vendorHash` is the crate closure: the human
+ # chose a single fixed-output vendor derivation over an in-tree copy of
+ # VLS's Cargo.lock on 2026-09-13. Both hashes belong in 's input
+ # manifest, `vendorHash` especially -- it is the one release input here
+ # that nixpkgs' own vendoring code can move without any change of ours.
+ pin = {
+ url = "https://gitlab.com/lightning-signer/validating-lightning-signer.git";
+ version = "v0.14.0";
+ rev = "9c0fd05c946d549f643d3e1833d8663168d2b0db";
+ hash = "sha256-gKTkOOaj7EGunJF/xi7lW5dNNRvzWoj0nKuEIv3+TUk=";
+ vendorHash = "sha256-fxPAZV2uSqN4RlWqTZLDHwsl0/RZdhPcg1fhmiNtgQo=";
+ };
+
+ src = bp.fetchgit {
+ inherit (pin) url rev hash;
+ };
+
+ # --- what the binary says it is --------------------------------------
+ #
+ # `vls-util/build.rs` runs `git describe` and bakes the answer into
+ # `GIT_DESC`, which is what `remote_hsmd_socket --version` prints and what
+ # goes out as the OTLP service version. The Alpine hook did a real `git
+ # clone`, so it got a real string; a fixed-output source fetch has no
+ # `.git`, and the build.rs falls back to the literal `git-desc-failed` --
+ # deterministic, so reproducibility is unaffected, but every VLS we ever
+ # ship would refuse to say which one it is.
+ #
+ # So: answer the one question build.rs asks, from the pin itself. Not a
+ # patch to third-party source, and nothing else in the built set shells out
+ # to git (only vls-util does; vls-signer-stm32 is excluded from the
+ # workspace). `-0-g` is the `--long` form for a commit that *is* the tag.
+ gitDesc = "${pin.version}-0-g${builtins.substring 0 12 pin.rev}";
+ gitShim = bp.writeShellScriptBin "git" ''
+ if [ "''${1:-}" = describe ]; then
+ echo "${gitDesc}"
+ exit 0
+ fi
+ echo "vls: unexpected git invocation: $*" >&2
+ exit 1
+ '';
+
+ rustTarget = stdenv.hostPlatform.rust.rustcTarget;
+ rustTargetEnv = lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] rustTarget);
+ rustTargetVar = builtins.replaceStrings [ "-" ] [ "_" ] rustTarget;
+
+ # the crates.io 403, one layer
+ # over. `fetchCargoVendor` does not fetch crates with `fetchurl` at all,
+ # so the User-Agent overlay does not reach it: it runs a python
+ # `requests` script (`fetch-cargo-vendor-util`) that sets no UA at all, and
+ # crates.io refuses `python-requests/` exactly as it refuses
+ # `curl/`. Every crate 404s -- 403s -- before the build starts.
+ #
+ # The script is a `let` binding inside nixpkgs' fetch-cargo-vendor.nix, so
+ # there is nothing to `.override`; the only seam is the `writers` call that
+ # builds it. Doing that as a *flake overlay* was the first attempt and is
+ # a trap worth recording: `fetchCargoVendor`'s outer derivation is an
+ # ordinary runCommand that depends on the script, so patching `writers`
+ # globally moves the derivation of every nixpkgs package that vendors
+ # crates -- including the release toolchain (`x86_64-unknown-linux-musl-
+ # cargo` went from 35rali2m... to x3yxsnpd...). That is a
+ # distribution-motivated change silently moving CLN's release bytes, which
+ # is the exact failure class 's guards exist to catch.
+ #
+ # So the patch is scoped to *this* call: our own instance of nixpkgs'
+ # fetcher, with a patched `writers` passed in. Nothing outside VLS sees
+ # it, and the vendor dir is fixed-output anyway, so the release bytes are
+ # pinned by `vendorHash` either way.
+ #
+ # Both seams -- the internal file path and the exact line replaced -- can
+ # move when the certified nixpkgs rev moves, and `replaceStrings` fails
+ # silently: it changes nothing, and the fetch then 403s far from here.
+ # So a replacement that did not happen is an evaluation error.
+ uaNeedle = " session = requests.Session()\n";
+ fetchCargoVendor = bp.callPackage "${pkgs.path}/pkgs/build-support/rust/fetch-cargo-vendor.nix" {
+ writers = bp.writers // {
+ writePython3Bin =
+ name: args: text:
+ bp.writers.writePython3Bin name args (
+ if name == "fetch-cargo-vendor-util" then
+ assert lib.assertMsg (lib.hasInfix uaNeedle text) ''
+ nix/pkgs/vls.nix: nixpkgs' fetch-cargo-vendor-util no longer contains
+ the line the User-Agent patch replaces; crates.io would 403 the fetch.
+ Re-check the patch against the certified nixpkgs rev.
+ '';
+ builtins.replaceStrings
+ [ uaNeedle ]
+ [
+ "${uaNeedle} session.headers.update({\"User-Agent\": \"Nixpkgs fetch-cargo-vendor (Core Lightning reprobuild)\"})\n"
+ ]
+ text
+ else
+ text
+ );
+ };
+ };
+
+ # The crate closure, as one fixed-output derivation (the human's choice on
+ # 2026-09-13 over an in-tree copy of VLS's Cargo.lock). It emits a
+ # `.cargo/config.toml` with a `@vendor@` placeholder, which is all cargo
+ # needs to be fully offline -- the network rule again: hashed
+ # before the build, not fetched during it.
+ cargoVendor = fetchCargoVendor {
+ inherit src;
+ hash = pin.vendorHash;
+ };
+in
+stdenv.mkDerivation {
+ pname = if vlsBinary == "remote_hsmd_socket" then "vls" else "vls-${vlsBinary}";
+ version = lib.removePrefix "v" pin.version;
+ inherit src;
+
+ # NOT `rustPlatform.buildRustPackage`, which is the obvious way to write
+ # this and the wrong one. Its `rustPlatform` resolves to the *row's* rust
+ # toolchain, so the amd64 row started compiling an
+ # `x86_64-unknown-linux-musl-rustc` and cargo from rustc-1.89.0-src -- a
+ # toolchain built here, inside the inputs of a signed artifact, where CLN
+ # gets a substituted one (measured exactly this asymmetry between
+ # the native and cross rows). CLN's release path instead uses the
+ # *build-platform* cargo/rustc and names the target with
+ # CARGO_BUILD_TARGET; VLS does the same, so both released binaries come
+ # out of one toolchain. buildRustPackage's hooks are no loss: its
+ # cargo-auditable default embeds a `.dep-v0` SBOM section that
+ # `strip --strip-all` deletes again, and its install hook would copy
+ # every binary in the workspace.
+ nativeBuildInputs = [
+ rustBin
+ # `vlsd` and `lightning-storage-server` drive prost/tonic codegen.
+ bp.protobuf
+ gitShim
+ # Same class as CC_FOR_BUILD in CLN's own derivation: cargo
+ # compiles build scripts and proc macros *for the build machine* and asks
+ # rustc for its default linker, which is plain `cc`. A cross (or
+ # pkgsStatic) stdenv only puts `-gcc` on PATH.
+ bp.stdenv.cc
+ ];
+
+ dontConfigure = true;
+ enableParallelBuilding = true;
+
+ buildPhase = ''
+ runHook preBuild
+
+ export SOURCE_DATE_EPOCH LANG=C LC_ALL=C TZ=UTC
+ export PROTOC=${bp.protobuf}/bin/protoc
+ export PROTOC_INCLUDE=${bp.protobuf}/include
+
+ # Offline cargo, against the vendored crates.
+ export CARGO_HOME=$NIX_BUILD_TOP/cargo-home
+ mkdir -p $CARGO_HOME
+ sed "s|@vendor@|${cargoVendor}|g" ${cargoVendor}/.cargo/config.toml > $CARGO_HOME/config.toml
+
+ export CARGO_BUILD_TARGET=${rustTarget}
+
+ # the wrapper: rustc still links a crt-static musl target
+ # non-PIE *and* self-contained at 1.89.0, so the link line is rewritten
+ # (crt1.o -> rcrt1.o, crtbegin.o -> crtbeginS.o, `-static` dropped).
+ # The release wants static-pie on every shipped ELF, VLS included.
+ export CARGO_TARGET_${rustTargetEnv}_LINKER=${rustStaticPieCc}/bin/${stdenv.cc.targetPrefix}rust-cc
+
+ # nixpkgs' toolchain emits no build-id; the release keeps one so a
+ # stripped crash report stays resolvable. The remap is belt and braces
+ # here -- unlike CLN's, this source is a fixed-output store path, the
+ # same on every machine -- but it also makes the build directory a
+ # non-input, which is exactly what watched go wrong.
+ # the vendor dir is remapped too, as did for CLN.
+ # Without it the binary carries ~500 panic-location strings naming
+ # `-cargo-deps-vendor/...`, so the shipped bytes track a store path
+ # that nixpkgs' own vendoring code can move with no change of ours -- the
+ # one input 38 singled out as movable from outside. rustc applies the
+ # *last* matching map, so the general one stays first.
+ export CARGO_TARGET_${rustTargetEnv}_RUSTFLAGS="--remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix=${cargoVendor}=/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1${rustTargetFlags}"
+
+ # VLS pulls in C through cc-rs (secp256k1-sys and friends), which reads
+ # these rather than the stdenv's exported CC. The Alpine hook set the
+ # same pair by hand against its `arches` row; here the row supplies them.
+ export CC_${rustTargetVar}=${stdenv.cc.targetPrefix}cc
+ export AR_${rustTargetVar}=${stdenv.cc.targetPrefix}ar
+
+ # the second silent hazard: NIX_CFLAGS_LINK is unsalted, so pkgsStatic's
+ # appended `-static` also reaches the *build-platform* cc that compiles
+ # cargo's build scripts and proc macros. The static link belongs on the
+ # target compiler alone (it is in the wrapper above).
+ export NIX_CFLAGS_LINK="''${NIX_CFLAGS_LINK//-static/}"
+
+ # the rule releases `remote_hsmd_socket` and nothing else; the
+ # workspace also holds remote_hsmd_serial, decode-vls, vlsd and vls-cli.
+ # Default features (grpc, main, debug), which is what built.
+ cargo build --offline --locked --release --jobs "$NIX_BUILD_CORES" \
+ -p ${vlsCargoPackage} --bin ${vlsBinary}
+
+ runHook postBuild
+ '';
+
+ installPhase = ''
+ runHook preInstall
+ # /s10: a *released* binary's output is the artifact itself, under
+ # its release name (remote_hsmd_socket--, ).
+ # A test binary goes in bin/ under its own name, so nothing can mistake it
+ # for something a manifest should list.
+ ${
+ if vlsBinary == "remote_hsmd_socket" then
+ ''
+ install -Dm755 target/${rustTarget}/release/${vlsBinary} \
+ $out/${vlsBinary}-${pin.version}-${releaseArch}''
+ else
+ ''install -Dm755 target/${rustTarget}/release/${vlsBinary} $out/bin/${vlsBinary}''
+ }
+ runHook postInstall
+ '';
+
+ # Nothing static needs patchelf, and fixupPhase runs it *after* the strip
+ # below -- an uncontrolled rewrite of the exact bytes the manifest signs.
+ dontPatchELF = true;
+
+ # see `noRpathEnv` in static-pie.nix (arm32 only).
+ env = noRpathEnv;
+
+ # Stripped, asserted rather than assumed, by the same recipe Core Lightning's
+ # derivation uses: the two must ship the same way, and an assertion that fails
+ # the build is the only version of this that cannot degrade quietly.
+ postInstall = ''
+ strip_one() {
+ ${stdenv.cc.targetPrefix}strip --strip-all --preserve-dates "$1" \
+ || { echo "strip failed on $1" >&2; exit 1; }
+ }
+ find $out -type f -print0 | while IFS= read -r -d "" fp; do
+ case "$(head -c 4 "$fp" | od -An -tx1 | tr -d " \n")" in
+ 7f454c46) strip_one "$fp" ;;
+ esac
+ done
+
+ fail=0
+ find $out -type f -print0 | while IFS= read -r -d "" fp; do
+ case "$(head -c 4 "$fp" | od -An -tx1 | tr -d " \n")" in
+ 7f454c46) ;;
+ *) continue ;;
+ esac
+ sections=$(${stdenv.cc.targetPrefix}readelf -SW "$fp" 2>/dev/null || true)
+ if printf '%s' "$sections" | grep -qE '\.symtab|\.debug_'; then
+ echo "STRIP CHECK FAILED: $fp still carries .symtab/.debug_*" >&2
+ fail=1
+ fi
+ if readelf_dyn=$(${stdenv.cc.targetPrefix}readelf -dlW "$fp" 2>/dev/null) \
+ && printf '%s' "$readelf_dyn" | grep -qE 'RPATH|RUNPATH|INTERP'; then
+ echo "STATIC CHECK FAILED: $fp has an rpath or interpreter" >&2
+ fail=1
+ fi
+ if ! printf '%s' "$sections" | grep -q '\.note\.gnu\.build-id'; then
+ echo "STRIP CHECK FAILED: $fp has no build-id" >&2
+ fail=1
+ fi
+ [ "$fail" = 0 ] || exit 1
+ done
+ '';
+
+ # (, the amendment): the VLS row's input manifest. The
+ # pin is its own identity -- a CLN tree change does not move these bytes --
+ # and `vendorHash` is the input nixpkgs' vendoring code can move with no
+ # change of ours, so both are spelled out here.
+ passthru.releaseManifest =
+ let
+ section = title: lines: "${title}\n" + lib.concatMapStrings (l: " ${l}\n") lines;
+ in
+ section "row" (
+ [
+ "arch ${releaseArch}"
+ "host ${stdenv.hostPlatform.config}"
+ ]
+ ++ lib.optional (stdenv.hostPlatform.gcc ? fpu) "fpu ${stdenv.hostPlatform.gcc.fpu}"
+ )
+ # See the same section in default.nix: the pin below says which VLS, and
+ # the flags say how, but neither covers the files that decide the link.
+ + section "recipe" [
+ "vls.nix ${builtins.hashFile "sha256" ./vls.nix}"
+ "static-pie.nix ${builtins.hashFile "sha256" ./static-pie.nix}"
+ "flake.nix ${builtins.hashFile "sha256" ../../flake.nix}"
+ "rust-bin.nix ${builtins.hashFile "sha256" ./rust-bin.nix}"
+ ]
+ + section "pin" [
+ "url ${pin.url}"
+ "version ${pin.version}"
+ "rev ${pin.rev}"
+ "hash ${pin.hash}"
+ "vendorHash ${pin.vendorHash}"
+ "git-desc ${gitDesc}"
+ ]
+ + section "toolchain" (
+ [
+ "gcc ${stdenv.cc.cc.version}"
+ "rustc ${rustBin.version}"
+ "protobuf ${bp.protobuf.version}"
+ ]
+ ++ extraObjsManifest
+ ++ rustBin.manifestLines
+ )
+ + section "flags" (
+ [
+ "cargo build --offline --locked --release -p vls-proxy --bin remote_hsmd_socket"
+ "strip --strip-all"
+ "rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1${rustTargetFlags}"
+ ]
+ ++ lib.mapAttrsToList (k: v: "env ${k}=${v}") noRpathEnv
+ );
+
+ meta = with lib; {
+ description = "VLS remote_hsmd_socket, statically linked for a CLN release";
+ homepage = "https://gitlab.com/lightning-signer/validating-lightning-signer";
+ license = licenses.asl20;
+ platforms = platforms.linux;
+ };
+}
diff --git a/nix/release-manifests/cln-amd64 b/nix/release-manifests/cln-amd64
new file mode 100644
index 000000000000..8e7f3974036c
--- /dev/null
+++ b/nix/release-manifests/cln-amd64
@@ -0,0 +1,56 @@
+row
+ arch amd64
+ host x86_64-unknown-linux-musl
+recipe
+ default.nix 4a6e23873f672eb4b6d5b787d5bbb3a3dd174bda0c2bf1bc47aca48f83479da0
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+ flake-module.nix 8fcc8fa3f96dc6c329acbc34f923da995e41df8b0003f9133604dd8a631d0518
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ python 3.14.7
+ mimalloc 3.5.3
+ llvm-libc memcpy+memmove 21.1.8
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-x86_64-unknown-linux-musl bd9f35880de21dab0e387e84009c00001ae7836a4ba565cb16823f13f75f325f
+ rust-dist musl-objects musl 1.2.6
+nativeBuildInputs
+ autoconf 2.73
+ automake 1.18.1
+ file 5.48
+ gcc-wrapper 16.2.0
+ gettext 1.0
+ git-minimal 2.55.0
+ jq 1.8.2
+ libtool 2.6.2
+ lowdown 3.0.1
+ protobuf 36.2
+ python3 3.14.7-env
+ rust-bin-x86_64-unknown-linux-musl 1.98.1
+ unzip 6.0
+ which 2.25
+ x86_64-unknown-linux-musl-pkgconf-wrapper 2.5.1
+buildInputs
+ gmp-with-cxx 6.3.0
+ jq 1.8.2
+ libpq 18.6
+ libsodium 1.0.22-unstable-2026-08-13
+ openssl 3.5.8
+ sqlite 3.53.3
+ zlib 1.3.2
+flags
+ configure --disable-valgrind --prefix=/usr/local COPTFLAGS=-O2
+ dontBuild true
+ dontPatchELF true
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1
+ env NIX_OUTPATH_USED_AS_RANDOM_SEED=cln-release
+ make RUST_PROFILE=release
+ make PIE_LDFLAGS=-static-pie
+ make TARGET=x86_64-unknown-linux-musl
+ make AR=x86_64-unknown-linux-musl-ar
diff --git a/nix/release-manifests/cln-arm64 b/nix/release-manifests/cln-arm64
new file mode 100644
index 000000000000..b37f79325615
--- /dev/null
+++ b/nix/release-manifests/cln-arm64
@@ -0,0 +1,58 @@
+row
+ arch arm64
+ host aarch64-unknown-linux-musl
+recipe
+ default.nix 4a6e23873f672eb4b6d5b787d5bbb3a3dd174bda0c2bf1bc47aca48f83479da0
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+ flake-module.nix 8fcc8fa3f96dc6c329acbc34f923da995e41df8b0003f9133604dd8a631d0518
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ python 3.14.7
+ mimalloc 3.5.3
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-aarch64-unknown-linux-musl 7e0ad2e67817f224b7a6331e48d6397303fc050edaccf81784ed786ffddc884a
+ rust-dist musl-objects musl 1.2.6
+nativeBuildInputs
+ aarch64-unknown-linux-musl-pkgconf-wrapper 2.5.1
+ autoconf 2.73
+ automake 1.18.1
+ file 5.48
+ gcc-wrapper 16.2.0
+ gettext 1.0
+ git-minimal 2.55.0
+ jq 1.8.2
+ libtool 2.6.2
+ lowdown 3.0.1
+ protobuf 36.2
+ python3 3.14.7-env
+ rust-bin-aarch64-unknown-linux-musl 1.98.1
+ unzip 6.0
+ which 2.25
+buildInputs
+ gmp-with-cxx 6.3.0
+ jq 1.8.2
+ libpq 18.6
+ libsodium 1.0.22-unstable-2026-08-13
+ openssl 3.5.8
+ sqlite 3.53.3
+ zlib 1.3.2
+flags
+ configure --disable-valgrind --prefix=/usr/local COPTFLAGS=-O2
+ dontBuild true
+ dontPatchELF true
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1
+ env NIX_OUTPATH_USED_AS_RANDOM_SEED=cln-release
+ make RUST_PROFILE=release
+ make PIE_LDFLAGS=-static-pie
+ make TARGET=aarch64-unknown-linux-musl
+ make AR=aarch64-unknown-linux-musl-ar
+ make BUILD=x86_64-unknown-linux-gnu
+ make MAKE_HOST=aarch64-unknown-linux-musl
+ make CC_FOR_BUILD=cc
diff --git a/nix/release-manifests/cln-armhf b/nix/release-manifests/cln-armhf
new file mode 100644
index 000000000000..4e69422a14f3
--- /dev/null
+++ b/nix/release-manifests/cln-armhf
@@ -0,0 +1,61 @@
+row
+ arch armhf
+ host armv7l-unknown-linux-musleabihf
+ fpu neon-vfpv4
+recipe
+ default.nix 4a6e23873f672eb4b6d5b787d5bbb3a3dd174bda0c2bf1bc47aca48f83479da0
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+ flake-module.nix 8fcc8fa3f96dc6c329acbc34f923da995e41df8b0003f9133604dd8a631d0518
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ python 3.14.7
+ mimalloc 3.5.3
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-armv7-unknown-linux-musleabihf dd0efa4210a6da6350a6b05d8ffa43eae4baecf2397cc00a3b028bdf56cdb1ce
+ rust-dist musl-objects musl 1.2.6
+nativeBuildInputs
+ armv7l-unknown-linux-musleabihf-pkgconf-wrapper 2.5.1
+ autoconf 2.73
+ automake 1.18.1
+ file 5.48
+ gcc-wrapper 16.2.0
+ gettext 1.0
+ git-minimal 2.55.0
+ jq 1.8.2
+ libtool 2.6.2
+ lowdown 3.0.1
+ protobuf 36.2
+ python3 3.14.7-env
+ rust-bin-armv7-unknown-linux-musleabihf 1.98.1
+ unzip 6.0
+ which 2.25
+buildInputs
+ gmp-with-cxx 6.3.0
+ jq 1.8.2
+ libpq 18.6
+ libsodium 1.0.22-unstable-2026-08-13
+ openssl 3.5.8
+ sqlite 3.53.3
+ zlib 1.3.2
+flags
+ configure --disable-valgrind --prefix=/usr/local COPTFLAGS=-O2
+ dontBuild true
+ dontPatchELF true
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1 -C target-feature=+vfp4,+neon
+ env NIX_DONT_SET_RPATH_armv7l_unknown_linux_musleabihf=1
+ env NIX_NO_SELF_RPATH=1
+ env NIX_OUTPATH_USED_AS_RANDOM_SEED=cln-release
+ make RUST_PROFILE=release
+ make PIE_LDFLAGS=-static-pie
+ make TARGET=armv7-unknown-linux-musleabihf
+ make AR=armv7l-unknown-linux-musleabihf-ar
+ make BUILD=x86_64-unknown-linux-gnu
+ make MAKE_HOST=armv7l-unknown-linux-musleabihf
+ make CC_FOR_BUILD=cc
diff --git a/nix/release-manifests/vls-amd64 b/nix/release-manifests/vls-amd64
new file mode 100644
index 000000000000..617a2adc518b
--- /dev/null
+++ b/nix/release-manifests/vls-amd64
@@ -0,0 +1,31 @@
+row
+ arch amd64
+ host x86_64-unknown-linux-musl
+recipe
+ vls.nix ceb35d83c38ce8cdc2cd974af9987a4c1a97fd35921ea028e161ed6dad27d14f
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+pin
+ url https://gitlab.com/lightning-signer/validating-lightning-signer.git
+ version v0.14.0
+ rev 9c0fd05c946d549f643d3e1833d8663168d2b0db
+ hash sha256-gKTkOOaj7EGunJF/xi7lW5dNNRvzWoj0nKuEIv3+TUk=
+ vendorHash sha256-fxPAZV2uSqN4RlWqTZLDHwsl0/RZdhPcg1fhmiNtgQo=
+ git-desc v0.14.0-0-g9c0fd05c946d
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ protobuf 36.2
+ mimalloc 3.5.3
+ llvm-libc memcpy+memmove 21.1.8
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-x86_64-unknown-linux-musl bd9f35880de21dab0e387e84009c00001ae7836a4ba565cb16823f13f75f325f
+ rust-dist musl-objects musl 1.2.6
+flags
+ cargo build --offline --locked --release -p vls-proxy --bin remote_hsmd_socket
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1
diff --git a/nix/release-manifests/vls-arm64 b/nix/release-manifests/vls-arm64
new file mode 100644
index 000000000000..9dfd54fde736
--- /dev/null
+++ b/nix/release-manifests/vls-arm64
@@ -0,0 +1,30 @@
+row
+ arch arm64
+ host aarch64-unknown-linux-musl
+recipe
+ vls.nix ceb35d83c38ce8cdc2cd974af9987a4c1a97fd35921ea028e161ed6dad27d14f
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+pin
+ url https://gitlab.com/lightning-signer/validating-lightning-signer.git
+ version v0.14.0
+ rev 9c0fd05c946d549f643d3e1833d8663168d2b0db
+ hash sha256-gKTkOOaj7EGunJF/xi7lW5dNNRvzWoj0nKuEIv3+TUk=
+ vendorHash sha256-fxPAZV2uSqN4RlWqTZLDHwsl0/RZdhPcg1fhmiNtgQo=
+ git-desc v0.14.0-0-g9c0fd05c946d
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ protobuf 36.2
+ mimalloc 3.5.3
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-aarch64-unknown-linux-musl 7e0ad2e67817f224b7a6331e48d6397303fc050edaccf81784ed786ffddc884a
+ rust-dist musl-objects musl 1.2.6
+flags
+ cargo build --offline --locked --release -p vls-proxy --bin remote_hsmd_socket
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1
diff --git a/nix/release-manifests/vls-armhf b/nix/release-manifests/vls-armhf
new file mode 100644
index 000000000000..7a7d00e557d8
--- /dev/null
+++ b/nix/release-manifests/vls-armhf
@@ -0,0 +1,33 @@
+row
+ arch armhf
+ host armv7l-unknown-linux-musleabihf
+ fpu neon-vfpv4
+recipe
+ vls.nix ceb35d83c38ce8cdc2cd974af9987a4c1a97fd35921ea028e161ed6dad27d14f
+ static-pie.nix 6abd5d2f05e276148f14fdca74cb732b15709613c71b8071b40da631ae1a1450
+ flake.nix 66b107f9cfbf0d69c0b9df603b583ddce493128aa00522acfee51c461f079b98
+ rust-bin.nix 51d59ab9b8451020c4865bc28f036d601a78e10ec06d1104b4f535496ccd62b3
+pin
+ url https://gitlab.com/lightning-signer/validating-lightning-signer.git
+ version v0.14.0
+ rev 9c0fd05c946d549f643d3e1833d8663168d2b0db
+ hash sha256-gKTkOOaj7EGunJF/xi7lW5dNNRvzWoj0nKuEIv3+TUk=
+ vendorHash sha256-fxPAZV2uSqN4RlWqTZLDHwsl0/RZdhPcg1fhmiNtgQo=
+ git-desc v0.14.0-0-g9c0fd05c946d
+toolchain
+ gcc 16.2.0
+ rustc 1.98.1
+ protobuf 36.2
+ mimalloc 3.5.3
+ rust-dist 1.98.1 2026-09-03 48a229ceaefd4985c50990b14116b6d856af0985
+ rust-dist rustc-x86_64-unknown-linux-gnu e974f036b28565f37c0f3bd92ddefa809bee16c04f9dcf07b9ed96e05aaaf7c4
+ rust-dist cargo-x86_64-unknown-linux-gnu ea1de9f9e23107d97ee2b41a72c552f34064a593da503789218387aee59f3ba4
+ rust-dist rust-std-x86_64-unknown-linux-gnu fa3ff450172a16c026944030230c5069947af93c728d9179971d44e5e0cfb561
+ rust-dist rust-std-armv7-unknown-linux-musleabihf dd0efa4210a6da6350a6b05d8ffa43eae4baecf2397cc00a3b028bdf56cdb1ce
+ rust-dist musl-objects musl 1.2.6
+flags
+ cargo build --offline --locked --release -p vls-proxy --bin remote_hsmd_socket
+ strip --strip-all
+ rustflags --remap-path-prefix=$NIX_BUILD_TOP=/home/clightning --remap-path-prefix==/home/clightning/vendor -C link-arg=-Wl,--build-id=sha1 -C target-feature=+vfp4,+neon
+ env NIX_DONT_SET_RPATH_armv7l_unknown_linux_musleabihf=1
+ env NIX_NO_SELF_RPATH=1
diff --git a/nix/release-rows b/nix/release-rows
new file mode 100644
index 000000000000..77ab30101521
--- /dev/null
+++ b/nix/release-rows
@@ -0,0 +1,25 @@
+# The release matrix: one row per static tarball (and VLS binary).
+#
+# Read by the flake (nix/pkgs/flake-module.nix), which generates
+# `cln-release-static-` and `vls-release-static-` from it, and by
+# tools/reprobuild with a plain `while read`. No tooling on either side, so
+# keep it whitespace-separated, one row per line, `#` comments on their own
+# lines only.
+#
+# The `@nixpkgs` line is the nixpkgs revision these rows are *certified*
+# against. It must equal the nixpkgs rev in flake.lock: `nix flake check`
+# fails at bump time if it does not, and the release derivations refuse to
+# evaluate. Move it only with `tools/reprobuild certify`.
+#
+# The arm rows are for the Raspberry Pi: arm64 for any 64-bit Pi OS, armhf
+# for 32-bit Pi OS on a Pi 2 or later (ARMv7, NEON, VFPv4). The ARMv6 Pi 1
+# and Zero cannot run armhf. pkgsCrossRaspberryPi is defined in
+# nix/pkgs/flake-module.nix.
+#
+# arch package-set path docker platform
+amd64 pkgsStatic linux/amd64
+arm64 pkgsCross.aarch64-multiplatform-musl.pkgsStatic linux/arm64
+armhf pkgsCrossRaspberryPi.pkgsStatic linux/arm/v7
+
+@nixpkgs b4fd65b198c599cbe814fcb9f42d25d021595ec9
+
diff --git a/plugins/Makefile b/plugins/Makefile
index e036917bc1e7..27955022343d 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -279,20 +279,13 @@ $(RUST_TARGET_DIR)/examples/cln-plugin-reentrant: ${CLN_PLUGIN_SRC} plugins/exam
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard: ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC} plugins/examples/cln-subscribe-wildcard.rs
$(CARGO) build ${CARGO_OPTS} --example cln-subscribe-wildcard
-$(RUST_TARGET_DIR)/cln-grpc: ${CLN_PLUGIN_SRC} ${CLN_GRPC_PLUGIN_SRC} ${CLN_RPC_SOURCES} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL)
- $(CARGO) build ${CARGO_OPTS} --bin cln-grpc
-$(RUST_TARGET_DIR)/clnrest: ${CLN_REST_PLUGIN_SRC} ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin clnrest
-$(RUST_TARGET_DIR)/cln-lsps-client: ${CLN_LSPS_PLUGIN_SRC} ${LSPS_TYPES_SOURCES} ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin cln-lsps-client
-$(RUST_TARGET_DIR)/cln-lsps-service: ${CLN_LSPS_PLUGIN_SRC} ${LSPS_TYPES_SOURCES} ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin cln-lsps-service
-$(RUST_TARGET_DIR)/wss-proxy: ${CLN_WSS_PROXY_PLUGIN_SRC} ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin wss-proxy
-$(RUST_TARGET_DIR)/cln-bip353: ${CLN_BIP353_PLUGIN_SRC} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin cln-bip353
-$(RUST_TARGET_DIR)/cln-currencyrate: ${CLN_CURRENCYRATE_PLUGIN_SRC} ${CLN_RPC_SOURCES} ${CLN_PLUGIN_SRC}
- $(CARGO) build ${CARGO_OPTS} --bin cln-currencyrate
+# One cargo invocation for all of them: separate ones serialize on cargo's
+# target-dir lock, and each then builds its own final crate alone. The
+# leading + hands cargo make's jobserver, so it shares the -j budget.
+$(RUST_PLUGIN_NAMES:%=$(RUST_TARGET_DIR)/%) &: ${CLN_PLUGIN_SRC} ${LSPS_TYPES_SOURCES} ${CLN_RPC_SOURCES} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL) \
+ ${CLN_GRPC_PLUGIN_SRC} ${CLN_REST_PLUGIN_SRC} ${CLN_LSPS_PLUGIN_SRC} ${CLN_WSS_PROXY_PLUGIN_SRC} \
+ ${CLN_BIP353_PLUGIN_SRC} ${CLN_CURRENCYRATE_PLUGIN_SRC}
+ +$(CARGO) build ${CARGO_OPTS} $(RUST_PLUGIN_NAMES:%=--bin %)
ifneq ($(RUST),0)
include plugins/rest-plugin/Makefile
diff --git a/tools/build-release.sh b/tools/build-release.sh
deleted file mode 100755
index b9ddac8a54f6..000000000000
--- a/tools/build-release.sh
+++ /dev/null
@@ -1,315 +0,0 @@
-#! /bin/sh
-set -e
-
-echo "RAW ARGS: [$*]"
-echo "ARG COUNT: $#"
-echo "ARG1: [$1]"
-
-# When run inside docker (from below), we do build and drop result in /release
-if [ "$1" = "--inside-docker" ]; then
- echo "Inside docker: starting build"
- VER="$2"
- PLTFM="$3"
- PLTFMVER="$4"
- ARCH="$5"
- MAKEPAR="$6"
- git config --global --add safe.directory /src/.git
- git clone /src /build
- cd /build || exit
- uv venv
- uv export --format requirements.txt > /tmp/requirements.txt
- uv pip install -r /tmp/requirements.txt
- ./configure
- uv run make -j"$MAKEPAR" VERSION="$VER"
- uv run make -j"$MAKEPAR" install DESTDIR=/"$VER-$PLTFM-$PLTFMVER-$ARCH" RUST_PROFILE=release
- cd /"$VER-$PLTFM-$PLTFMVER-$ARCH"
- LC_ALL=C tar --sort=name -c -v -z -f /release/clightning-"$VER-$PLTFM-$PLTFMVER-$ARCH".tar.gz --mtime='@1672531200' -- *
- echo "Inside docker: build finished"
- exit 0
-fi
-
-FORCE_UNCLEAN=false
-VERIFY_RELEASE=false
-WITHOUT_ZIP=false
-NO_PUSH=false
-SUDO=
-
-ALL_TARGETS="bin-Fedora bin-Ubuntu docker sign"
-# ALL_TARGETS="bin-Fedora bin-Ubuntu tarball deb docker sign"
-
-TARGETS=""
-
-while [ $# -gt 0 ]; do
- case "$1" in
- --force-version=*)
- FORCE_VERSION=${1#*=}
- ;;
- --force-version)
- shift
- FORCE_VERSION=$1
- ;;
- --force-unclean)
- FORCE_UNCLEAN=true
- ;;
- --force-mtime=*)
- FORCE_MTIME=${1#*=}
- ;;
- --force-mtime)
- shift
- FORCE_MTIME=$1
- ;;
- --verify)
- VERIFY_RELEASE=true
- ;;
- --without-zip)
- WITHOUT_ZIP=true
- ;;
- --no-push)
- NO_PUSH=true
- ;;
- --sudo)
- SUDO=sudo
- ;;
- --help)
- echo "Usage: [--force-version=] [--force-unclean] [--force-mtime=YYYY-MM-DD] [--verify] [--no-push] [TARGETS]"
- echo Known targets: "$ALL_TARGETS"
- echo "Example: tools/build-release.sh"
- echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 bin-Fedora bin-Ubuntu sign"
- echo "Example: tools/build-release.sh --verify"
- echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 --verify"
- echo "Example: tools/build-release.sh docker"
- echo "Example: tools/build-release.sh --force-version=v23.05 --force-unclean --force-mtime=2023-05-01 docker"
- exit 0
- ;;
- -*)
- echo "Unknown arg $1" >&2
- exit 1
- ;;
- *)
- TARGETS="$TARGETS $1"
- ;;
- esac
- shift
-done
-
-echo "Verify Release: $VERIFY_RELEASE"
-echo "Force mTime: $FORCE_MTIME"
-echo "Force Unclean: $FORCE_UNCLEAN"
-
-VERSION=$(git tag --points-at HEAD)
-echo "Tagged Version: $VERSION"
-VERSION=${FORCE_VERSION:-$VERSION}
-echo "Version: $VERSION"
-
-if [ "$VERSION" = "" ]; then
- echo "No tagged version at HEAD?" >&2
- exit 1
-fi
-
-# Don't forget the v prefix!
-case "$VERSION" in
- v*) ;;
- *)
- echo "Version must begin with v! Not $VERSION" >&2
- exit 1
- ;;
-esac
-
-# `status --porcelain -u no` suppressed modified! Bug reported...
-if [ "$(git diff --name-only)" != "" ] && ! $FORCE_UNCLEAN; then
- echo "Not a clean git directory" >&2
- exit 1
-fi
-
-# Skip 'v' here in $VERSION
-MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[.*${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
-echo "mTime: $MTIME"
-
-if [ -z "$MTIME" ]; then
- echo "No date found for $VERSION in CHANGELOG.md" >&2
- exit 1
-fi
-
-MAKEPAR=${MAKEPAR:-$(nproc)}
-echo "Parallel: $MAKEPAR"
-
-if [ "$VERIFY_RELEASE" = "true" ]; then
- if [ -f "SHA256SUMS-$VERSION.asc" ] && [ -f "SHA256SUMS-$VERSION" ]; then
- ALL_TARGETS="bin-Fedora bin-Ubuntu"
- else
- echo "Unable to verify. File SHA256SUMS-$VERSION or SHA256SUMS-$VERSION.asc not found in the root."
- exit 1
- fi
-fi
-
-TARGETS=${TARGETS:-$ALL_TARGETS}
-
-# ARM targets get their own release directory per architecture
-# (release-arm64/, release-armv7/), and never build the zip: the zip is
-# architecture-independent, and its block unconditionally removes release/'s
-# copy before rebuilding it from the current HEAD.
-case "$TARGETS" in
- *-arm64*)
- RELEASEDIR="$(pwd)/release-arm64"
- WITHOUT_ZIP=true
- ;;
- *-armv7*)
- RELEASEDIR="$(pwd)/release-armv7"
- WITHOUT_ZIP=true
- ;;
- *)
- RELEASEDIR="$(pwd)/release"
- ;;
-esac
-BARE_VERSION="$(echo "${VERSION}" | sed 's/^v//g')"
-TARBALL="${RELEASEDIR}/lightningd_${BARE_VERSION}.orig.tar.bz2"
-DATE=$(date +%Y%m%d%H%M%S)
-echo "Targets: $TARGETS"
-echo "Release Directory: $RELEASEDIR"
-echo "Tarball File: $TARBALL"
-echo "Current Timestamp: $DATE"
-
-mkdir -p "$RELEASEDIR"
-
-if [ "$WITHOUT_ZIP" = "false" ]; then
- # If it's a completely clean directory, we need submodules!
- make submodcheck
-
- echo "Creating Zip File"
- # delete zipfile if exists
- [ -f "$RELEASEDIR/clightning-$VERSION.zip" ] && rm "$RELEASEDIR/clightning-$VERSION.zip"
- mkdir "$RELEASEDIR/clightning-$VERSION"
- # git archive won't go into submodules :(; We use tar to copy
- git ls-files -z --recurse-submodules | tar --null --files-from=- -c -f - | (cd "$RELEASEDIR/clightning-$VERSION" && tar xf -)
- # tar can set dates on files, but zip cares about dates in directories!
- # We set to local time (not "$MTIME 00:00Z") because zip uses local time!
- find "$RELEASEDIR/clightning-$VERSION" -print0 | xargs -0r touch --no-dereference --date="$MTIME"
- # Seriously, we can have differing permissions, too. Normalize.
- # Directories become drwxr-xr-x
- find "$RELEASEDIR/clightning-$VERSION" -type d -print0 | xargs -0r chmod 755
- # Executables become -rwxr-xr-x
- find "$RELEASEDIR/clightning-$VERSION" -type f -perm -100 -print0 | xargs -0r chmod 755
- # Non-executables become -rw-r--r--
- find "$RELEASEDIR/clightning-$VERSION" -type f ! -perm -100 -print0 | xargs -0r chmod 644
- # zip -r doesn't have a deterministic order, and git ls-files does.
- LANG=C git ls-files --recurse-submodules | sed "s@^@clightning-$VERSION/@" | (cd release && zip -@ -X "clightning-$VERSION.zip")
- rm -r "$RELEASEDIR/clightning-$VERSION"
- echo "Zip File Created"
-fi
-
-for target in $TARGETS; do
- platform=${target#bin-}
- [ "$platform" != "$target" ] || continue
- case $platform in
- Fedora*)
- echo "Building Fedora Image"
- ARCH=amd64
- TAG=fedora
- DOCKERFILE=contrib/docker/Dockerfile.builder.fedora
- FEDORA_VERSION=$(grep -oP '^FROM fedora:\K[0-9]+' "$DOCKERFILE")
- docker build --no-cache -f $DOCKERFILE -t $TAG --load .
- docker run --rm=true -v "$(pwd)":/src:ro -v "$RELEASEDIR":/release $TAG /src/tools/build-release.sh --inside-docker "$VERSION" "$platform" "$FEDORA_VERSION" "$ARCH" "$MAKEPAR"
- docker run --rm=true -w /build $TAG rm -rf /"$VERSION-$platform-$FEDORA_VERSION-$ARCH" /build
- echo "Fedora Image Built"
- ;;
- Ubuntu*)
- distributions=${platform#Ubuntu-}
- [ "$distributions" = "Ubuntu" ] && distributions="jammy noble resolute"
- for d in $distributions; do
- # Capitalize the first letter of distro
- D=$(echo "$d" | awk '{print toupper(substr($0,1,1))substr($0,2)}')
- echo "Building Ubuntu $D Image"
- # armv7 is cross-compiled in the amd64 builder image; arm64
- # builds natively in its own cl-repro--arm64 image.
- IMAGE=cl-repro-"$d"
- REPRO_ARCH=""
- case "$d" in
- *-armv7)
- IMAGE=cl-repro-"${d%-armv7}"
- REPRO_ARCH=armv7
- ;;
- esac
- docker run --rm -v "$(pwd)":/repo -e FORCE_MTIME="$MTIME" -e FORCE_VERSION="$VERSION" -e MAKEPAR="$MAKEPAR" -e REPRO_ARCH="$REPRO_ARCH" "$IMAGE"
- echo "Ubuntu $D Image Built"
- done
- ;;
- *)
- echo "No Dockerfile for $platform" >&2
- exit 1
- esac
-done
-
-if [ -z "${TARGETS##* docker *}" ] || [ -z "${TARGETS##* docker}" ]; then
- echo "Building Docker Images"
- DOCKER_USER="elementsproject"
- echo "Creating multi-platform images tagged as $VERSION and latest"
- if $NO_PUSH; then
- # Build without publishing: the result only populates the builder's
- # cache, so a later run without --no-push pushes from cache quickly.
- DOCKER_OPTS="--platform linux/amd64,linux/arm64,linux/arm/v7"
- else
- DOCKER_OPTS="--push --platform linux/amd64,linux/arm64,linux/arm/v7"
- fi
- DOCKER_OPTS="$DOCKER_OPTS --build-arg VERSION=$VERSION"
- DOCKER_OPTS="$DOCKER_OPTS -t $DOCKER_USER/lightningd:$VERSION"
- DOCKER_OPTS="$DOCKER_OPTS -t $DOCKER_USER/lightningd:latest"
- DOCKER_OPTS="$DOCKER_OPTS --cache-to=type=local,dest=/tmp/docker-cache --cache-from=type=local,src=/tmp/docker-cache"
- echo "Docker Options: $DOCKER_OPTS"
- if $SUDO docker buildx ls | grep -q 'cln-builder'; then
- $SUDO docker buildx use cln-builder
- else
- $SUDO docker buildx create --name=cln-builder --use
- fi
- # shellcheck disable=SC2086
- $SUDO docker buildx build $DOCKER_OPTS .
- if $NO_PUSH; then
- echo "Built multi-platform images without pushing (rerun without --no-push to publish)"
- else
- echo "Pushed multi-platform images tagged as $VERSION and latest"
- fi
-fi
-
-if [ -z "${TARGETS##* sign *}" ] || [ -z "${TARGETS##* sign}" ]; then
- echo "Signing Release"
- cd release/ || exit
- sha256sum clightning-"$VERSION"-*.tar.* clightning-"$VERSION".zip > SHA256SUMS-"$VERSION"
- gpg -sb --armor --default-key "$(gpgconf --list-options gpg | awk -F: '$1 == "default-key" {print $10}' | tr -d '"')" -o SHA256SUMS-"$VERSION".asc SHA256SUMS-"$VERSION"
- cd ..
- echo "Release Signed"
-fi
-
-if [ "$VERIFY_RELEASE" = "true" ]; then
- echo "Verifying Release"
- sumfile="SHA256SUMS-${VERSION}"
- # Ensure that the release captains checksum exists at the desired location.
- if [ ! -f "$sumfile" ]; then
- echo "Can not find release captains checksum file \"$sumfile\"".
- echo "You can download it from the repository at:"
- echo "https://github.com/ElementsProject/lightning/releases/tag/$VERSION"
- echo "Place it under the project root as \"$sumfile\"."
- exit 1
- fi
- sumfile="$(pwd)/${sumfile}"
- cd release/ || exit
- # Check that the release captains sum matches. Strictly this is not necessary here
- # as we compare our checksums with the release captains checksums later, but
- # it gives a direct hint which specific checksums don't match if so.
- sha256sum --check --ignore-missing "${sumfile}"
- # compare our and release captain's SHA256SUMS contents
- if cmp -s SHA256SUMS "$sumfile"; then
- echo "SHA256SUMS are Identical"
- else
- echo "Error: SHA256SUMS do NOT Match"
- exit 1
- fi
- # Verify release captain signature. Pass the manifest explicitly: with only
- # the .asc argument gpg picks its mode from the file's packet structure and
- # would verify a payload embedded in an inline-signed .asc, exiting 0
- # without ever reading the checksums we just compared.
- gpg --verify "../SHA256SUMS-$VERSION.asc" "../SHA256SUMS-$VERSION"
- # create ASCII-armored detached signature
- gpg -sb --armor < SHA256SUMS > SHA256SUMS.new
- echo "Verified Successfully! Signature Updated in release/SHA256SUMS.new"
-fi
-
-echo "Building release script finished!!"
diff --git a/tools/check-release.sh b/tools/check-release.sh
index 1e9bcd19c156..b1669c384667 100755
--- a/tools/check-release.sh
+++ b/tools/check-release.sh
@@ -6,7 +6,7 @@ set -e
# tagging issues prior to build via Github Actions.
#
# 1. The version tag should point to the HEAD of the branch.
-# - tools/build-release.sh#67
+# - historically tools/build-release.sh; now tools/reprobuild
# 2. The pushed tag should match the branch tag at the HEAD.
# 3. The CHANGELOG.md contains a header entry for the version tag.
# 4. The CHANGELOG.md entry for that version tag can be parsed for a date.
diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh
index 89b2f821c4a5..c4fab35ee0a1 100755
--- a/tools/docker-entrypoint.sh
+++ b/tools/docker-entrypoint.sh
@@ -4,6 +4,32 @@
networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}"
+# -vls image: run the VLS signer proxy as the hsmd subdaemon
+# unless the user already chose one.
+if [ "${VLS_ENABLED:-false}" = "true" ]; then
+ case " $* " in
+ *" --subdaemon=hsmd:"* | *" --subdaemon hsmd:"*) ;;
+ *) set -- --subdaemon=hsmd:/var/lib/vls/bin/remote_hsmd_socket "$@" ;;
+ esac
+ # The signer reads three things from the environment and *panics* if any is
+ # missing (vls-proxy/src/util/env_var.rs: BITCOIND_RPC_URL, VLS_NETWORK,
+ # VLS_CLN_VERSION). lightningd sees only an hsmd that never answers and
+ # then waits forever with no error of its own, so each one is either
+ # supplied here or refused here.
+ #
+ # The network is not a separate choice: it follows lightningd's.
+ export VLS_NETWORK="${VLS_NETWORK:-$LIGHTNINGD_NETWORK}"
+ # The bitcoind URL cannot be guessed -- the signer validates on chain and
+ # needs its own connection, which may not be the node's. Refuse with an
+ # explanation rather than starting something that will hang.
+ if [ -z "${BITCOIND_RPC_URL:-}" ]; then
+ echo "VLS_ENABLED=true but BITCOIND_RPC_URL is not set." >&2
+ echo "The signer validates against the chain itself and needs a bitcoind RPC URL," >&2
+ echo "e.g. -e BITCOIND_RPC_URL=http://user:pass@bitcoind:8332" >&2
+ exit 1
+ fi
+fi
+
set -m
lightningd --network="${LIGHTNINGD_NETWORK}" "$@" &
LIGHTNINGD_PID=$!
diff --git a/tools/repro-build.sh b/tools/repro-build.sh
deleted file mode 100755
index 621847e71d13..000000000000
--- a/tools/repro-build.sh
+++ /dev/null
@@ -1,156 +0,0 @@
-#! /bin/sh
-
-set -e
-
-LANG=C
-LC_ALL=C
-export LANG LC_ALL
-
-for arg; do
- case "$arg" in
- --force-version=*)
- FORCE_VERSION=${arg#*=}
- ;;
- --force-mtime=*)
- FORCE_MTIME=${arg#*=}
- ;;
- --help)
- echo "Usage: [--force-version=] [--force-mtime=YYYY-MM-DD]"
- exit 0
- ;;
- *)
- echo "Unknown arg $arg" >&2
- exit 1
- ;;
- esac
- shift
-done
-
-# Taken from https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script
-if [ -f /etc/os-release ]; then
- # freedesktop.org and systemd
- # shellcheck disable=SC1091
- . /etc/os-release
- OS=$NAME
- VER=$VERSION_ID
-elif command -v lsb_release >/dev/null 2>&1; then
- # linuxbase.org
- OS=$(lsb_release -si)
- VER=$(lsb_release -sr)
-elif [ -f /etc/lsb-release ]; then
- # For some versions of Debian/Ubuntu without lsb_release command
- # shellcheck disable=SC1091
- . /etc/lsb-release
- OS=$DISTRIB_ID
- VER=$DISTRIB_RELEASE
-elif [ -f /etc/debian_version ]; then
- # Older Debian/Ubuntu/etc.
- OS=Debian
- VER=$(cat /etc/debian_version)
-else
- # Fall back to uname, e.g. "Linux ", also works for BSD, etc.
- OS=$(uname -s)
- VER=$(uname -r)
-fi
-
-ARCH=$(dpkg --print-architecture)
-PLATFORM="$OS"-"$VER"
-VERSION=${FORCE_VERSION:-$(git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')}
-MAKEPAR=${MAKEPAR:-1}
-
-# eg. ## [0.6.3] - 2019-01-09: "The Smallblock Conspiracy"
-# Skip 'v' here in $VERSION
-MTIME=${FORCE_MTIME:-$(sed -n "s/^## \\[${VERSION#v}\\] - \\([-0-9]*\\).*/\\1/p" < CHANGELOG.md)}
-if [ -z "$MTIME" ]; then
- echo "No date found for $VERSION in CHANGELOG.md" >&2
- exit 1
-fi
-
-echo "Repro Version: $VERSION"
-echo "Repro mTime: $MTIME"
-echo "Repro Platform: $PLATFORM"
-
-if grep ^deb /etc/apt/sources.list | grep -- '-\(updates\|security\)'; then
- echo Please disable security and updates in /etc/apt/sources.list >&2
- exit 1
-fi
-
-DOWNLOAD='sudo apt -y --no-install-recommends --reinstall -d install'
-PKGS='autoconf automake libtool make gcc libsqlite3-dev zlib1g-dev libsodium-dev'
-INST='sudo dpkg -i'
-
-case "$PLATFORM" in
- Ubuntu-22.04)
- cat > /tmp/SHASUMS < /tmp/SHASUMS < /tmp/SHASUMS <&2
- exit 1
- ;;
-esac
-
-# Download the packages
-# shellcheck disable=SC2086
-$DOWNLOAD $PKGS
-
-# Make sure versions match, and exactly.
-sha256sum -c /tmp/SHASUMS
-
-# Install them
-# shellcheck disable=SC2046
-$INST $(cut -c66- < /tmp/SHASUMS)
-
-# Build ready for packaging.
-# Once everyone has gcc8, we can use CC="gcc -ffile-prefix-map=$(pwd)=/home/clightning"
-./configure --prefix=/usr CC="gcc -fdebug-prefix-map=$(pwd)=/home/clightning"
-# libwally wants "python". Seems to work to force it here.
-make -j"$MAKEPAR" PYTHON_VERSION=3 VERSION="$VERSION"
-make -j"$MAKEPAR" install DESTDIR=inst/
-
-cd inst && tar --sort=name \
- --mtime="$MTIME 00:00Z" \
- --owner=0 --group=0 --numeric-owner -cvaf ../clightning-"$VERSION-$PLATFORM-$ARCH".tar.xz .
diff --git a/tools/reprobuild b/tools/reprobuild
new file mode 100755
index 000000000000..e18de8994eb7
--- /dev/null
+++ b/tools/reprobuild
@@ -0,0 +1,1340 @@
+#!/usr/bin/env python3
+"""The reproducible-release driver.
+
+The host is required to have **docker, coreutils and python3 (>= 3.10)**, and
+nothing else: this script imports only the standard library, and every nix
+invocation happens inside a digest-pinned `nixos/nix` container, against a
+store under $XDG_CACHE_HOME. `--host-nix` is an opt-in for whoever has Nix
+and wants the faster loop; both routes are expected to produce identical
+bytes.
+
+Deliberately not run through `uv`: a co-signer reproducing a release should
+need a python interpreter, not a python package manager.
+
+3.10 rather than the repo's own `requires-python` floor, deliberately: that
+floor is about who can install the pyln packages, this is about who can
+reproduce a release, and there is no reason to shut out a co-signer on Ubuntu
+22.04 for a script that runs there. Raise it only when something here needs to.
+
+The matrix is data (nix/release-rows), read here and by the flake with no
+tooling on either side, so there is one source of truth.
+
+ fetch bitcoin-cli tarballs + SHA256SUMS.asc, GPG-verified
+ build [archs] tarball per arch, as a Nix output
+ vls [archs] remote_hsmd_socket per arch, a Nix output
+ -- NOT part of `all`: this release ships no VLS
+ zip source zip
+ docker runtime images to a local OCI layout
+ sign SHA256SUMS- + .asc
+ verify co-signer flow
+ certify [--no-verify] re-pin nixpkgs rev + input manifests,
+ from-source build, acceptance suite
+ publish everything public in one go: tarballs, manifests and
+ source zip -> download host, images -> Docker Hub,
+ tag -> GitHub, and the GitHub release
+ accept [archs] portability rows + the two-tree probe
+ all zip + build all + fetch + docker + sign
+
+`certify` is deliberately *not* part of `all`: certification is an intentional
+act, and folding it in would let a release day quietly re-certify a toolchain
+nobody examined.
+"""
+
+from __future__ import annotations
+
+import argparse
+import hashlib
+import json
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+import time
+from dataclasses import dataclass, field
+from pathlib import Path
+
+# Whether this release publishes VLS. Core Lightning offers splicing by
+# default and refuses an hsmd that cannot sign splices; no released VLS
+# implements it, so the binaries and the -vls image could not start against
+# the release shipping them. The derivations, the `vls` verb and the regtest
+# harness stay: bringing VLS back is a pin bump, a green regtest run and this.
+RELEASE_SHIPS_VLS = False
+
+# The distro `all` smoke-tests the finished tarballs on. The full matrix
+# lives in `accept`; what this catches is the release-day question -- do the
+# binaries we just signed actually run.
+RELEASE_SMOKE_IMAGE = "ubuntu:26.04"
+
+# How often --wait-for-key retries the key. Each retry is a real signature
+# attempt, so this is not free: often enough that nobody stands around waiting,
+# rare enough that a smartcard is not hammered for half an hour.
+KEY_POLL_SECONDS = 10
+
+
+def die(msg: str) -> None:
+ sys.exit(f"reprobuild: {msg}")
+
+
+def info(msg: str) -> None:
+ """Progress goes to stderr, like die(). It must not go to stdout: the
+ verbs that capture a nix store path capture stdout, and a progress line
+ printed while seeding the store -- which only happens on a cold cache --
+ would be captured as part of the path."""
+ print(f"reprobuild: {msg}", file=sys.stderr, flush=True)
+
+
+def run(
+ *cmd: str,
+ capture: bool = False,
+ check: bool = True,
+ merge: bool = False,
+ stream_stderr: bool = False,
+ **kw,
+) -> str:
+ """Run a command, returning stdout (and stderr, with merge) when asked.
+ With stream_stderr, only stdout is captured and stderr goes to the
+ terminal, so a long build's log is visible while it runs."""
+ # Build logs can carry raw bytes; a decode error must never kill a release.
+ kw.setdefault("errors", "replace")
+ if merge:
+ kw["stderr"] = subprocess.STDOUT
+ kw["stdout"] = subprocess.PIPE
+ p = subprocess.run(cmd, text=True, **kw)
+ elif capture and stream_stderr:
+ p = subprocess.run(cmd, text=True, stdout=subprocess.PIPE, **kw)
+ else:
+ p = subprocess.run(cmd, text=True, capture_output=capture, **kw)
+ if check and p.returncode != 0:
+ if capture and p.stderr:
+ print(p.stderr, file=sys.stderr, end="")
+ die(f"failed ({p.returncode}): {' '.join(cmd)}")
+ return (p.stdout or "").strip() if capture else ""
+
+
+def sha256(path: Path) -> str:
+ h = hashlib.sha256()
+ with path.open("rb") as f:
+ for chunk in iter(lambda: f.read(1 << 20), b""):
+ h.update(chunk)
+ return h.hexdigest()
+
+
+@dataclass
+class Row:
+ arch: str
+ pkgs: str
+ platform: str
+
+
+@dataclass
+class Driver:
+ args: argparse.Namespace
+ top: Path
+ rev: str = ""
+ flake_ref: str = ""
+ narhash: str = ""
+ substitute: bool = True
+ _version: str = ""
+ _rows: list[Row] = field(default_factory=list)
+
+ # --- data: the matrix, the pins, the version -------------------------
+
+ @property
+ def rows_file(self) -> Path:
+ return self.top / "nix/release-rows"
+
+ def rows(self) -> list[Row]:
+ """nix/release-rows, minus comments and the `@directive` lines."""
+ if not self._rows:
+ for line in self.rows_file.read_text().splitlines():
+ f = line.split()
+ if not f or f[0].startswith(("#", "@")):
+ continue
+ if len(f) < 3:
+ die(f"nix/release-rows: short row: {line}")
+ self._rows.append(Row(*f[:3]))
+ return self._rows
+
+ def directive(self, name: str) -> str:
+ hits = [
+ ln.split()[1]
+ for ln in self.rows_file.read_text().splitlines()
+ if ln.startswith(f"@{name} ")
+ ]
+ if len(hits) != 1:
+ die(f"nix/release-rows: expected exactly one @{name} line")
+ return hits[0]
+
+ def certified_rev(self) -> str:
+ return self.directive("nixpkgs")
+
+ def platform_of(self, arch: str) -> str:
+ return next(r.platform for r in self.rows() if r.arch == arch)
+
+ def arch_list(self, sel: list[str] | None) -> list[str]:
+ known = [r.arch for r in self.rows()]
+ if not sel or sel == ["all"]:
+ return known
+ for a in sel:
+ if a not in known:
+ die(f"unknown arch '{a}' (not in nix/release-rows)")
+ return sel
+
+ # Digits belong in the key pattern: REPRO_S3_BUCKET and friends have one,
+ # and a name class that quietly does not match them yields a dict missing
+ # exactly the keys the caller is about to index.
+ VARS_RE = r"^([A-Z0-9_]+)=(.*)$"
+
+ def pins(self) -> dict[str, str]:
+ text = (self.top / "contrib/reprobuild/pins").read_text()
+ return dict(re.findall(self.VARS_RE, text, re.M))
+
+ def publish_vars(self) -> dict[str, str]:
+ text = (self.top / "contrib/reprobuild/publish.vars").read_text()
+ return dict(re.findall(self.VARS_RE, text, re.M))
+
+ def rclone_args(self, v: dict[str, str]) -> list[str]:
+ """The credentials are the shared publisher account's HMAC key, taken
+ from the environment so they are never written to a file here."""
+ key = os.environ.get("REPRO_S3_ACCESS_KEY_ID")
+ secret = os.environ.get("REPRO_S3_SECRET_ACCESS_KEY")
+ if not key or not secret:
+ die("REPRO_S3_ACCESS_KEY_ID / REPRO_S3_SECRET_ACCESS_KEY are not set.\n"
+ " They are the HMAC key of the shared publisher account; put them in\n"
+ " the environment for this command only.")
+ return ["rclone", "--s3-provider", v["REPRO_S3_PROVIDER"],
+ "--s3-endpoint", v["REPRO_S3_ENDPOINT"],
+ "--s3-access-key-id", key, "--s3-secret-access-key", secret]
+
+ def vls_source(self) -> str:
+ """The VLS pin is read at the rev being built, not from the working
+ tree: a co-signer verifying an older release must see the pin that
+ produced those bytes."""
+ if self.rev:
+ return run("git", "-C", str(self.top), "show",
+ f"{self.rev}:nix/pkgs/vls.nix", capture=True)
+ return (self.top / "nix/pkgs/vls.nix").read_text()
+
+ def vls_pin(self, field_name: str) -> str:
+ m = re.search(rf'^\s*{field_name} = "([^"]*)";', self.vls_source(), re.M)
+ return m.group(1) if m else ""
+
+ def vls_version(self) -> str:
+ v = self.vls_pin("version")
+ if not v:
+ die("cannot read the VLS version from nix/pkgs/vls.nix")
+ return v
+
+ def version(self) -> str:
+ if not self._version:
+ self._version = self.args.version or run(
+ "git", "-C", str(self.top), "describe", "--tags", "--abbrev=7",
+ capture=True)
+ return self._version
+
+ # --- the tree a release is built from ---------------------------------
+
+ def prepare_tree(self) -> None:
+ """A release is never built from a dirty tree: nix caches the fetched
+ worktree and would happily build a snapshot that is neither the
+ working tree nor any commit, which the rev+narHash manifest identity
+ would then describe without having built it."""
+ if self.flake_ref:
+ return
+ dirty = run("git", "-C", str(self.top), "status", "--porcelain",
+ "--untracked-files=no", capture=True)
+ if dirty and not self.args.allow_dirty:
+ die("the tree is dirty; commit first.\n"
+ " A release must never be built from a dirty tree: nix caches the\n"
+ " fetched worktree, so the artifacts would be labelled with a commit\n"
+ " they were not built from. --allow-dirty is for experiments only.")
+ if dirty:
+ info("WARNING: --allow-dirty: building the working tree, not a commit")
+ self.rev = run("git", "-C", str(self.top), "rev-parse", "HEAD", capture=True)
+ # The timestamp baked into the artifacts is the commit's, not the
+ # machine's: a co-signer building the same commit a week later, on
+ # the other side of midnight or of the world, gets the same bytes.
+ # The date-only shape is what every consumer expects (tar's
+ # `--mtime="$MTIME 00:00Z"`, configure's MTIME, docker's
+ # SOURCE_DATE_EPOCH); `verify` pins the manifest's own value and
+ # `--mtime` overrides, neither lands here.
+ if self.args.mtime is None:
+ ct = int(run("git", "-C", str(self.top), "log", "-1", "--format=%ct",
+ self.rev, capture=True))
+ self.args.mtime = time.strftime("%Y-%m-%d", time.gmtime(ct))
+ base = f"git+file://{self.top}?submodules=1"
+ self.flake_ref = base if self.args.allow_dirty else f"{base}&rev={self.rev}"
+
+ # --- nix, in the pinned container (or on the host) --------------------
+
+ def substituters(self) -> str:
+ """Passed by the *driver*, identical for captain and co-signers, so
+ nobody's personal nix.conf is an input to a signed artifact."""
+ v = self.publish_vars()
+ base, prefix = v.get("PUBLISH_BASE_URL"), v.get("PUBLISH_PREFIX_ARCHIVE")
+ return (f"{base}/{prefix} https://cache.nixos.org" if base and prefix
+ else "https://cache.nixos.org")
+
+ def store_dir(self) -> Path:
+ if self.args.store_dir:
+ return Path(self.args.store_dir)
+ cache = os.environ.get("XDG_CACHE_HOME") or (Path.home() / ".cache")
+ return Path(cache) / "cln-reprobuild/nix"
+
+ def seed_store(self) -> None:
+ """`-v $store:/nix` shadows the image's own /nix, where the nix binary
+ and its closure live, so the container could not exec nix at all.
+ Seed the store from the image once."""
+ store = self.store_dir()
+ store.mkdir(parents=True, exist_ok=True)
+ if not (store / "store").is_dir():
+ info(f"seeding {store} from {self.pins()['NIX_IMAGE']}")
+ run("docker", "run", "--rm", "-v", f"{store}:/seed",
+ self.pins()["NIX_IMAGE"], "sh", "-c", "cp -a /nix/. /seed/")
+
+ def nix(
+ self,
+ *args: str,
+ capture: bool = False,
+ check: bool = True,
+ merge: bool = False,
+ stream_stderr: bool = False,
+ ) -> str:
+ subs = self.substituters()
+ sub = "true" if self.substitute else "false"
+ if self.args.host_nix:
+ # The sandbox is a release gate, not a preference: an unsandboxed
+ # build bakes a random build directory into every locally compiled
+ # Rust artifact, so it can reproduce nothing. On the host this is
+ # a daemon setting a non-trusted user cannot override, so it is
+ # checked rather than asked for.
+ have = run("nix", "--extra-experimental-features", "nix-command flakes",
+ "config", "show", "sandbox", capture=True, check=False)
+ if have not in ("true", "relaxed"):
+ die(f"the host's nix has sandbox={have or 'unknown'}; a release build "
+ "must be sandboxed.\n Set 'sandbox = true' in /etc/nix/nix.conf "
+ "and restart nix-daemon, or drop --host-nix.")
+ return run(
+ "nix",
+ "--extra-experimental-features",
+ "nix-command flakes",
+ "--option",
+ "substituters",
+ subs,
+ "--option",
+ "substitute",
+ sub,
+ "--option",
+ "sandbox-fallback",
+ "false",
+ *args,
+ capture=capture,
+ check=check,
+ merge=merge,
+ stream_stderr=stream_stderr,
+ )
+
+ self.seed_store()
+ # In a linked git worktree, `.git` is a file pointing at
+ # /.git/worktrees/, where the submodule git dirs also
+ # live -- none of it inside $top. Mount the common dir too, at the
+ # same absolute path.
+ common = Path(run("git", "-C", str(self.top), "rev-parse",
+ "--git-common-dir", capture=True))
+ if not common.is_absolute():
+ common = self.top / common
+ mounts = [] if common == self.top / ".git" else ["-v", f"{common}:{common}:ro"]
+ # nix's libgit2 fetcher refuses a repository it does not own, and the
+ # container runs as root against a tree owned by the invoking user.
+ with tempfile.NamedTemporaryFile("w", suffix=".gitconfig") as gc:
+ gc.write("[safe]\n\tdirectory = *\n")
+ gc.flush()
+ # --privileged supplies the namespaces nix needs for the sandbox;
+ # sandbox-fallback = false makes a failure to set it up loud
+ # instead of silently unreproducible.
+ return run(
+ "docker",
+ "run",
+ "--rm",
+ "--privileged",
+ "-v",
+ f"{self.top}:{self.top}:ro",
+ *mounts,
+ "-v",
+ f"{self.store_dir()}:/nix",
+ "-v",
+ f"{gc.name}:/root/.gitconfig:ro",
+ "-e",
+ "NIX_CONFIG="
+ + "\n".join(
+ [
+ "experimental-features = nix-command flakes",
+ "filter-syscalls = false",
+ "sandbox = true",
+ "sandbox-fallback = false",
+ f"substitute = {sub}",
+ f"substituters = {subs}",
+ ]
+ ),
+ self.pins()["NIX_IMAGE"],
+ "nix",
+ *args,
+ capture=capture,
+ check=check,
+ merge=merge,
+ stream_stderr=stream_stderr,
+ )
+
+ def host_path(self, store_path: str) -> Path:
+ """A store path printed by the container exists only inside it: a
+ verifier's host has no /nix, which is the entire point of this route."""
+ if self.args.host_nix:
+ return Path(store_path)
+ return self.store_dir() / store_path.removeprefix("/nix/")
+
+ def parallelism(self, width: int) -> list[str]:
+ """--max-jobs/--cores for `width` heavy top-level derivations.
+
+ nix's default `cores = 0` hands every derivation all CPUs, so three
+ rows building at once would each run `make -jNPROC`. The budget is
+ split over the heavy ones instead (the zip is not one: it only copies
+ files). --cores does not reach the output bytes: xz is pinned to one
+ thread and cargo's codegen does not depend on its job count.
+ """
+ width = max(1, min(width, self.args.jobs))
+ # --max-jobs counts every derivation, including the small ones (the
+ # zip, a wrapper script); +1 lets one run beside the heavy rows.
+ return [
+ "--max-jobs",
+ str(width + 1),
+ "--cores",
+ str(max(1, self.args.jobs // width)),
+ ]
+
+ def build_exprs(self, exprs: list[str], width: int) -> list[str]:
+ """Build every expression in one `nix build`, so independent rows
+ overlap; returns the output paths in the order given."""
+ attrs = "; ".join(f"a{i} = {e}" for i, e in enumerate(exprs))
+ out = self.nix(
+ "build",
+ "--impure",
+ *self.parallelism(width),
+ "--print-out-paths",
+ "--no-link",
+ "-L",
+ "--expr",
+ f"{{ {attrs}; }}",
+ *(f"a{i}" for i in range(len(exprs))),
+ capture=True,
+ stream_stderr=True,
+ )
+ paths = out.splitlines()
+ if len(paths) != len(exprs):
+ die(
+ f"nix build printed {len(paths)} output paths for {len(exprs)} attributes"
+ )
+ return paths
+
+ def rebuild(self, store_paths: list[str], width: int) -> None:
+ """`nix build --rebuild` holds the *inputs* identical by construction,
+ which is stronger than two runs of this driver. It must name the
+ derivations that were just built, by store path: re-evaluating asks
+ the flake what the tree says *now*."""
+ drvs = []
+ for sp in store_paths:
+ drv = self.nix("path-info", "--derivation", sp, capture=True, check=False)
+ if not drv:
+ die(f"cannot find the deriver of {sp}")
+ drvs.append(drv.splitlines()[0] + "^out")
+ info(f"nix build --rebuild {' '.join(drvs)}")
+ log = self.nix(
+ "build",
+ "--rebuild",
+ *self.parallelism(width),
+ "--no-link",
+ "-L",
+ *drvs,
+ capture=True,
+ check=False,
+ merge=True,
+ )
+ # "Could not check" and "differs" are *not* the same answer, and a
+ # release gate must never conflate them.
+ if "not valid, so checking is not possible" in log:
+ die(f"--rebuild COULD NOT CHECK {' '.join(store_paths)} (not in the store)")
+ if "differs" in log or "may not be deterministic" in log:
+ print(log, file=sys.stderr)
+ die(f"--rebuild DIFFERS for one of {' '.join(store_paths)}")
+ info(f"--rebuild reproduced {' '.join(store_paths)}")
+
+ # --- provenance: which tree an artifact on disk came from -------------
+
+ @property
+ def provenance(self) -> Path:
+ return Path(self.args.out) / ".provenance"
+
+ def tree_narhash(self) -> str:
+ if not self.narhash:
+ self.narhash = self.nix("eval", "--raw", "--impure", "--expr",
+ f'(builtins.getFlake "{self.flake_ref}").narHash',
+ capture=True)
+ return self.narhash
+
+ def record_provenance(self, name: str) -> None:
+ """The driver cannot stop someone building rows on Monday and signing
+ on Wednesday, but it can refuse to describe them with today's rev."""
+ self.provenance.parent.mkdir(parents=True, exist_ok=True)
+ lines = [ln for ln in (self.provenance.read_text().splitlines()
+ if self.provenance.exists() else [])
+ if not ln.startswith(f"{name} ")]
+ lines.append(f"{name} {self.rev} {self.tree_narhash()}")
+ self.provenance.write_text("\n".join(lines) + "\n")
+
+ def provenance_of(self, names: list[str]) -> tuple[str, str]:
+ if not self.provenance.exists():
+ die(f"no {self.provenance}: these artifacts were not built by this "
+ "driver. Rebuild them so the manifest can say which tree they "
+ "came from.")
+ have = dict()
+ for ln in self.provenance.read_text().splitlines():
+ f = ln.split()
+ if len(f) == 3:
+ have[f[0]] = (f[1], f[2])
+ seen = {}
+ for n in names:
+ if n not in have:
+ die(f"{n} has no provenance line in {self.provenance}; rebuild it")
+ seen[n] = have[n]
+ revs = {v[0] for v in seen.values()}
+ if len(revs) != 1:
+ odd = ", ".join(f"{n}({v[0]})" for n, v in seen.items())
+ die(f"these artifacts were built from different trees: {odd}\n"
+ " Everything in one manifest must come from one tree. Rebuild.")
+ return next(iter(seen.values()))
+
+ # --- verbs ------------------------------------------------------------
+
+ def verb_fetch(self) -> None:
+ """bitcoin-cli, GPG-verified, into the cache the image build reads."""
+ bv = self.pins()["BITCOIN_VERSION"]
+ out = Path(self.args.out)
+ (out / "cache").mkdir(parents=True, exist_ok=True)
+ run(str(self.top / "contrib/reprobuild/fetch-bitcoin.sh"),
+ f"--cache={out}/cache/bitcoin-{bv}")
+
+ def _artifacts(self, specs: list[tuple[str, str, int, str]]) -> list[Path]:
+ """Build (attr, file name, mode, override) specs in one nix build and
+ install each output file under --out."""
+ flake = f'(builtins.getFlake "{self.flake_ref}").packages.x86_64-linux'
+ width = max(
+ 1, sum(1 for attr, _, _, _ in specs if attr != "cln-release-source-zip")
+ )
+ stores = self.build_exprs(
+ [f"{flake}.{attr}{override}" for attr, _, _, override in specs], width
+ )
+ if self.args.rebuild:
+ self.rebuild(stores, width)
+ written = []
+ for store, (_, name, mode, _) in zip(stores, specs):
+ src = self.host_path(store) / name
+ if not src.is_file():
+ die(f"the derivation produced no {name}")
+ dst = Path(self.args.out) / name
+ dst.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copyfile(src, dst)
+ dst.chmod(mode)
+ self.record_provenance(name)
+ info(f"wrote {dst}")
+ print(f"{sha256(dst)} {dst}")
+ written.append(dst)
+ return written
+
+ def release_specs(
+ self,
+ archs: list[str] | None,
+ vls: bool,
+ zip_: bool,
+ vls_archs: list[str] | None = None,
+ ) -> list[tuple[str, str, int, str]]:
+ """What `build`, `vls` and `zip` produce, as _artifacts() specs."""
+ self.prepare_tree()
+ ver, mtime = self.version(), self.args.mtime
+ # Version and mtime reach the derivations through `.override`, the
+ # same knob the flake exposes to any consumer.
+ ov = f'.override {{ releaseVersion = "{ver}"; releaseMtime = "{mtime}"; }}'
+ specs = []
+ if zip_:
+ specs.append(("cln-release-source-zip", f"clightning-{ver}.zip", 0o644, ov))
+ for arch in self.arch_list(archs) if archs is not None else []:
+ specs.append(
+ (
+ f"cln-release-static-{arch}",
+ f"clightning-{ver}-static-{arch}.tar.xz",
+ 0o644,
+ ov,
+ )
+ )
+ if vls:
+ # No override: which VLS ships is a release decision with its own
+ # review cadence, pinned in nix/pkgs/vls.nix.
+ vlsver = self.vls_version()
+ for arch in self.arch_list(vls_archs if vls_archs is not None else archs):
+ specs.append(
+ (
+ f"vls-release-static-{arch}",
+ f"remote_hsmd_socket-{vlsver}-{arch}",
+ 0o755,
+ "",
+ )
+ )
+ return specs
+
+ def build_release(
+ self,
+ archs: list[str] | None,
+ vls: bool = False,
+ zip_: bool = False,
+ vls_archs: list[str] | None = None,
+ ) -> None:
+ """Every requested artifact in one nix build, then the per-tarball
+ checks: stripped, position-independent, no embedded library search
+ path, build-id present -- a precondition of `sign`, not advice."""
+ specs = self.release_specs(archs, vls, zip_, vls_archs)
+ info("building " + ", ".join(name for _, name, _, _ in specs))
+ for dst in self._artifacts(specs):
+ if dst.name.endswith(".tar.xz"):
+ run(str(self.top / "contrib/reprobuild/check.sh"), str(dst))
+
+ def verb_build(self, archs: list[str]) -> None:
+ self.build_release(archs)
+
+ def verb_vls(self, archs: list[str]) -> None:
+ self.build_release(None, vls=True, vls_archs=archs)
+
+ def verb_zip(self) -> None:
+ """The source zip is a derivation like every other signed artifact, so
+ it does not depend on the working tree, the host's `zip` or a locale."""
+ self.build_release(None, zip_=True)
+
+ # --- OCI layouts ------------------------------------------------------
+
+ def oci_index_digest(self, layout: Path) -> str:
+ idx = json.loads((layout / "index.json").read_text())
+ return idx["manifests"][0]["digest"]
+
+ def oci_image_labels(self, layout: Path, platform: str) -> dict[str, str]:
+ """The labels of one platform's image config, read out of the layout.
+
+ This is what `publish` checks instead of an image digest: it answers
+ "is this layout the one built for this release, from this commit",
+ which is a staleness question and has an answer. "Are these the exact
+ bytes someone else would get" does not, because the image build has an
+ unpinned apt step."""
+ algo_h = dict(self.oci_platform_digests(layout)).get(platform)
+ if not algo_h:
+ die(f"{layout}: no image for {platform}")
+ algo, h = algo_h.split(":")
+ manifest = json.loads((layout / "blobs" / algo / h).read_text())
+ calgo, ch = manifest["config"]["digest"].split(":")
+ cfg = json.loads((layout / "blobs" / calgo / ch).read_text())
+ return cfg.get("config", {}).get("Labels") or {}
+
+ def oci_platform_digests(self, layout: Path) -> list[tuple[str, str]]:
+ """Each entry of the index blob is one platform."""
+ d = self.oci_index_digest(layout)
+ algo, h = d.split(":")
+ blob = json.loads((layout / "blobs" / algo / h).read_text())
+ out = []
+ for m in blob["manifests"]:
+ p = m.get("platform", {})
+ if not p.get("os") or not p.get("architecture"):
+ continue
+ name = f"{p['os']}/{p['architecture']}"
+ if p.get("variant"):
+ name += f"/{p['variant']}"
+ out.append((name, m["digest"]))
+ return out
+
+ def verb_docker(self) -> None:
+ self.prepare_tree()
+ ver, out = self.version(), Path(self.args.out)
+ bv = self.pins()["BITCOIN_VERSION"]
+ bitcoin = out / f"cache/bitcoin-{bv}"
+ layoutdir = out / "docker"
+ images = ["lightningd"] + (["lightningd-vls"] if RELEASE_SHIPS_VLS else [])
+ sde = int(time.mktime(time.strptime(self.args.mtime + " +0000", "%Y-%m-%d %z")))
+ created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(sde))
+ platforms = ",".join(self.platform_of(a) for a in self.arch_list(None))
+
+ missing = [str(out / f"clightning-{ver}-static-{a}.tar.xz")
+ for a in self.arch_list(None)
+ if not (out / f"clightning-{ver}-static-{a}.tar.xz").exists()]
+ if not bitcoin.is_dir():
+ missing.append(f"{bitcoin} (run fetch)")
+ if missing:
+ die("missing input(s): " + ", ".join(missing))
+
+ if subprocess.run(["docker", "buildx", "inspect", "cln-builder"],
+ capture_output=True).returncode != 0:
+ run("docker", "buildx", "create", "--name", "cln-builder",
+ "--driver", "docker-container", "--bootstrap")
+ layoutdir.mkdir(parents=True, exist_ok=True)
+ for image in images:
+ shutil.rmtree(layoutdir / image, ignore_errors=True)
+ info(f"docker: building {image} ({platforms})")
+ # The -vls overlay is the only consumer of the vls context.
+ vls_args = (["--build-context", f"vls={out}",
+ "--build-arg", f"VLS_VERSION={self.vls_version()}"]
+ if RELEASE_SHIPS_VLS else [])
+ run("docker", "buildx", "build", "--builder", "cln-builder", "--no-cache",
+ "--platform", platforms, "--target", image,
+ "-f", str(self.top / "Dockerfile"),
+ "--build-context", f"release={out}",
+ "--build-context", f"bitcoin={bitcoin}", *vls_args,
+ "--build-arg", f"VERSION={ver}",
+ "--build-arg", f"SOURCE_DATE_EPOCH={sde}",
+ "--build-arg", f"CREATED={created}",
+ "--build-arg", f"REVISION={self.rev}",
+ "--provenance=false", "--sbom=false",
+ "--output", f"type=oci,tar=false,rewrite-timestamp=true,dest={layoutdir / image}",
+ str(self.top))
+ if not (layoutdir / image / "index.json").exists():
+ die(f"build of {image} produced no layout")
+ # The digests are logged, not recorded as an artifact and not
+ # signed. They are useful to an operator comparing what Docker Hub
+ # ended up with against what was pushed, and they are not evidence
+ # of anything: this image has an unpinned apt step, so nobody can
+ # re-derive these bytes later and a signature over them would
+ # attest less than the signed tarball the image is built from.
+ idx = self.oci_index_digest(layoutdir / image)
+ info(f"docker: {image} index {idx}")
+ for platform, digest in self.oci_platform_digests(layoutdir / image):
+ info(f"docker: {image} {platform} {digest}")
+ if not self.args.no_smoke:
+ self.smoke_images(layoutdir, ver, images)
+
+ def skopeo(self, *args: str, capture: bool = False) -> str:
+ """Ubuntu 22.04's skopeo 1.4.1 lacks --preserve-digests, and pushing
+ without it re-compresses the layers, so what users pull would not be
+ the bytes that were built, smoke-tested and logged here."""
+ host = shutil.which("skopeo")
+ if host and "--preserve-digests" in run(host, "copy", "--help",
+ capture=True, check=False, merge=True):
+ return run(host, *args, capture=capture)
+ out = Path(self.args.out)
+ return run("docker", "run", "--rm", "--network", "host",
+ "-v", f"{out / 'docker'}:{out / 'docker'}:ro",
+ self.pins()["SKOPEO_IMAGE"], *args, capture=capture)
+
+ def smoke_images(self, layoutdir: Path, ver: str, images: list[str]) -> None:
+ """The layout bytes go through a loopback registry (this host's classic
+ image store cannot `docker load` a manifest list), then every platform
+ runs under binfmt."""
+ port = 5000 + os.getpid() % 1000
+ name = f"cln-smoke-registry-{os.getpid()}"
+ subprocess.run(["docker", "rm", "-f", name], capture_output=True)
+ run("docker", "run", "-d", "--rm", "--name", name,
+ "-p", f"127.0.0.1:{port}:5000", "registry:2", capture=True)
+ time.sleep(2)
+ fail = False
+ try:
+ for image in images:
+ ref = f"127.0.0.1:{port}/{image}:{ver}"
+ self.skopeo("copy", "--all", "--preserve-digests",
+ "--dest-tls-verify=false",
+ f"oci:{layoutdir / image}", f"docker://{ref}", capture=True)
+ for arch in self.arch_list(None):
+ platform = self.platform_of(arch)
+ run("docker", "pull", "-q", "--platform", platform, ref, capture=True)
+ got = run("docker", "run", "--rm", "--platform", platform,
+ "--entrypoint", "lightningd", ref, "--version",
+ capture=True, check=False).splitlines()[-1:]
+ if got and got[0] == ver:
+ info(f"ok {image} {platform}: lightningd {got[0]}")
+ else:
+ info(f"FAIL {image} {platform}: lightningd --version -> {got}")
+ fail = True
+ subprocess.run(["docker", "rmi", "-f", ref], capture_output=True)
+ finally:
+ subprocess.run(["docker", "rm", "-f", name], capture_output=True)
+ if fail:
+ die("the image smoke test failed")
+ info("docker: smoke test passed")
+
+ # --- accept, sign, verify --------------------------------------------
+
+ def portability(self, tarballs: list[Path], images: str | None = None) -> bool:
+ """portability.sh on every tarball at once, each run's output printed
+ whole and in order afterwards. The rows are separate containers, and
+ the foreign ones spend their time in qemu, so nothing is gained by
+ waiting for one to finish before starting the next."""
+ extra = [f"--images={images}"] if images else []
+ script = str(self.top / "contrib/reprobuild/portability.sh")
+ procs = [
+ subprocess.Popen(
+ [script, str(t), *extra],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ text=True,
+ errors="replace",
+ )
+ for t in tarballs
+ ]
+ ok = True
+ for p in procs:
+ log, _ = p.communicate()
+ print(log, end="", flush=True)
+ ok = ok and p.returncode == 0
+ return ok
+
+ def verb_accept(self, archs: list[str]) -> None:
+ """The suite that costs real time, kept out of `all` and run by
+ `certify`: the portability rows and the two-tree probe on every row."""
+ ver, out = self.version(), Path(self.args.out)
+ tarballs = []
+ for arch in self.arch_list(archs):
+ tarball = out / f"clightning-{ver}-static-{arch}.tar.xz"
+ if not tarball.exists():
+ die(f"no {tarball}; run build first")
+ tarballs.append(tarball)
+ info(f"accept: portability rows for {' '.join(self.arch_list(archs))}")
+ fail = not self.portability(tarballs)
+ # The probe builds, so it stays one row at a time: the build already
+ # uses every core it is given.
+ for arch in self.arch_list(archs):
+ info(f"accept: two-tree probe for {arch}")
+ probe = [str(self.top / "contrib/reprobuild/two-tree-probe.sh"),
+ f"--arch={arch}", f"--jobs={self.args.jobs}"]
+ if self.args.host_nix:
+ probe.append("--host-nix")
+ if subprocess.run(probe).returncode:
+ fail = True
+ if RELEASE_SHIPS_VLS:
+ die("accept: wire vls-regtest.sh here when VLS returns")
+ if fail:
+ die("the acceptance suite failed")
+ info("accept: OK")
+
+ def manifest_files(self, ver: str, vlsver: str) -> list[str]:
+ """SHA256SUMS- holds every release file: one manifest, every row
+ a co-signer reproduces. (armhf was scoped into a separate manifest
+ while its Rust binaries diverged across machines; the toolchain move
+ fixed that — see the note in the reproducible-builds doc.)"""
+ files = []
+ for arch in self.arch_list(None):
+ files.append(f"clightning-{ver}-static-{arch}.tar.xz")
+ if RELEASE_SHIPS_VLS:
+ files.append(f"remote_hsmd_socket-{vlsver}-{arch}")
+ files.append(f"clightning-{ver}.zip")
+ return files
+
+ def manifest_header(self, ver: str, rev: str, narhash: str) -> str:
+ """What the build consumed: the version string is a label a human
+ picks, the narHash is the content the build consumed and is
+ machine-independent. The VLS pin is identity only when VLS ships."""
+ lines = [f"# Core Lightning {ver}", f"# rev {rev}", f"# narHash {narhash}",
+ "# submodules true", f"# mtime {self.args.mtime}",
+ f"# nixpkgs-certified {self.certified_rev()}"]
+ if RELEASE_SHIPS_VLS:
+ lines += [f"# vls-rev {self.vls_pin('rev')}",
+ f"# vls-vendorHash {self.vls_pin('vendorHash')}"]
+ return "\n".join(lines) + "\n"
+
+ def key_answers(self) -> str:
+ """Sign a throwaway file: the only honest test of the signing key, and
+ the only one that also unlocks a smartcard. Returns "" on success, or
+ gpg's complaint."""
+ with tempfile.TemporaryDirectory() as d:
+ f = Path(d) / "preflight"
+ f.write_text("preflight\n")
+ p = subprocess.run(["gpg", "--batch", "--yes", "--armor",
+ "--detach-sign", "--output", f"{f}.asc", str(f)],
+ capture_output=True, text=True)
+ if not p.returncode:
+ return ""
+ return " ".join(p.stderr.strip().splitlines()[-2:]) or "gpg failed"
+
+ def preflight_sign(self) -> None:
+ """`all` ends in `sign`, and an hour of building that dies on a key
+ nobody could reach is the worst possible ordering.
+
+ With --wait-for-key that ordering is given up on purpose: the operator
+ is not expected to be at the machine when the build starts, so absence
+ stops being an error and becomes something to wait for. The wait polls
+ this same test rather than reading a keypress -- long runs here are
+ started detached, where there is no stdin to read from, but a log to
+ tail; and polling the key is the answer to "is it ready", where a
+ keypress is only a claim that it is."""
+ if self.args.no_sign:
+ return
+ err = self.key_answers()
+ if not err:
+ info("preflight: the signing key answers")
+ return
+ advice = ("If the key is on a smartcard, plug it in and unlock it, then try "
+ "again.\n To build without signing (no release can be published "
+ "this way), pass --no-sign.")
+ if not self.args.wait_for_key:
+ die("the signing key does not answer, and this run would end in a "
+ f"signature:\n {err}\n {advice}\n To wait for it instead of "
+ "failing, pass --wait-for-key.")
+ limit = self.args.wait_for_key
+ info(f"WAITING for the signing key -- plug it in and unlock it. "
+ f"Giving up after {limit}s. (Ctrl-C to abort.)")
+ info(f" gpg says: {err}")
+ start, nagged = time.monotonic(), 0.0
+ while True:
+ waited = time.monotonic() - start
+ if waited >= limit:
+ die(f"the signing key still does not answer after {int(waited)}s.\n"
+ f" {err}\n {advice}")
+ time.sleep(min(KEY_POLL_SECONDS, limit - waited))
+ err = self.key_answers()
+ if not err:
+ info(f"the signing key answers after {int(time.monotonic() - start)}s")
+ return
+ if time.monotonic() - start - nagged >= 60:
+ nagged = time.monotonic() - start
+ info(f" still waiting for the signing key ({int(nagged)}s of {limit}s)")
+
+ def verb_sign(self) -> None:
+ # Tree first, key second: the tree check is instant, and --wait-for-key
+ # can block for half an hour. Summoning someone to unlock a smartcard
+ # and then refusing the run for a dirty tree is the wrong order.
+ self.prepare_tree()
+ self.preflight_sign()
+ ver, vlsver, out = self.version(), self.vls_version(), Path(self.args.out)
+ if not out.is_dir():
+ die(f"no {out}; run build/vls/zip/docker first")
+ mf = out / f"SHA256SUMS-{ver}"
+ files = self.manifest_files(ver, vlsver)
+ missing = [f for f in files
+ if not (out / f).exists() and not (out / "docker" / f).exists()]
+ if missing:
+ die(f"cannot sign {mf.name}, missing: {' '.join(missing)}")
+ # The identity is the artifacts' own, not the working tree's.
+ rev, narhash = self.provenance_of(files)
+ self.rev = rev
+ body = self.manifest_header(ver, rev, narhash)
+ for f in files:
+ path = out / "docker" / f if (out / "docker" / f).exists() else out / f
+ body += f"{sha256(path)} {f}\n"
+ mf.write_text(body)
+ # The VLS binaries are named by *their* version, so a
+ # release-version glob misses them; assert the count instead.
+ want = len(self.arch_list(None)) if RELEASE_SHIPS_VLS else 0
+ got = body.count(" remote_hsmd_socket-")
+ if got != want:
+ die(f"{mf.name} lists {got} VLS binaries, expected {want}")
+ info(f"wrote {mf} ({len(files)} files, {got} VLS)")
+ if self.args.no_sign:
+ info(f"--no-sign: {mf.name} left unsigned (publish will refuse it)")
+ else:
+ asc = Path(f"{mf}.asc")
+ asc.unlink(missing_ok=True)
+ run("gpg", "--armor", "--detach-sign", "--output", str(asc), str(mf))
+ info(f"signed {asc}")
+
+ def verb_verify(self, manifest: str) -> None:
+ """Per manifest, not per release: a mismatch prints the hashes and
+ withholds the signature; resolving it is manual between captain and
+ co-signer, and no automated triage is owed. Releases published while
+ armhf carried its own `-armhf` manifest still verify here: a mismatch
+ in such a legacy manifest withholds that signature without holding
+ the release, which is how it was signed back then."""
+ mf = Path(manifest).resolve()
+ if not mf.is_file():
+ die("usage: tools/reprobuild verify ")
+ base = mf.name
+ ver = base.removeprefix("SHA256SUMS-").removesuffix("-armhf")
+ self._version = ver
+ # Everything the build consumed comes out of the manifest, not out of
+ # whatever the co-signer happens to have checked out.
+ head = dict(re.findall(r"^# (\w[\w-]*) (.*)$", mf.read_text(), re.M))
+ mrev, mmtime = head.get("rev"), head.get("mtime")
+ if not mrev or not mmtime:
+ die(f"{base} has no '# rev'/'# mtime' line; it was written by an older driver")
+ if subprocess.run(["git", "-C", str(self.top), "cat-file", "-e", f"{mrev}^{{commit}}"],
+ capture_output=True).returncode:
+ die(f"commit {mrev} is not in this checkout.\n"
+ " Fetch the tag first: git fetch origin tag .")
+ self.args.mtime, self.rev = mmtime, mrev
+ self.flake_ref = f"git+file://{self.top}?submodules=1&rev={mrev}"
+ info(f"verify: rebuilding {mrev} (mtime {mmtime}) as {base} names it")
+
+ archs = [a for a in self.arch_list(None)
+ if f"clightning-{ver}-static-{a}.tar.xz" in mf.read_text()]
+ if not archs:
+ die(f"{base} lists no tarball this matrix knows")
+ info(f"verify {base}: rows {' '.join(archs)} (version {ver})")
+ self.build_release(
+ archs,
+ vls=RELEASE_SHIPS_VLS,
+ zip_=f" clightning-{ver}.zip" in mf.read_text(),
+ )
+
+ out, bad = Path(self.args.out), []
+ for line in mf.read_text().splitlines():
+ if line.startswith("#") or not line.strip():
+ continue
+ want, name = line.split(maxsplit=1)
+ name = name.strip().lstrip("*")
+ path = out / name
+ if not path.exists():
+ info(f"MISSING {name}")
+ bad.append(name)
+ elif sha256(path) == want:
+ info(f"ok {name}")
+ else:
+ info(f"DIFFERS {name}")
+ info(f" captain: {want}")
+ info(f" here: {sha256(path)}")
+ bad.append(name)
+
+ if bad:
+ if base.endswith("-armhf"):
+ info(f"armhf manifest differs: {' '.join(bad)}")
+ info(f"signature WITHHELD for {base} -- a legacy split manifest; "
+ "for that release an armhf mismatch did not gate anything")
+ return
+ die(f"manifest differs: {' '.join(bad)}\n"
+ " Signature withheld. Retract the unverified hashes, fix the cause\n"
+ " and retry with the captain until the hashes match.")
+ if self.args.no_sign:
+ info("every file reproduced; --no-sign, so no signature was written")
+ return
+ keys = run("gpg", "--list-secret-keys", "--with-colons", capture=True, check=False)
+ fpr = next((ln.split(":")[9] for ln in keys.splitlines() if ln.startswith("fpr:")), "")
+ if not fpr:
+ die("no secret key to sign with")
+ asc = Path(f"{self.args.out}/{base}.asc.{fpr[-16:]}")
+ asc.unlink(missing_ok=True)
+ run("gpg", "--armor", "--detach-sign", "--output", str(asc), str(mf))
+ info(f"every file reproduced; wrote {asc}")
+
+ # --- certify, publish, all --------------------------------------------
+
+ def verb_certify(self, no_verify: bool) -> None:
+ """Certification is an intentional act, kept out of `all`: re-pin the
+ certified nixpkgs rev and the input manifests, then build every row
+ from source with substitution off, so cache.nixos.org is *checked*
+ once per certification rather than trusted forever."""
+ self.prepare_tree()
+ locked = self.nix("eval", "--raw", "--impure", "--expr",
+ f'(builtins.getFlake "{self.flake_ref}").inputs.nixpkgs.rev',
+ capture=True)
+ if not locked:
+ die("cannot read the locked nixpkgs rev")
+ current = self.certified_rev()
+ if locked == current:
+ info(f"certify: nix/release-rows already names {locked}")
+ else:
+ info(f"certify: {current} -> {locked}")
+ text = re.sub(r"^@nixpkgs .*$", f"@nixpkgs {locked}",
+ self.rows_file.read_text(), flags=re.M)
+ self.rows_file.write_text(text)
+ info("certify: re-pinned nix/release-rows (commit it)")
+ # The input manifests come from the *unguarded* attributes, since the
+ # guard is exactly what a stale manifest trips.
+ for arch in self.arch_list(None):
+ for kind in ("cln", "vls"):
+ name = f"{kind}-{arch}"
+ text = self.nix("eval", "--raw", "--impure", "--expr",
+ f'(builtins.getFlake "{self.flake_ref}")'
+ f".legacyPackages.x86_64-linux.release.manifests.{name}",
+ capture=True)
+ # The trailing newline matters: the guard compares the file
+ # against the derivation's string with builtins.readFile, and
+ # run() strips what it captures, so a manifest written without
+ # it could never match and certify would leave the guard
+ # tripped in exactly the state it exists to clear.
+ (self.top / "nix/release-manifests" / name).write_text(
+ text if text.endswith("\n") else text + "\n")
+ info(f"certify: wrote nix/release-manifests/{name}")
+ info("certify: re-pinned rows and manifests; commit them before building")
+ if no_verify:
+ info("certify: --no-verify, skipping the from-source build and the suite")
+ return
+ info("certify: building every row from source (substituters off)")
+ self.substitute = False
+ self.verb_build(["all"])
+ self.verb_accept(["all"])
+ info("certify: from-source build and acceptance suite passed")
+ info("certify: the nix copy of the source closures into the bucket is still owed")
+
+ def good_sigs(self, manifest: Path, sigprefix: Path) -> int:
+ """Count good signatures from the committed keyring, the way `fetch`
+ counts them over Bitcoin Core's: gpg's exit status answers a different
+ question, since a file may carry signatures from keys we do not vendor."""
+ n = 0
+ with tempfile.TemporaryDirectory() as home:
+ env = {**os.environ, "GNUPGHOME": home}
+ for key in sorted((self.top / "contrib/keys").glob("*.txt")):
+ subprocess.run(["gpg", "--batch", "--quiet", "--import", str(key)],
+ env=env, capture_output=True)
+ for sig in sorted(sigprefix.parent.glob(sigprefix.name + "*")):
+ p = subprocess.run(["gpg", "--batch", "--status-fd", "1", "--verify",
+ str(sig), str(manifest)],
+ env=env, capture_output=True, text=True)
+ if "[GNUPG:] BADSIG " in p.stdout:
+ die(f"BAD signature: {sig}")
+ if "[GNUPG:] VALIDSIG " in p.stdout:
+ n += 1
+ return n
+
+ def verb_publish(self) -> None:
+ """Everything a release makes public, in one go: the tarballs, manifests
+ and source zip to the download host, the images to Docker Hub, the tag to
+ GitHub, and the GitHub release itself.
+
+ One verb on purpose. Binaries and source go out together, so there is
+ nothing for a second verb to express, and splitting it would only offer
+ ways to half-publish a release.
+
+ The order is least-reversible-last: an upload can be deleted, a Docker
+ Hub push is awkward to undo, and a pushed tag is public forever. The
+ upload is read back and checked against the signed manifest before the
+ tag goes anywhere.
+ """
+ self.prepare_tree()
+ ver, vlsver, out = self.version(), self.vls_version(), Path(self.args.out)
+ main = out / f"SHA256SUMS-{ver}"
+ armhf = out / f"SHA256SUMS-{ver}-armhf"
+ if not main.exists():
+ die(f"no {main}; run sign first")
+ tag = run("git", "-C", str(self.top), "tag", "--points-at", "HEAD",
+ capture=True).split("\n")[0]
+ if tag != ver:
+ die(f"HEAD is tagged '{tag}', not '{ver}'")
+ # ...and the artifacts must come from that commit: `sign` only proved
+ # they came from *one* tree.
+ mrev = next((ln.split()[2] for ln in main.read_text().splitlines()
+ if ln.startswith("# rev ")), "")
+ tagrev = run("git", "-C", str(self.top), "rev-parse", f"{ver}^{{commit}}", capture=True)
+ if mrev != tagrev:
+ die(f"{main.name} was built from {mrev}, but {ver} is {tagrev}.\n"
+ " Rebuild from the tag, or publish the tag those artifacts came from.")
+ if subprocess.run(["git", "-C", str(self.top), "ls-remote", "--exit-code",
+ "--tags", "origin", f"refs/tags/{ver}"],
+ capture_output=True).returncode == 0:
+ die(f"{ver} is already on the GitHub remote; refusing to publish it twice")
+ # A tag push publishes the pyln modules on its own schedule, and this
+ # verb pushes a tag. Checked first, because it is the one precondition
+ # that cannot be fixed after the upload has happened.
+ if shutil.which("gh"):
+ state = run("gh", "workflow", "view", "Release 🚀", "--json", "state",
+ "--jq", ".state", capture=True, check=False) or "unknown"
+ if state.startswith("disabled"):
+ info(f'publish: "Release 🚀" is {state}')
+ elif state == "unknown":
+ info('publish: WARNING: cannot read the "Release 🚀" state; check by hand')
+ else:
+ die(f'the "Release 🚀" workflow is {state}.\n'
+ ' Run: gh workflow disable "Release 🚀"\n'
+ " Re-enable it afterwards.")
+ else:
+ info('publish: WARNING: no gh; check the "Release 🚀" workflow by hand')
+
+ n = self.good_sigs(main, Path(f"{main}.asc"))
+ if n < 3:
+ die(f"only {n} good signature(s) on {main.name}; three are required")
+ info(f"publish: {n} good signatures on {main.name}")
+ if armhf.exists():
+ na = self.good_sigs(armhf, Path(f"{armhf}.asc"))
+ info(f"publish: {na} good signature(s) on {armhf.name} (a legacy split "
+ "manifest; current releases stage exactly one)")
+
+ # The staging dir is the whole upload: debug/ and cache/ are excluded
+ # by construction, not by a filter.
+ stage = out / "publish" / ver
+ shutil.rmtree(stage, ignore_errors=True)
+ stage.mkdir(parents=True)
+ for f in self.manifest_files(ver, vlsver):
+ shutil.copyfile(out / f, stage / f)
+ for mf in (main, armhf):
+ if mf.exists():
+ shutil.copyfile(mf, stage / mf.name)
+ for asc in mf.parent.glob(mf.name + ".asc*"):
+ shutil.copyfile(asc, stage / asc.name)
+ info(f"publish: staged {len(list(stage.iterdir()))} files in {stage}")
+
+ v = self.publish_vars()
+ base = v["PUBLISH_BASE_URL"]
+ rclone = self.rclone_args(v)
+ # Object versioning is off by decision, so immutability is a driver
+ # rule: refuse rather than overwrite a prefix that already exists.
+ listing = run(*rclone, "lsf", f":s3:{v['REPRO_S3_BUCKET']}/{ver}/",
+ capture=True, check=False)
+ if listing.strip():
+ die(f"{base}/{ver}/ already has objects; refusing to overwrite")
+ run(*rclone, "copy", str(stage), f":s3:{v['REPRO_S3_BUCKET']}/{ver}/")
+ info(f"publish: uploaded to {base}/{ver}/")
+
+ # Read back what we just uploaded and check it against the manifest.
+ # rclone reporting success is not the same as the bytes being right,
+ # and this is the last moment before the tag makes the release real.
+ with tempfile.TemporaryDirectory() as d:
+ for line in main.read_text().splitlines():
+ if line.startswith("#") or not line.strip():
+ continue
+ want, name = line.split(maxsplit=1)
+ name = name.strip().lstrip("*")
+ dest = Path(d) / name
+ run("curl", "-fsSL", "-o", str(dest), f"{base}/{ver}/{name}")
+ if sha256(dest) != want:
+ die(f"{name} on the download host does not match the manifest")
+ info(f"publish: verified on the download host {name}")
+
+ # Images next: an upload can be deleted, a Docker Hub push cannot.
+ # --all copies every platform, --preserve-digests keeps the bytes that
+ # were built and smoke-tested.
+ #
+ # The layout used to be checked against a recorded index digest. That
+ # digest is gone, because the image build has an unpinned apt step and a
+ # signature over bytes nobody can re-derive attests less than the signed
+ # tarball the image is built from. What is checkable, and what the old
+ # guard was really protecting against, is staleness: that this layout is
+ # the one built for *this* release, from *this* commit. The image's own
+ # OCI labels answer that.
+ repo, layoutdir = "docker.io/elementsproject/", out / "docker"
+ images = ["lightningd"] + (["lightningd-vls"] if RELEASE_SHIPS_VLS else [])
+ for image in images:
+ layout = layoutdir / image
+ if not layout.is_dir():
+ die(f"no OCI layout at {layout}; run docker first")
+ for platform, _ in self.oci_platform_digests(layout):
+ labels = self.oci_image_labels(layout, platform)
+ lver = labels.get("org.opencontainers.image.version", "")
+ lrev = labels.get("org.opencontainers.image.revision", "")
+ if lver != ver:
+ die(f"{image} {platform}: the layout says version {lver!r}, not "
+ f"{ver!r}. It is from another release; run docker again.")
+ if lrev != mrev:
+ die(f"{image} {platform}: the layout was built from {lrev!r}, but "
+ f"{main.name} was built from {mrev!r}. Run docker again.")
+ idx = self.oci_index_digest(layout)
+ info(f"publish: pushing {image}:{ver} ({idx}), labels match {mrev[:12]}")
+ self.skopeo("copy", "--all", "--preserve-digests",
+ f"oci:{layout}", f"docker://{repo}{image}:{ver}")
+ if self.args.latest:
+ if "rc" in ver:
+ die(f"refusing --latest on an rc tag ({ver})")
+ suffix = "-vls" if image == "lightningd-vls" else ""
+ info(f"publish: tagging latest{suffix}")
+ self.skopeo("copy", "--all", "--preserve-digests",
+ f"oci:{layout}", f"docker://{repo}lightningd:latest{suffix}")
+
+ # The tag last: it is the one step that cannot be taken back.
+ run("git", "-C", str(self.top), "push", "origin", ver)
+ info(f"publish: pushed tag {ver}")
+ if shutil.which("gh"):
+ notes = (f"Reproducible release artifacts: {base}/{ver}/\n\n"
+ f"Verify with: sha256sum -c SHA256SUMS-{ver}")
+ assets = [str(out / f"clightning-{ver}.zip"), str(main),
+ *map(str, out.glob(f"{main.name}.asc*"))]
+ if armhf.exists():
+ assets += [str(armhf), *map(str, out.glob(f"{armhf.name}.asc*"))]
+ with tempfile.NamedTemporaryFile("w", suffix=".md") as nf:
+ nf.write(notes)
+ nf.flush()
+ # As a draft, deliberately. Everything before this point is
+ # already public -- the artifacts are on the download host and
+ # the tag is pushed -- but the release page is the thing people
+ # read, and the runbook has always had the captain check it and
+ # publish it by hand. Creating it published would skip that
+ # step silently.
+ run("gh", "release", "create", ver, "--draft", "--title", ver,
+ "--notes-file", nf.name, *assets)
+ info("publish: created the GitHub release as a DRAFT -- review it "
+ "and publish it by hand")
+ else:
+ info("publish: no gh; create the GitHub release by hand")
+ info('publish: done. REMEMBER to re-enable the "Release 🚀" workflow')
+
+ def verb_all(self) -> None:
+ # Normally first, to fail before an hour of building. --wait-for-key
+ # trades that away deliberately: the key is expected to arrive later,
+ # so the wait belongs in `sign`, not here.
+ if not self.args.wait_for_key:
+ self.preflight_sign()
+ self.verb_fetch()
+ self.build_release(["all"], vls=RELEASE_SHIPS_VLS, zip_=True)
+ self.verb_docker()
+ self.verb_sign()
+ # Last: the binaries that were just signed, unpacked and run on a
+ # current distro. One container per row; `accept` runs the full matrix.
+ ver = self.version()
+ archs = self.arch_list(None)
+ info(f"all: smoke test on {RELEASE_SMOKE_IMAGE} ({' '.join(archs)})")
+ if not self.portability(
+ [
+ Path(self.args.out) / f"clightning-{ver}-static-{a}.tar.xz"
+ for a in archs
+ ],
+ RELEASE_SMOKE_IMAGE,
+ ):
+ die("the smoke test failed")
+ info("all: done -- publish is a separate, deliberate verb")
+
+
+def main() -> None:
+ top = Path(run("git", "rev-parse", "--show-toplevel", capture=True))
+ p = argparse.ArgumentParser(
+ prog="reprobuild", description=__doc__,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+ p.add_argument("--version", help="release version (default: git describe --tags)")
+ p.add_argument("--mtime", default=None,
+ help="timestamp baked into artifacts, YYYY-MM-DD "
+ "(default: the built commit's date, UTC)")
+ p.add_argument("--jobs", type=int, default=os.cpu_count() or 4)
+ p.add_argument("--host-nix", action="store_true",
+ help="use the host's nix instead of the pinned container")
+ p.add_argument("--store-dir", help="the container's nix store")
+ p.add_argument("--out", default=str(top / "release"), help="where artifacts land")
+ p.add_argument("--rebuild", action="store_true",
+ help="also run `nix build --rebuild` on what was just built")
+ p.add_argument("--allow-dirty", action="store_true",
+ help="build from an uncommitted tree; never valid for a release")
+ p.add_argument("--no-sign", action="store_true",
+ help="write the manifests but do not gpg-sign them")
+ p.add_argument("--wait-for-key", nargs="?", type=int, const=1800, default=0,
+ metavar="SECONDS",
+ help="if the signing key does not answer, wait for it instead "
+ "of failing (default 1800s). `all` then skips its up-front "
+ "key check and waits when it reaches sign, so the build "
+ "needs nobody at the machine until there is something to "
+ "sign")
+ p.add_argument("--no-smoke", action="store_true",
+ help="skip the image smoke test in `docker`")
+ p.add_argument("--latest", action="store_true",
+ help="publish: also tag latest (never on an rc, never implied)")
+ p.add_argument("--no-verify", action="store_true",
+ help="certify: regenerate the rows and manifests only, "
+ "skipping the from-source build and the acceptance suite")
+ p.add_argument("verb", choices=["fetch", "build", "vls", "zip", "docker", "sign",
+ "verify", "certify", "publish", "accept", "all"])
+ p.add_argument("rest", nargs="*", metavar="archs|manifest",
+ help="`all` or arch tokens from nix/release-rows; "
+ "verify takes a manifest")
+ args = p.parse_args()
+
+ d = Driver(args=args, top=top)
+ rest = list(args.rest)
+ match args.verb:
+ case "fetch": d.verb_fetch()
+ case "build": d.verb_build(rest)
+ case "vls": d.verb_vls(rest)
+ case "zip": d.verb_zip()
+ case "docker": d.verb_docker()
+ case "sign": d.verb_sign()
+ case "verify": d.verb_verify(rest[0] if rest else "")
+ case "certify": d.verb_certify(args.no_verify)
+ case "publish": d.verb_publish()
+ case "accept": d.verb_accept(rest)
+ case "all": d.verb_all()
+
+
+if __name__ == "__main__":
+ main()