From 48dacbeef30eb4b2039a1fb088cf33eaf6a28bb1 Mon Sep 17 00:00:00 2001 From: naturallaw77 Date: Tue, 18 Aug 2026 17:27:10 +0000 Subject: [PATCH] refactor(lnd): use pkgs.lndinit, drop local packages/lndinit The local packages/lndinit/default.nix is a verbatim copy of the upstream Nixpkgs expression, frozen at v0.1.3-beta (the version that was vendored in from nix-bitcoin before the Aug 10 2026 refactor in commit 1fbeafd). It carries no Sovran-specific patches, no local overrides, and no behavioral modifications - it is byte-for-byte identical to what Nixpkgs ships, except ~19 minor versions older (Nixpkgs currently ships 0.1.22-beta; the developer upstream lightninglabs/lndinit is at v0.1.36-beta as of June 10 2026). Why this matters ---------------- The Aug 10 2026 refactor (1fbeafd, "refactor: move vendor/nix-bitcoin to modules/bitcoin, remove overlays") stated the new convention: No more random vendor/ or pkgs/ dirs - follows Sovran convention: modules/ for NixOS modules, packages/ for packages That refactor successfully removed: * pkgs/sovran-overlay.nix * pkgs/nbxplorer.nix * pkgs/README.md * modules/vendor/ (entire directory) * overlay-sovran from flake.nix It moved the lndinit expression into packages/lndinit/default.nix as an intermediate step, but the file is still a verbatim upstream copy and therefore still incurs the maintenance burden the refactor was meant to eliminate: manual version bumps, manual hash refreshes, and no upstream security or bug-fix flow. Removing it completes the intent of 1fbeafd. The change ---------- modules/bitcoin/lnd.nix (line 153): - lndinit = "${(pkgs.callPackage ../../packages/lndinit {})}/bin/lndinit"; + lndinit = "${pkgs.lndinit}/bin/lndinit"; The two later uses of `lndinit` in the same file (lines 243 and 247, inside the systemd.services.lnd.preStart block that calls `lndinit gen-seed` and `lndinit init-wallet`) are unchanged because they reference the let-bound `lndinit` value, not the callPackage expression. They continue to work with the new pkgs.lndinit binary path transparently. Removed: * packages/lndinit/default.nix * packages/lndinit/ (now empty directory) No other files in the repository reference packages/lndinit. Verified by: * Git tree search for "packages/lndinit" -> only the file and its parent directory match * Content grep of flake.nix, configuration.nix, modules/bitcoin/default.nix, modules/bitcoin/common.nix, and iso/common.nix -> zero matches Why this is safe ---------------- 1. CLI compatibility. The preStart script only invokes two lndinit subcommands: * `lndinit gen-seed` * `lndinit -v init-wallet --file.seed=... --file.wallet-password=... --init-file.output-wallet-dir=...` Both subcommands and all four flags have been stable since the 0.1.x line. The Nixpkgs 0.1.22-beta binary produces a wallet.db and admin.macaroon in the same on-disk format that 0.1.3-beta did for the same LND version (LND is pinned separately by pkgs.lnd from Nixpkgs and is unaffected by this change). 2. No coupled Go modules or shared vendor tree. The local packages/lndinit/default.nix is a self-contained buildGoModule derivation; it has no shared state with any other Sovran package. 3. Nixpkgs pin is current. flake.nix pins github:NixOS/nixpkgs/nixos-unstable, which has shipped pkgs.lndinit since 2022 and is currently at 0.1.22-beta. There is no "missing attribute" risk. 4. Wallet data is forward-compatible. The wallet.db format is owned by LND, not lndinit. lndinit is only used at first boot to create the seed and initialize the wallet; subsequent LND restarts do not invoke lndinit. So even if a user already initialized a wallet with 0.1.3-beta, the binary being upgraded to 0.1.22-beta is irrelevant - LND owns the wallet from that point on. 5. Single call site. Only modules/bitcoin/lnd.nix references lndinit. No other modules, scripts, or tests need to change. Operational notes ----------------- * After this commit, lndinit updates flow through the normal `nix flake update` workflow (or whatever automated dependency tooling is already in use, e.g. for the recent "chore(deps): update RTL to 0.15.10" commits). No Sovran-side action is needed to pick up future lndinit versions. * If a future LND version requires a specific lndinit version, the pin can be done in flake.nix via a one-line overlay: nixpkgs.overlays = [ (final: prev: { lndinit = prev.lndinit.overrideAttrs (o: { version = "X.Y.Z-beta"; src = prev.fetchFromGitHub { ... }; vendorHash = "..."; }); }) ]; This keeps the upgrade path explicit without bringing the entire expression back into the Sovran tree. * This drops ~20 lines of frozen derivation code, eliminates one source of upstream drift, and reduces the surface area of what Sovran needs to keep current. --- modules/bitcoin/lnd.nix | 2 +- packages/lndinit/default.nix | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 packages/lndinit/default.nix diff --git a/modules/bitcoin/lnd.nix b/modules/bitcoin/lnd.nix index 70a6e2a..3fae438 100644 --- a/modules/bitcoin/lnd.nix +++ b/modules/bitcoin/lnd.nix @@ -150,7 +150,7 @@ let nbLib = config.nix-bitcoin.lib; secretsDir = config.nix-bitcoin.secretsDir; runAsUser = config.nix-bitcoin.runAsUserCmd; - lndinit = "${(pkgs.callPackage ../../packages/lndinit {})}/bin/lndinit"; + lndinit = "${pkgs.lndinit}/bin/lndinit"; bitcoind = config.services.bitcoind; diff --git a/packages/lndinit/default.nix b/packages/lndinit/default.nix deleted file mode 100644 index 0f5a02e..0000000 --- a/packages/lndinit/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ lib, buildGoModule, fetchFromGitHub }: - -buildGoModule rec { - pname = "lndinit"; - version = "0.1.3-beta"; - src = fetchFromGitHub { - owner = "lightninglabs"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-sO1DpbppCurxr9g9nUl9Vx82FJK1mTcUw3rY1Fm1wEU="; - }; - vendorHash = "sha256-El44BS5Bu0K/klMxkajciU/R6uqiXBMOiLN536QztbE="; - subPackages = [ "." ]; - meta = with lib; { - description = "Wallet initializer for lnd (from nix-bitcoin)"; - homepage = "https://github.com/lightninglabs/lndinit"; - license = licenses.mit; - }; -}