Skip to content

Build fixes for nix + a rust check error - #9423

Merged
nepet merged 3 commits into
ElementsProject:masterfrom
niftynei:nifty/python-build-fix
Oct 27, 2026
Merged

nepet merged 3 commits into
ElementsProject:masterfrom
niftynei:nifty/python-build-fix

Conversation

@niftynei

Copy link
Copy Markdown
Collaborator

Handful of bugfixes:

  • When building CLN on NixOS (outside of the uv runner), you run into issues with the python scripts we use for building. By falling back to a python type in the absence of uv, we can fix this error. We were masking over it in the built-in nix builds.
  • Getting the nix builds running on MacOS unearthed an issue with lowdown attempting to spawn a sandbox within a sandbox. We resolve this by telling lowdown not to spawn a sandbox when it's running in a nixos build.
  • nix build .#default unearthed an issue with the Rust tests masking overflow errors.

@niftynei
niftynei requested a review from cdecker as a code owner August 15, 2026 22:40
@niftynei niftynei changed the title Nifty/python build fix Build fixes for nix + a rust check error Aug 15, 2026
Builds on NixOS are failing due to lack of python configuration

> PYTHONPATH=contrib/msggen  contrib/msggen/msggen/__main__.py bundle doc/schemas
       > /nix/store/rlq03x4cwf8zn73hxaxnx0zn5q9kifls-bash-5.3p3/bin/bash: line 1: contrib/msggen/msggen/__main__.py: Permission denied
              > make: *** [contrib/msggen/Makefile:15: contrib/msggen/msggen/schema.json] Error 126

We can: fail if not configured and use the local python3 path
if/when `uv` doesn't work.

We also add an error when PYTHON isn't configured, and remove the
local override for the nix setup (since it should be fixed now).

Changelog-Fixed: nix-builds: correctly set PYTHON in case where `uv` is not present
When running `nix build .#default -L` I came across two failures:

> failures:
>
> ---- primitives::test::test_amount_add_overflow stdout ----
> note: test did not panic as expected at cln-rpc/src/primitives.rs:1064:8
> ---- primitives::test::test_amount_sub_overflow stdout ----
> note: test did not panic as expected at cln-rpc/src/primitives.rs:1057:8
>
> failures:
>     primitives::test::test_amount_add_overflow
>     primitives::test::test_amount_sub_overflow
>
> test result: FAILED(B. 36 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

Rather than wrapping silently, we now error.

Changelog-Fixed: rust: Amounts that overflow fail, don't silently ignore in release builds
We're already in a sandbox when you're running `nix build`.
MacOS explicitly disallows nested sandboxes. If on Darwin and
running in a nix sandbox, we explicitly disable the `lowdown` sandbox

Changelog-Fixed: macos: builds with lowdown succeed, as we no longer attempt to spawn a nested sandbox
@nepet
nepet force-pushed the nifty/python-build-fix branch from 0e05bc1 to 6f01e33 Compare October 26, 2026 15:22

@nepet nepet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK 6f01e33

Thanks @niftynei!

  • nix build .#cln succeeds on aarch64-darwin (nix sandbox off) and aarch64-linux (nixos/nix container, sandbox on). lightningd --version reports v26.06.6 and all 22 plugins are installed, including cln-grpc and clnrest.
  • test_amount_{add,sub}_overflow pass under crane's cargo test --release on both.
  • With #8950 on top, nix develop + ./configure && make works on Linux. configure now picks PYTHON=python3 through the new fallback (d835a5a), where on master it ends up empty.

Non-blocking suggestion for 6f01e33: nixpkgs already ships this as lowdown-unsandboxed (built with enableDarwinSandbox = false). nixpkgs' own nix package uses it on darwin, it's in cache.nixos.org for both darwin archs (so no local lowdown rebuild), and on Linux it's the same store path as lowdown. The lowdownForBuild block could become:

    # lowdown calls sandbox_init() on darwin, which fails inside a nix build.
    lowdown-unsandboxed

That also drops the --replace-fail against lowdown's main.c, which will break on a future lowdown bump.

FYI on 2e3d221: for downstream users of the cln-rpc crate, an Amount overflow now panics in release builds instead of silently wrapping, and checked_add/checked_sub become public API. I think both are right.

@nepet
nepet merged commit ba3bd7d into ElementsProject:master Oct 27, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants