WS-H: NixOS module, VM test, README section
Module: Origin/Host allowlists from allowedHosts and the FQDN, credentials refreshed on reload so SIGHUP rotates the TLS cert, string cert/key paths kept out of the store, docker.enable asserts virtualisation.docker. VM test covers healthz, 401, token mint/revoke via sudo -u, /mcp, Origin 403, root refusal and a TLS node. Package skips two unit tests that need host state the sandbox lacks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017WMgwyHQQU9cB4ruRDrKow
This commit is contained in:
1 parent
46b4f5ac0b
commit
34da657fdf
6 files changed
+193
-16
No files matched your search
@@ -160,6 +160,43 @@ curl --cacert cert.pem -H "Authorization: Bearer $TOKEN" https://localhost:1984/
|
||||
|
||||
Rotation: replace the files and send `SIGHUP` (`kill -HUP $(pidof slinuxm)`, or `systemctl kill -s HUP <unit>`). New connections get the new certificate; established ones are not dropped. The certificate and key are read as two separate files, so rotation tooling must send SIGHUP only after BOTH are in place; if the pair is unreadable or mismatched (for example the cert was replaced but the key not yet), the old certificate stays, an error is logged, and you send SIGHUP again once the files are consistent. Any intermediate certificates must be in the `cert_file` chain. Both the TLS and the plain listener are HTTP/1.1 only, share one accept loop, cap concurrent connections at 1024 and close connections that send no request header within 30 seconds. SIGHUP is harmless when TLS is disabled (it is logged and ignored). For ACME, point `cert_file` and `key_file` at the client's output (for example certbot's `live/<name>/fullchain.pem` and `privkey.pem`, or the NixOS `security.acme` directory) and send SIGHUP from the renewal hook. For sops-nix or systemd `LoadCredential`, point at the decrypted or credential path (`/run/credentials/<unit>/...`) so the service user needs no access to the original key file.
|
||||
|
||||
## NixOS
|
||||
|
||||
The flake exports `packages.<system>.default` and `nixosModules.default`.
|
||||
|
||||
```nix
|
||||
# flake.nix
|
||||
inputs.skyg-linux-tracker.url = "github:<owner>/linux-system-monitor";
|
||||
|
||||
# in your nixosSystem modules
|
||||
modules = [
|
||||
skyg-linux-tracker.nixosModules.default
|
||||
{ services.skyg-linux-tracker.enable = true; }
|
||||
];
|
||||
```
|
||||
|
||||
That runs the service as the `skyg-linux-tracker` user on `127.0.0.1:1984` with the same sandbox as `systemd/skyg-linux-tracker.service`, writes `/etc/skyg-linux-tracker.toml` (the path the CLI reads by default) and installs `slinuxm` system-wide. Mint the first token as the service user:
|
||||
|
||||
```sh
|
||||
sudo -u skyg-linux-tracker slinuxm token create my-laptop
|
||||
```
|
||||
|
||||
Options (under `services.skyg-linux-tracker`): `port` (1984), `bind` (`"127.0.0.1"`), `tls.{enable,certFile,keyFile}` (passed through `LoadCredential`, so the service user never reads the original key; `systemctl reload skyg-linux-tracker` re-reads them; for ACME add `security.acme.certs.<name>.reloadServices = [ "skyg-linux-tracker" ]`), `openFirewall` (all interfaces), `firewallInterfaces` (recommended for a LAN), `allowedHosts`, `docker.enable` (adds the root-equivalent `docker` group), `settings` (freeform TOML merged over the module defaults) and `environmentFile` (secrets such as `SKYG_OTEL__HEADERS__AUTHORIZATION`, kept out of the store and out of the generated TOML).
|
||||
|
||||
Exposure: keep the default loopback bind and reach it over Tailscale or a TLS reverse proxy. Bearer tokens over plain HTTP are readable on a LAN. A non-loopback `bind` with `auth.enabled = false` fails at evaluation time. For `bind = "0.0.0.0"` add the names clients use to `allowedHosts` (`networking.hostName` is added for you), and prefer `firewallInterfaces = [ "enp3s0" ]` over `openFirewall`.
|
||||
|
||||
```nix
|
||||
services.skyg-linux-tracker = {
|
||||
enable = true;
|
||||
bind = "0.0.0.0";
|
||||
firewallInterfaces = [ "enp3s0" ];
|
||||
allowedHosts = [ "monitor.lan:1984" ];
|
||||
tls = { enable = true; certFile = "/var/lib/acme/monitor.lan/fullchain.pem"; keyFile = "/var/lib/acme/monitor.lan/key.pem"; };
|
||||
};
|
||||
```
|
||||
|
||||
`nix flake check` runs a two-machine VM test (plain and TLS) covering healthz, 401, token mint and revoke through the CLI, `/mcp` and the Origin check.
|
||||
|
||||
## Docker access
|
||||
|
||||
Reading the Docker socket directly requires group `docker`, which is root-equivalent. The unit file has this commented out. Prefer a read-only socket proxy that allows only `GET /containers/*`, `/events` and `/version`, for example [tecnativa/docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) with `CONTAINERS=1 EVENTS=1 POST=0`, exposed as a unix socket (or loopback TCP through a socat bridge), then:
|
||||
|
||||
Reference in new issue
Block a user