Repository navigation
Keep unreleased migration notices visible on master - #283
Conversation
6a51a68 to
91a4650
Compare
Use root version.nix to record the latest finalized release and keep it at 0.1.6 during development. Warn about applicable unreleased migrations even after an early configVersion bump; released migrations still block until acknowledged. Advance the release marker, all example config versions and their release pins only during release preparation. Validate them before tagging, with regression tests for stale or missing versions and pins. Update contributor and upgrade documentation and example test helpers consistently. Assisted-by: Codex (GPT-6 Astra)
91a4650 to
a3f5238
Compare
|
Request changes: the PR doesn't close #282 for users who already bumped, and unreleased migrations now fail open. Must
Should
Nit
Tested on a3f5238: evaluated configs at Assisted-by: Claude Code (Claude Opus 5.5) |
Reject configVersion values newer than the latest finalized release and direct users back to that release. Update current-version fixtures and allow tests to override the release marker, keeping warnings, released errors, future-version rejection and the null opt-out covered after tagging. Keep unreleased migrations as nonblocking warnings and document that deployments can proceed without acknowledgement and warnings may repeat. Clarify the interval before example release pins can be fetched and remove the migration-policy subsection from the 0.2.0 migration instructions. Assisted-by: Codex (GPT-6 Astra)
|
Added commit e1ad6c3 addressing the review:
Both nits are addressed: Validation: |
seberm
left a comment
There was a problem hiding this comment.
LGTM
e1ad6c3 resolves both must items: future configVersion values are rejected, and the fail-open behaviour of unreleased notices is now stated in the PR and docs. Keeping them as warnings is acceptable: with future versions rejected, everyone on master stays at the released version and hits every notice as a blocking error at release, so the non-blocking window covers only pre-release deploys from master.
Nit
- The future-version message reads
Set nix-bitcoin.configVersion = "0.1.6"; until the release is finalized.The;mid-sentence is confusing; e.g.Set nix-bitcoin.configVersion = "0.1.6" until the release is finalized.
Tested: CI on e1ad6c3 (flake check incl. module-config, deployment examples, release tooling, shellcheck). VM tests not run.
Assisted-by: Claude Code (Claude Opus 5.5)
Remove the mid-sentence semicolon and check the complete guidance sentence. Assisted-by: Codex (GPT-6 Astra)
#268) Fixes #128. The btcpayserver user is in NBXplorer's group, because BTCPay Server reads NBXplorer's API cookie (`/var/lib/nbxplorer/<network>/.cookie`). But the secret `bitcoin-rpcpassword-btcpayserver`, NBXplorer's bitcoind RPC password, had the same group and the default mode `0440`. So BTCPay Server could read the password, although it never uses it. The secret now belongs to NBXplorer's user, with mode `0400`. Only NBXplorer reads it, in its `preStart`. bitcoind reads only `bitcoin-HMAC-btcpayserver`, which doesn't change. The group still gives BTCPay Server the cookie. `setup-secrets` and nixops apply the new owner and mode on the next deployment. A program that read the password through the group, or as the `bitcoin` user, now fails. So config version 0.2.0 gets a notice for configs with BTCPay Server, and `docs/upgrading.md` says what to do. It also says how to replace the password if BTCPay Server was compromised. Users who manage the secret files outside bitcoinix have to change this one by hand. The notice targets 0.2.0, the lowest open milestone. ## Testing The `btcpayserver` VM test now checks that the password file is `nbxplorer`-owned with mode `0400`, that the btcpayserver user can't read it, and that it can still read NBXplorer's cookie. Before this change, the first two checks fail. - `regtest`: passes. NBXplorer still connects to bitcoind, and BTCPay Server's `/api/v1/health` reports `synchronized`, so BTCPay Server still authenticates to NBXplorer with the cookie. - `default`: passes. - `ciTestInfo`, `checks.x86_64-linux.module-config` and `checks.x86_64-linux.test-runner`: pass. - Evaluation: a BTCPay Server config at config version 0.1.6 gets the notice, which names the configured NBXplorer user. On master it's a warning. A config without BTCPay Server gets no notice. - `mdbook build`: passes, and the release note links to the new upgrading section. ## Not in this PR - NBXplorer's RPC proxy (`POST /v1/cryptos/BTC/rpc`) still lets the cookie holder call the methods NBXplorer allows without `exposerpc`, for example `sendrawtransaction` and `gettxout`. This PR removes BTCPay Server's direct access to the rest of the whitelist and its copy of the credential. - NBXplorer's data dir is `0770 nbxplorer:nbxplorer`, so the btcpayserver user can write there. That could be its own issue. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows` and `regtest` pass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.
…ervice (#273) Fixes #132. The `secure-node.nix` preset always publishes sshd as an onion service, but nothing in `modules/` turned off SSH password login. Only the example configs did. NixOS allows passwords by default. So a config that imports the preset into an existing setup let anyone with the onion address try passwords over Tor. This includes the operator, who is in the groups that control funds (`bitcoin`, `clightning`, `lnd`). The preset now sets `services.openssh.settings.PasswordAuthentication` and `KbdInteractiveAuthentication` to `mkDefault false`. sshd then accepts only keys, over the onion service and over the node's IP address. A config that needs passwords can still set either option to `true`. This can lock out an account that logs in with a password, so it comes with a 0.2.0 notice. It fires for every config that uses the preset and enables sshd. A narrower condition would need to tell how the config defines the two options, and every way to do that missed some affected configs. A missed notice can lock the operator out of the node, and a needless one only costs a config version bump. The notice and the upgrade notes say that nothing changes for a config that already sets both options to `false`, like the flakes and Colmena examples. Keyboard-interactive login through PAM depends on the PAM module, because NixOS sets `security.pam.services.sshd.unixAuth` from `PasswordAuthentication`. I checked sshd's PAM stack in the pinned nixpkgs: - `googleAuthenticator`: without `unixAuth`, the stack is only `pam_deny`, so such setups need both options set back to `true`. With `services.homed.enable`, NixOS adds the rule without `unixAuth`. - `otpwAuth`: with `unixAuth`, a `sufficient pam_unix` rule comes before `pam_otpw`, so a plain password would skip the one-time password. Such setups need only `KbdInteractiveAuthentication = true`. The upgrade notes say this and tell users to test a new login before they close their session. A config that sets one of the options to `true` with `lib.mkDefault` fails evaluation with "conflicting definition values", because the preset uses the same priority. This happens at any config version, before the notice shows. The upgrade notes say to set the option without `lib.mkDefault`. Docs: - `docs/upgrading.md`: a 0.2.0 entry with the check, the PAM case, the conflict error and the way back. - `docs/release-notes.md`: a 0.2.0 entry. - `docs/introduction.md` and the SSH onion service section of `docs/services.md` now say that the preset turns off SSH password login. Nothing else in the repo uses SSH password login. The tests, the QEMU and krops deployment scripts and the deployment examples all log in with keys. The preset doesn't change `PermitRootLogin`, so root keeps the NixOS default `prohibit-password`. ## Testing - `nix build .#checks.x86_64-linux.module-config` passes. Two new tests: - `testSecureNodeSshKeysOnly`: the preset gives `false` for both options, an explicit `true` wins, and without the preset both stay `true`. It fails with the preset from master. - `testVersioningSecureNodeSshPasswords`: the notice fires with the preset and sshd, not with sshd disabled, not without the preset, and not for a 0.2.0 config once 0.2.0 is released. - `nix build .#checks.x86_64-linux.test-runner` passes. - `nix eval .#ciTestInfo` passes. - `./test/run-tests.sh -s secureNode` passes. - A config with the preset and `PasswordAuthentication = lib.mkDefault true` fails with "conflicting definition values" before and after 0.2.0 is released. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows` and `secureNode` pass on the KVM host. `acknowledged` replaces `current`, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed the second rebase.
Fixes #127. clightning added `getblockfrompeer` and mempool added `gettxoutsetinfo` to the whitelist of the shared `public` RPC user. `rpcwhitelist` is a list option, so the module system merged both into one list for `public`, and every service that connects as `public` got them. With mempool enabled, electrs, fulcrum and lnd could call `gettxoutsetinfo`, which walks the whole UTXO set and can keep bitcoind busy for minutes. BTCPay's user builds on the public list, so it got `gettxoutsetinfo` too. The comment in `bitcoind-rpc-public-whitelist.nix` said each module grants these methods to itself, which only btcpayserver did. This PR gives clightning and mempool their own RPC users, as btcpayserver has: - `clightning`: the public whitelist plus `getblockfrompeer` when bcli is the backend. With trustedcoin, it's the public whitelist alone. - `mempool`: the public whitelist plus `gettxoutsetinfo`. - An empty `rpcwhitelist` disables whitelisting for its user. So when the public whitelist is empty, both new whitelists stay empty too, and the services keep the unrestricted access they had through `public`. - Each user gets its own generated password and HMAC (`bitcoin-rpcpassword-<user>`, `bitcoin-HMAC-<user>`), owned like the btcpayserver ones. - clightning and mempool connect as their new users and leave the `bitcoinrpc-public` group, since they no longer read its password. - The `public` user keeps only the base whitelist. BTCPay's whitelist is now the base list plus `getblockfrompeer`, which is what nbxplorer probes for. It never needed `gettxoutsetinfo`. The pinned trustedcoin 0.8.7 reads `bitcoin-rpcuser` and `bitcoin-rpcpassword` from lightningd and calls `getblockchaininfo`, `getblockhash`, `getblock`, `getrawtransaction`, `estimatesmartfee` and `sendrawtransaction`. All of them are in the base list, so it keeps working with the `clightning` user. It still logs that password at startup (#191), but now it's the password of the clightning user, not the one that electrs, fulcrum and lnd share. The other clightning plugins don't talk to bitcoind. ## Migration A 0.2.0 notice fires for every config that enables clightning or mempool. No option marks a bitcoind on another node, since the `bitcoind-remote.nix` preset only changes the bitcoind unit. And configs that supply their own secrets have to act either way. So the text depends on the config instead. With `nix-bitcoin.generateSecrets`, it says there's nothing else to do when bitcoind runs on the node. Otherwise it says to create the new secrets first. For a bitcoind on another node, it lists the whitelists to set there. It also says to remove `getblockfrompeer` and `gettxoutsetinfo` from the remote public user if it has them, whatever the new config enables, since the old config may have added them. With BTCPay Server, it says to set the remote BTCPay user's whitelist again, since that list builds on the public one and had `gettxoutsetinfo` with mempool. The released 0.1.5 notice for mempool's RPC password told users to save the password to `bitcoin-rpcpassword-public`. Notices are evaluated against the current code, which reads `bitcoin-rpcpassword-mempool`, so it now names that file. So does the 0.1.5 section of `docs/upgrading.md`, which also says that releases before 0.2.0 read `bitcoin-rpcpassword-public`. `docs/upgrading.md` says what each setup has to do. The guide for a bitcoind on another node in `docs/configuration.md` now lists the new users, their whitelists, their password files, and the local HMAC files that setup checks. The migration tests for the currencyrate and rebalance plugins and for mempool's RPC password stay as master has them. Once 0.2.0 is released, later notices block every older config there, so a new test checks the 0.1.5 notices by their message. ## Testing - `test/configuration.nix`: new checks that `public` has neither method, `clightning` and `btcpayserver` have only `getblockfrompeer`, `mempool` has only `gettxoutsetinfo`, and `clightning` with trustedcoin has neither. With an empty public whitelist, both new whitelists are empty. Also that both services read their own password and aren't in `bitcoinrpc-public`, and what the notice says for which config, including the remote public and BTCPay whitelists. - `test/suite/security.py`, test `rpc-whitelist`: `public` can't call either method, and each service user can call only its own. Before this change, `public` could call `gettxoutsetinfo` in the `regtest` scenario. - `module-config` and `test-runner` checks pass, and the mdBook build succeeds. - `regtest` scenario passes. The bitcoind log shows `public` refused `gettxoutsetinfo` and `getblockfrompeer`, `mempool` refused `getblockfrompeer`, and `clightning` and `btcpayserver` refused `gettxoutsetinfo`. - `trustedcoin` scenario fails, as it does on master 772846d. trustedcoin logs `bitcoind RPC working` as user `clightning`, and `rpc-whitelist` passes: `clightning` is refused `getblockfrompeer` and `gettxoutsetinfo`. The failure is a startup race in trustedcoin, unrelated to this change. When clightning restarts right after bitcoind, lightningd asks for the chain tip before trustedcoin's `OnInit` has set up its bitcoind client. trustedcoin then falls back to block explorers, which the VM can't reach, returns `tip: 0`, and lightningd exits with `bitcoind has gone backwards`. The start then hangs in clightning's `postStart` until it times out. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows`, `regtest` and `trustedcoin` pass on the KVM host. `acknowledged` replaces `current`, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. Deleting a 0.1.5 notice fails `testMigrationNotices015` with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed both rebases.
Fixes #123. This is hardening of the data dir route. The RPC socket already lets every member of the clightning group run code as the clightning user, for example with `plugin start`. Taking BTCPay Server off the socket is #87. The bitcoind and lnd data dirs stay `0770`, because only the operator joins those groups. The Core Lightning data dir had mode `0770`, so every member of the clightning group could create, rename and delete entries in it. The group holds the operator user when `nix-bitcoin.operator.enable` is set, the btcpayserver user with `services.btcpayserver.lightningBackend = "clightning"`, and any user you add. A member could rename its own file over `config` after `preStart` wrote it and before lightningd read it, and make lightningd load a plugin as the clightning user. Or it could move the network dir aside and plant one with its own `hsm_secret`. Group members only need to pass through the data dir to reach the RPC socket and to read `config`, so the dir is now `0750`. The tmpfiles rule sets this mode on existing nodes at the next deployment. lightningd creates the network dir with mode `0700`, and `postStart` adds only `g+x`. So the RPC socket is the only entry under the data dir that the group can write. I checked each user of the group: BTCPay Server, `lightning-cli`, `lnconnect-clnrest`, nodeinfo, RTL's root scripts, the clnrest rune, the plugins and replication. None of them writes to the data dir as a group member. A script that writes to the data dir as a group member now fails. So config version 0.2.0 gets a notice for configs with clightning. `docs/upgrading.md` explains the change and how to list entries that a group member created. The release notes get a 0.2.0 entry. Tests: - The `clightning` test checks the data dir's owner, group and mode. It checks that the RPC socket is the only entry the group or others can write, and that every entry belongs to the clightning user. For each member of the clightning group, it checks that `lightning-cli getinfo` works and that creating a file in the data dir fails. - The new scenario `btcpayserverClightning` runs BTCPay Server on the clightning backend. It's in the CI matrix. The `btcpayserver` test checks lnd's macaroon only with the lnd backend. The Greenfield request in the `regtest` test reaches clightning through the socket. - `config-replace` plants its symlink as the clightning user, because the operator can't write the data dir anymore. - `module-config` checks which configs get the notice. ## Testing On an x86_64-linux KVM host: - `./test/run-tests.sh -s btcpayserverClightning`: pass on the final head - `./test/run-tests.sh -s regtest`, `-s default` and `-s lnconnectNoOperatorRole`: pass on the previous head. Since then only the test's quoting and member loop and the docs changed. - `nix eval .#ciTestInfo`: pass, and it lists `btcpayserverClightning` - `nix build .#checks.x86_64-linux.{module-config,test-runner,ci-workflows,lnd-macaroon-filters}`: pass - `./test/shellcheck.sh`: pass - `systemd-tmpfiles --create` with a `d <dir> 0750` rule changes an existing `0770` dir to `0750`, as on an upgraded node. I didn't run `netns` and `netnsRegtest`. CI runs them. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows`, `shellcheck` and `btcpayserverClightning` pass on the KVM host. This PR doesn't change master's plugin migration checks. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus a recheck), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.
…278) Fixes #131. BTCPay Server makes the first account that registers the server admin. That account can use the internal Lightning node and install plugins. bitcoinix started BTCPay with no admin, so until the operator registered, any local user, or a service that can reach the port, could register first and take it. The window also covers the onion service and any LAN or WireGuard address. BTCPay 2.4.7 has no setting that closes it: - There's no option, environment variable or CLI flag to create the first admin or to require a token or an invite for it. - `disable-registration` (default true) locks registration only once the first admin exists. - Turning `LockSubscription` on before that blocks the web form, but not `POST /api/v1/users`. While no admin exists, BTCPay treats an anonymous caller of the Greenfield API as an admin and lets it create one. The regtest test used exactly this request until now. At the network level, loopback can't tell local users apart. `IPAddressAllow` filters by address. netns-isolation lets every process in the host namespace reach the service namespaces through the bridge. A UID owner match in the firewall would need an allow list of every client (the operator's SSH tunnel, Tor, a reverse proxy) for both iptables and nftables. BTCPay binds only to an address and port, so a Unix socket would mean a new listener setup and would break the onion service and existing tunnels. So this PR creates the admin before BTCPay opens its port: - A new oneshot unit `btcpayserver-admin` runs before each start of `btcpayserver`. If the database has an admin, it exits. - Otherwise it starts BTCPay in a private network namespace (`PrivateNetwork`), bound to `127.0.0.1`, which no other process can reach. It creates `admin@localhost` through the Greenfield API with the password in the new secret `btcpayserver-admin-password`, then stops BTCPay. BTCPay then locks registration. - `btcpayserver` requires the unit, so it doesn't start when the admin can't be created. - The secret belongs to `services.btcpayserver.user` and `.group`, so a custom user or group works with `setup-secrets`. - The setup instance's API URL follows `services.btcpayserver.rootpath`, with `/` and a trailing `/` treated like BTCPay does. - The BTCPay config is now a function of the bind address, because BTCPay binds to every `bind` in its config file and on its command line. - Nodes that already have an admin keep it and don't run the setup instance. Nodes that ran without an admin before this change may already have an admin that isn't the operator's. The docs say how to check the admins in Server Settings > Users. An admin that isn't yours could have installed plugins that run as the `btcpayserver` user and use the Lightning node, so the docs say to treat the node as compromised: stop BTCPay Server, move the funds to a wallet this node doesn't control and set up the node again. They give no in-place recovery steps. Docs: a new "Connect to BTCPay Server" section with "Check the admin accounts" in `docs/services.md`, the 0.2.0 upgrade notes and release notes, the example config and the BTCPay recipe in `dev/dev-features.sh`. The old warning in `examples/configuration.nix` about creating the admin before enabling the onion service is gone, since the admin now exists first. The 0.2.0 notice is for every node with BTCPay. Nodes without an admin now sign in with the generated account instead of registering. Nodes with an admin should check that it's theirs. Setups that supply their own secrets must add the new one. ## Testing The `btcpayserver` VM test now checks that: - `btcpayserver-admin` runs with `PrivateNetwork`. - `admin@localhost` with the generated password is a `ServerAdmin`. - An anonymous `POST /api/v1/users` gets 401, with and without `isAdministrator`. - `/register` redirects. Before this change, the anonymous request created the first admin. The regtest test relied on it. That test now signs in as the generated admin for its Greenfield request. BTCPay accepts Basic auth only in an account's first five minutes, so a test helper resets the account's creation time before each request. New eval tests in `test/configuration.nix`: - With a custom user and group, the secret's owner is that user and group, and both exist. - The health URL of the setup instance for `rootpath` null, `/`, `btcpay`, `/btcpay` and `btcpay/`. Results: - `regtest` VM scenario: pass. - `netnsRegtest` VM scenario: pass on an earlier revision of this branch, without the last fixes. That run checked the `bind` handling in a service namespace: the config file's `bind` is the namespace address, so the setup instance gets its own config with `bind=127.0.0.1`. An earlier version passed `--bind=127.0.0.1` on the command line and failed in both scenarios. - The `shellcheck-services` build in the VM scenarios covers the new unit script. - `checks.x86_64-linux.module-config` and `checks.x86_64-linux.test-runner`: pass. Not tested: the mainnet scenarios, a running node with `rootpath`, and a rerun of `btcpayserver-admin` on a node that already has an admin. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows`, `shellcheck` and `regtest` pass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.
#267) Fixes #67. Without a host, `nix-bitcoin-wg-connect` ran `lndconnect` to find the node's external IP. `lndconnect` does this through `go-external-ip`, which queries third-party IP lookup services over clearnet. That revealed the node's public IP to them, also on a node that otherwise uses only Tor. #201 documented the lookup, but the command still did it. This makes the host required. Without it, the command prints a usage message and exits with status 1: ``` Usage: nix-bitcoin-wg-connect [--text] <host> <host> is the address where your WireGuard client reaches this node: its public IP or hostname, or its LAN IP for a client in your local network. 'ip address' lists the node's own addresses. Behind NAT, your router shows the public IP. ``` The rest of the command works as before. The preset no longer references the `lndconnect` package. A call that used to work now fails, so this adds a config version 0.2.0 notice for configs that import the preset (`modules/versioning/0.2.0/wireguard-connect-host.nix`). `docs/upgrading.md` and `docs/release-notes.md` get 0.2.0 entries. The note from #201 in `docs/services.md` now says that the address is required and how to find it. The dev topic `dev/topics/lndconnect-and-wireguard.sh` passes a host. ## Testing - `wireguard-lndconnect` passes. A new subtest runs the command without a host and checks that it fails with the usage message and prints no config. - `checks.x86_64-linux.module-config` passes. The new `testVersioningWireguardConnectHost` checks that the notice fires for an older config with the preset and not without the preset, and that a config at 0.2.0 doesn't get it once 0.2.0 is released. Without the notice file, it fails. - `checks.x86_64-linux.test-runner` and `nix eval .#ciTestInfo` pass. - `shellcheck` passes on `dev/topics/lndconnect-and-wireguard.sh`. - The CVE scan node (`test/ci/scan-node.nix`) got `lndconnect` through the preset before. It now enables `services.lnd.lndconnect.enable`, so the scan still covers `lndconnect`. It evaluates, with `lndconnect` in its closure. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows`, `shellcheck` and `wireguard-lndconnect` pass on the KVM host. `acknowledged` replaces `current`, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.
…ory (#275) Fixes #122. With `services.clightning.replication.local.directory`, nothing tied clightning to the disk or share that should hold the replica. Only the SSHFS setup had a dependency, through `bindsTo` on `clightning-replication-mounts`. When the mount for a local directory was missing, tmpfiles created the directory on the filesystem below the mount point, and clightning wrote the replica there, usually to the primary disk. With `encrypt`, the mounts service ran `mkdir -p` and `gocryptfs -init` there too. The node looked healthy, but a failure of the primary disk took both copies. `docs/services.md` said that clightning doesn't start while the target is unavailable, which held only for SSHFS. This PR adds `RequiresMountsFor` for `local.directory` to `clightning.service`, and to `clightning-replication-mounts.service` when `encrypt` is set. systemd then mounts the directory first and doesn't start these units while the mount fails. A directory on the root filesystem has no mount to wait for, so it starts as before. systemd splits `RequiresMountsFor` and `ReadWritePaths` at whitespace, unquotes each word and expands `%` specifiers. So the module now writes the directory as a quoted word, with `\` and `"` escaped and `%` doubled, in both settings. Before, a directory with a space became two paths, and clightning failed with `226/NAMESPACE`. systemd can only wait for the mounts it knows, like `fileSystems` entries, and it doesn't follow symlinks. The docs now say this, with a `fileSystems` example for an external disk. I didn't add an assertion or a warning for a `local.directory` outside a declared mount. A replica on the root filesystem or a ZFS dataset that ZFS mounts itself is valid, so a check would break or nag valid configs. clightning now stays down without the mount, so there's a 0.2.0 notice for local replication, with upgrade notes and a release note. The notice shows for every local replica directory, also on the root filesystem, where nothing changes. A condition that reads `fileSystems` would miss the mounts that systemd knows from elsewhere, like `systemd.mounts`. ## Testing - `test/configuration.nix`: - `testReplicationRequiresLocalMounts` checks `RequiresMountsFor` on both units for a local directory, with and without `encrypt`, and its absence with SSHFS. - `testReplicationQuotesLocalDirectory` checks the quoting of a path with a space, `"`, `\` and `%` in `RequiresMountsFor` and `ReadWritePaths`. - `testVersioningReplicationLocalMounts` checks the notice for local directories and its absence with SSHFS. - These tests fail without this change. `checks.module-config` (139 tests) and `checks.test-runner` pass. - `clightning-replication` VM scenario: passes. A new last subtest switches to a config that declares a `nofail` mount at `/mnt/replica disk` whose disk is missing. clightning's start fails with result `dependency`, no replica appears under the mount point, and `systemctl show` lists the path as one word in `RequiresMountsFor` and `ReadWritePaths`. Without the mount dependency (checked with `/mnt/replica`), the switch succeeds and clightning starts anyway. Without the quoting, systemd ignores `disk` as a relative path, and clightning fails with `226/NAMESPACE` instead of the dependency. The subtest fails in both cases. - `nix eval .#ciTestInfo`: passes. - The mdBook build passes. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows` and `clightning-replication` pass on the KVM host. `acknowledged` replaces `current`, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus a recheck), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed the first rebase.
…276) Fixes #66. Fixes #153. `services.hardware-wallets` gives Ledger and Trezor devices to group `hardware-wallets`. Two things bypassed that group: - Our Trezor rules added `TAG+="uaccess"`. - systemd's `70-uaccess.rules` adds the same tag to every device in its hardware wallet hwdb, which includes all Ledger and Trezor devices. In systemd 262, which master pins, that's `SUBSYSTEM=="usb", ENV{ID_HARDWARE_WALLET}=="1", TAG+="uaccess"` and the same rule for `hidraw`. With the tag, `73-seat-late.rules` has systemd-logind give the user of the active local session an ACL on the device, also when that user isn't in the group. The module also turned on the Trezor Bridge (`services.trezord.enable = true`). In the pinned nixpkgs, trezord runs as user `trezord`, which isn't in group `hardware-wallets`. The nixpkgs `51-trezor.rules` set `GROUP="trezord"`, but our rules come later and replace it. So the bridge couldn't open the device. Making it work lets every local user and service use the Trezor through the bridge's HTTP API on `127.0.0.1:21325`, which has no authentication. Nothing in bitcoinix uses the bridge. HWI and `trezorctl` open the device directly. This PR: - moves our rules to `71-hardware-wallets-ledger.rules` and `71-hardware-wallets-trezor.rules`, and each rule line now removes the tag with `TAG-="uaccess"`. udevd sorts the files of `/etc/udev/rules.d` and systemd's own rules dir together by name. So ours run after `51-trezor.rules` and `70-uaccess.rules`, and before `73-seat-late.rules`, which applies the tag. In systemd 260, `TAG-=` drops the tag from the device's current tags. `73-seat-late.rules` matches current tags, and logind checks the current tag again before it sets ACLs on a session switch. - removes the tag only on the devices our rules give to the group. systemd's hwdb also lists generic USB serial chips and other wallets, which no group would get otherwise. - makes the Ledger rules match every Ledger device in systemd's hwdb: all products of vendor `2c97`, and the HW.1 and early Nano IDs of vendor `2581`. They matched only `2c97:0001` before. Real Ledger devices show other product IDs, for example a Nano S as `2c97:1011`, so the group didn't get them and the session did. - adds `services.hardware-wallets.trezorBridge` (default `false`). It turns on trezord and sets `SupplementaryGroups` on its unit, so a switch restarts a running bridge with the group. The option description says what the bridge exposes. - warns when trezord runs with `trezor` but without the group, since it then can't open the device. That happens when `services.trezord.enable` is set directly. The warning stays off when trezord gets the group in another way: through `users.users.trezord`, `users.groups.<group>.members`, the unit's `Group` or `SupplementaryGroups`, or `services.hardware-wallets.group = "trezord"`. - adds two 0.2.0 notices, upgrade notes, release notes and a paragraph in the Trezor section of `docs/services.md`. One notice covers session access for Ledger and Trezor users. The other covers the bridge, for Trezor users who don't run trezord. A device that's plugged in while you deploy keeps the session user's ACL until you unplug it. The upgrade note says so. A config that turned the bridge off with `services.trezord.enable = lib.mkForce false` gets the bridge notice too, although nothing changes for it. Detecting that needs option priority introspection, so this config only has to bump `configVersion` once more. ## Testing - New tests in `test/configuration.nix`: - Every Ledger and Trezor rule line sets the group and removes the `uaccess` tag. The `2c97` rule matches every product, and the `2581` rule has the HW.1 IDs. - trezord is off by default and needs `trezor`. With the bridge on, its unit has the group. - The warning appears only when trezord runs with `trezor` but without the group. It doesn't appear with `trezorBridge`, `users.users.trezord.extraGroups`, `users.groups.hardware-wallets.members`, the unit's `Group` or `SupplementaryGroups` (also as a space-separated string), or `group = "trezord"`. - Each notice fires only for the configs it describes. - The check build lists the system's udev rules dir, which on NixOS also holds copies of systemd's rules. It checks that `51-trezor.rules`, `70-uaccess.rules`, our two files and `73-seat-late.rules` sort in that order, and that systemd still tags hardware wallets in `70-uaccess.rules`. It also runs `udevadm verify` on our files. - These tests fail with our files at `52-`, and with `TAG-="uaccess"` removed. - `nix build .#checks.x86_64-linux.module-config` (139 tests) and `.#checks.x86_64-linux.test-runner` pass. - `nix eval .#ciTestInfo` passes. - VM scenario `netns` passes on the final head. It enables `services.hardware-wallets.trezor` and `ledger` through `full`. Not tested on a device. I didn't run `udevadm test` against a fake device in a VM. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows` and `netns` pass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed the first rebase.
…279) Fixes #95. The backups service copied the whole lnd and Core Lightning data dirs while the daemons ran. So the backup had lnd's `channel.db` and Core Lightning's `lightningd.sqlite3`, copied while the daemons wrote them. A copy made during a write can be torn. And a node that runs from an outdated copy can broadcast a revoked channel state. The peer can then take all funds in that channel. The docs didn't warn against restoring these files. The bitcoind wallet files were copied live too. This PR changes three things: - The filelist leaves out the Lightning channel databases: - lnd's `graph` dir. In lnd 0.21 it holds `channel.db`, `sphinxreplay.db` and `wtclient.db`, or `channel.sqlite` and `lnd.sqlite` with the SQLite backend. - Core Lightning's `lightningd.sqlite3` and the SQLite files that `services.clightning.wallet` sets, such as a replica. Each database also gets a `<file>-*` line for its journal files. Like Core Lightning, the DSN is split at the first `:` only. A relative path in it starts in the network dir, and an empty one names no file. - The gocryptfs dir of an encrypted replica in `local.directory`, which holds the encrypted database. With SSHFS or encrypted replication, also the mounts dir `/var/cache/clightning-replication`, which holds the SSHFS cipher dir and the plaintext mount. The paths are normalised, because duplicity matches them as strings, so `./` or `../` would slip through. duplicity also reads each line as a glob, so `[`, `*` and `?` in a path are escaped as one-char classes. Only paths under `services.duplicity.root`, normalised too, are listed, because duplicity aborts the whole backup on a selection outside its root. These entries come first in the filelist, so `extraFiles` can't include them. The backup keeps the files for recovery: `lnd-seed-mnemonic` and `channel.backup` for lnd, and `hsm_secret` and `emergency.recover` for Core Lightning. lnd and Core Lightning replace both files atomically, so a live copy of them is safe. - A new `bitcoind-wallet-backup` unit runs before each backup, like the PostgreSQL dumps. It runs as the bitcoind user with the usual hardening, write access only to `/var/lib/bitcoind/wallet-backups`, and network access only to `localhost` and bitcoind's RPC address. Here's what it does: - It removes the files of the last backup. It deletes only the files it writes, because the dir can also hold other files, like a wallet named `wallet-backups`. - If bitcoind runs, it asks it for a consistent copy of each loaded wallet with `backupwallet`. Each copy goes to `wallet-<sha256 of the wallet name>.dat.tmp` and is renamed to `wallet-<sha256>.dat` only when it's complete. The hash keeps the file name short for any wallet name. `wallet-names.json` maps each copy to its wallet name, so a restore can find the right file. - If bitcoind is stopped, it makes no copies, because the wallet files are consistent then. - If bitcoind is starting or stopping, or a copy fails, the unit fails, and so does the `duplicity` unit after the backup. `bitcoin-cli` runs with `-noconf` and explicit RPC options. The operator can replace `bitcoin.conf` in the data dir, and a planted config could make `bitcoin-cli` send the first line of a file it can read to any address. With the `bitcoind-remote.nix` preset, the wallets are on the other node, so the unit is masked and the backup doesn't start it. The live wallet files stay in the backup, because they're the only copy of wallets that bitcoind doesn't load. - `docs/services.md` gets a Backups section. It says what the backup holds and what it leaves out and why. It and the `postgresqlDatabases` option say not to list Core Lightning's PostgreSQL database, because its dump is an outdated copy of the channel state. It also says how to recover Lightning funds: the seed and `channel.backup` for lnd, `hsm_secret` and `emergency.recover` for Core Lightning, and database replication for a Core Lightning database that's always current. The backup no longer covers data it covered before, and the `duplicity` unit can now fail in new cases. So a 0.2.0 notice tells every config with backups about both changes. Backups made before this change still contain the channel databases. The notice and the upgrade notes say to never restore them. ## Testing - `test/suite/backups.py` runs two backups while bitcoind and the Lightning daemons run. Both must have the copy of the loaded test wallet and no channel database. The test checks that `wallet-names.json` maps the copy to the wallet. Before the second backup, the test adds a stale copy, a `wallet.dat` and another file. The second backup must leave out the stale copy and any `.tmp` file, and the other two files must still exist. After the backup with bitcoind stopped, the test checks these things: - The backup has no wallet copy. - It has lnd's `channel.backup` and Core Lightning's `emergency.recover`, next to the seed and `hsm_secret`. - `graph/mainnet/channel.db` and `lightningd.sqlite3` exist on disk but aren't in the backup. lnd writes `channel.backup` only once it's synced to the chain, which the test node never is, so the test adds a stand-in file for that check. - `test/configuration.nix` checks these things: - The exclusions come first in the filelist: for the default config, a DSN with `./`, `../`, `//` and a replica name that ends with `:`, a DSN with an empty replica, an empty `sqlite3://` DSN, a database named `channel[1].sqlite3`, an encrypted local replica, an encrypted SSHFS replica, a duplicity root of `/var/lib` with a replica outside it, and a root of `/var/lib/.`. - The wallet unit is defined and started for a local bitcoind, and not for the `bitcoind-remote.nix` preset or `disablewallet`. - The 0.2.0 notice shows for any config with backups. - `nix eval .#ciTestInfo`, `.#checks.x86_64-linux.module-config` and `.#checks.x86_64-linux.test-runner` pass. - VM scenario `default` (the secure node scenario with backups, lnd, Core Lightning and BTCPay Server) passes. - VM scenario `netns` with the backups test turned on passes. It checks that the wallet unit reaches bitcoind across the namespace with its IP allow list. - I ran duplicity 3.0.7 on its own with a filelist like the new one. It leaves out the databases, their `-journal`, `-wal` and super-journal files, a database named `h`, and `channel[1].sqlite3` with its journal. It keeps `channel1.sqlite3`, `channel.backup`, `hsm_secret` and `emergency.recover`. - After the rebase onto master c3d955c (#283), `module-config`, `test-runner`, `ci-workflows` and `default` pass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass with `version.nix` at 0.1.6 and at 0.2.0. ## Models Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.
Users following master could acknowledge an upcoming release and miss migrations added later for that release.
configVersionvalues newer than the latest finalized release are now rejected, with instructions to use the released version. Applicable unreleased migrations warn on evaluation; released migrations block until acknowledged.Unreleased notices intentionally remain nonblocking: deployment can proceed without completing or acknowledging those migrations. Users following master must review the warnings before deploying. There is no per-notice acknowledgement, so applicable warnings can repeat after migration. Finalizing the release makes its notices blocking errors until acknowledged.
Root
version.nixrecords the latest finalized release (0.1.6). It changes only in the release-preparation commit immediately before tagging, never during development or when adding migration notices. That commit also updates the explicitconfigVersionin the main configuration, Flakes, Colmena, and persistent-container examples, together with the three flake release pins. The tag helper refuses to create a release unless all these versions match. Documentation explains the interval when the preparation commit is on master but the example pins cannot yet be fetched; example tests override the pins with the checkout.Validation:
nix flake check --all-systems, including module tests that simulate both release states independently ofversion.nix, check future-version rejection, and retain the null opt-outsystem.build.toplevelevaluation: unreleased warnings permit deployment; future config versions and unacknowledged released migrations reject it; acknowledged releases and the null opt-out pass./test/shellcheck.shVM integration tests were not run.
Fixes #282.