Repository navigation
Conversation
Every secret that the config holds inline can now be read from a separate file: admin.password_hash, admin.session_secret, admin.protocol_login_pin_hash, turn.password, network.localkey and network.mqtt_password. This keeps secrets out of config files that are generated by tools or stored in world-readable places, and works with Docker secrets, systemd credentials and similar mechanisms. Inline values keep working unchanged.
The MITM launcher reads admin.session_secret to enable protocol session sync. It now also reads admin.session_secret_file and reports a file that cannot be read. Inline secrets that are not strings, such as a numeric MQTT password, keep their previous value.
The admin dashboard used to rewrite config.toml in place when an admin turned protocol auth or new connections on or off. That write was not atomic, failed for read-only config files, and was undone on every restart of the Home Assistant add-on, which regenerates config.toml from its options. Dashboard changes are now stored atomically in state/admin_settings.json. The config file provides the default, and a stored value is discarded once the config value it overrode changes, so the most recent change wins. An invalid settings file stops the server with a clear error instead of silently reopening access.
Also describe the precedence rule of stored dashboard settings precisely.
Without syncing the directory, a power failure right after a change could bring back the previous file and silently undo a restriction.
The shipped compose.yaml mounts config.toml read-only, which made the toggles fail with HTTP 500 before the settings moved to the state directory.
The package is built with uv2nix from uv.lock, so it uses exactly the locked Python dependencies. It is wrapped with Mosquitto, coturn, OpenSSL and curl, and the fixed acme.sh path of the container image is replaced with acme.sh from Nix. Its install check finds acme.sh and loads every native extension. The module runs the server as a hardened systemd service with a dynamic user. Non-secret settings go to config.toml in the Nix store, secrets are passed as systemd credentials through the new _file options, and certificates come from files or from security.acme. The firewall options keep plain listeners closed behind a reverse proxy. The VM test covers TLS and reverse proxy setups, the firewall, TURN allocation from a second machine, persistence of dashboard toggles across restarts and the absence of secrets in the generated config.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a Nix flake so the server can be installed on NixOS as a native systemd service, as a third installation method next to Docker Compose and the Home Assistant add-on.
Depends on #309 (secrets from
_filekeys) and #310 (dashboard toggles in the state directory). This branch contains both. Only the last two commits are new here.nix/package.nix):uv.lock, so it uses exactly the locked dependencies. The pinned versions of python-roborock, cryptography and gmpy2 differ from what nixpkgs ships.services.roborock-local-server, innix/module.nix):config.tomlin the Nix store. The settings the module relies on, such as ports, listener mode, broker mode and TURN mode, are typed options. Everything else is passed through to the server as is. The module refuses to build if a secret is put in the settings._filekeys from feat(config): read secrets from files with a _file suffix #309.security.acmethroughuseACMEHost. Credentials are copies taken when the service starts, so the certificate watcher from feat(tls): reload listeners when provided cert/key files change #250 does not see a renewal. The service is restarted instead whensecurity.acmerenews the certificate.openFirewallopens the HTTPS and MQTT TLS ports, plus the TURN ports when the relay runs. Behind a reverse proxy (external_tls), the plain HTTP and MQTT ports stay closed.nix/test.nix, run withnix flake check), three machines:docs/nixos.md, linked from the installation guide and the navigation.The server's own Cloudflare certificate mode is not offered by the module. The docs show the same Cloudflare DNS-01 setup through
security.acme, including the External Account Binding credentials that ZeroSSL and Actalis need. The package itself still supports that mode.Nothing changes for Docker or Home Assistant add-on users.
Before you open this PR (optional, but very helpful)
PRs I reviewed:
Proof that it works
Tested on:
What I did and what happened:
nix build .#checks.x86_64-linux.nixospasses, with all subtests:CAP_NET_BIND_SERVICEin its bounding setnix build .#checks.x86_64-linux.packagepasses, including the install check.nix flake check --no-build --all-systemspasses. aarch64-linux is evaluated only, not built.uv run pytest -qpasses in full.uv run mkdocs build --strictpasses.Not covered by the VM test: issuing and renewing a certificate through
security.acme, which needs an ACME server.Screenshots (required for any UI change)
No UI changes.