Multi-location deployment: extract per-machine config to runtime site files #41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Each ATM hardware model (
douro,batm3, etc.) currently has a single flake target likedouro-installedorbatm3-installed. Per-machine values are baked into the system derivation at build time, which means:This is fine for the current scale (1 BATM3, 1 douro) but becomes a major friction point as the fleet grows.
What's currently location-specific (baked into the flake)
deploy/nixos/hardware/batm3.nix:141(10.0.0.5/24)flake.nix:60(always USD for batm3)batm3.nix:117-119batm3.nix:136deploy/nixos/configuration.nixlamassu-atmWhat's already location-aware (good)
These already live outside the flake on each machine (in
/var/lib/lamassu-atm/.envor DB):wifi.conf)VITE_CASH_IN_FEE,VITE_CASH_OUT_FEE)Proposed solution: runtime site config
Make the system derivation identical for all machines of the same hardware model. Per-machine values come from a small site file (e.g.,
/var/lib/lamassu-atm/site.json) that lives outside the repo and is provisioned per machine.Example layout
How it gets applied
NixOS activation script reads
site.jsonand:hostnamecommand/etc/udev/rules.d/(writable)xinput set-propwith the matrix on graphical-session startVITE_LAMASSU_FIAT_CODEin/var/lib/lamassu-atm/.envif not already setThe flake-level config becomes:
douro-installedand onebatm3-installedtarget — shared by all locationsbatm3.nix,douro.nix) only contain things that truly differ by hardware: kernel modules, firmware, drivers, partition layout, etc.Cachix impact
Provisioning flow (after refactor)
For a new deployment:
No flake change. No rebuild. No cachix push.
Migration tasks
site.jsonschema and document it (docs/site-config.md)site.jsonand applies values/etc/udev/rules.d/generated at activationnetworking.hostName)mkAtmApp { fiatCode = "USD" }to runtime.env(already partially supported)provision-atm.shto writesite.jsoninteractivelyOpen questions
/var/lib/lamassu-atm/wg-private.key(file) or live insidesite.json? File is safer (can bechmod 600), butsite.jsonis one less thing to provision.deploy/push-all.shthat builds all current model closures and pushes them. Should this run in CI on everymainpush?site.jsonschema at activation time and fail early with a clear error if malformed? (Yes, probably with a small Nix-eval-time check or a JSON schema validator.)site.jsonis missing — should activation fail (forces operator to provision it) or fall back to safe defaults (hostname =lamassu-atm, no WG)? Failing loud is probably safer to prevent silent misconfiguration.Priority
Medium. Not blocking current operations, but worth tackling before deploying the 3rd machine of any model — at that point the per-target approach starts feeling painful, and refactoring becomes harder once 20 machines are already in production with location-specific flake targets.
Related