Skip to content

Commit cd438cc

Browse files
committed
Add dev shell flake and justfile for local checks
Introduce a Nix dev shell and a justfile so work on this fork has a reproducible toolchain and a one-command local gate, mirroring the setup in the ldk-node repo. The toolchain is pinned to stable 1.90.0 via fenix rather than tracking latest. The version is bounded on both ends: clippy must be at least 1.87 so ci/check-lint.sh can resolve the lint names it allows (older clippy hard-errors on the unknown clippy::manual_is_multiple_of), but 1.92+ adds clippy::assertions_on_constants which fires on existing code in lightning/src/chain/channelmonitor.rs and would break -D warnings on the inherited tree. 1.90.0 sits in that window and matches what CI's stable resolves to today. fenix is used over rust-overlay because it pins an exact channel by hash, so the shell can't drift. just check only compiles and runs the workspace test suite. It deliberately skips clippy and rustfmt: this branch is not clean under either of CI's gates (pre-existing dead code in lsps2/lsps4 trips check-lint.sh's -D warnings, and the tree predates the pinned rustfmt), and reformatting or de-linting code we don't own is out of scope.
1 parent aad7c22 commit cd438cc

4 files changed

Lines changed: 200 additions & 0 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

flake.lock

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
description = "Rust Lightning Development Environment";
3+
4+
inputs = {
5+
# Nixpkgs channel. New channels are released every 6 months.
6+
# See: https://github.com/NixOS/nixpkgs/tags
7+
nixpkgs.url = "github:nixos/nixpkgs/25.11";
8+
9+
# This makes it easy for the flake to be multi-platform.
10+
# See: https://github.com/numtide/flake-utils
11+
flake-utils.url = "github:numtide/flake-utils";
12+
13+
# Provides pinned Rust toolchains.
14+
# See: https://github.com/nix-community/fenix
15+
fenix = {
16+
url = "github:nix-community/fenix";
17+
inputs.nixpkgs.follows = "nixpkgs";
18+
};
19+
};
20+
21+
outputs =
22+
{
23+
self,
24+
nixpkgs,
25+
flake-utils,
26+
fenix,
27+
}:
28+
flake-utils.lib.eachDefaultSystem (
29+
system:
30+
let
31+
pkgs = import nixpkgs { inherit system; };
32+
33+
# Pinned stable toolchain. The version is deliberately bounded:
34+
# * clippy must be >= 1.87 so `./ci/check-lint.sh` resolves the lints it
35+
# `-A`s (e.g. `clippy::manual_is_multiple_of`); older clippy E0602s on the
36+
# unknown lint name.
37+
# * but NOT 1.92+, whose clippy grows `assertions_on_constants` (fires on
38+
# `assert!(cfg!(fuzzing), ..)` in lightning/src/chain/channelmonitor.rs)
39+
# and would break `-D warnings` on the pre-existing tree.
40+
# 1.90.0 sits in that window and matches what CI's `stable` resolves to.
41+
rust-toolchain =
42+
(fenix.packages.${system}.toolchainOf {
43+
channel = "1.90.0";
44+
sha256 = "sha256-SJwZ8g0zF2WrKDVmHrVG3pD2RGoQeo24MEXnNx5FyuI=";
45+
}).withComponents
46+
[
47+
"rustc"
48+
"cargo"
49+
"clippy"
50+
"rustfmt"
51+
"rust-src" # Needed for the rust-analyzer extension to work.
52+
];
53+
in
54+
{
55+
# The default development shell. Use `nix develop` or direnv to enter it.
56+
devShells.default = pkgs.mkShell {
57+
name = "rust-lightning-dev-shell";
58+
59+
packages = [
60+
rust-toolchain
61+
]
62+
++ (with pkgs; [
63+
just # Command runner
64+
nodejs # JavaScript runtime, required for MCP tools
65+
mold # Fast linker for Rust/C/C++
66+
pnpm # Package manager for JavaScript, required for MCP tools
67+
stdenv.cc.cc.lib # C++ standard library for runtime
68+
]);
69+
70+
env = {
71+
# OpenSSL configuration for Nix
72+
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
73+
# C++ standard library path for runtime
74+
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
75+
};
76+
77+
shellHook = ''
78+
echo "Rust Lightning dev shell"
79+
rustc --version
80+
cargo --version
81+
'';
82+
};
83+
}
84+
);
85+
}

justfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default:
2+
@just --list --unsorted
3+
4+
# Run all code quality checks. TODO: Add format and linting when branch is clean
5+
check:
6+
RUSTFLAGS="--cfg=lsps1_service" cargo test --workspace
7+
8+
# Run just the tests
9+
test:
10+
RUSTFLAGS="--cfg=lsps1_service" cargo test --workspace
11+
12+
# Format all sources in place.
13+
fmt:
14+
cargo fmt --all

0 commit comments

Comments
 (0)