Skip to content

odoo: 0..n local instances with odoo-reset and odoo-purge - #38

Merged
andrewthomaslee merged 1 commit into
mainfrom
odoo-instances
Nov 12, 2026
Merged

andrewthomaslee merged 1 commit into
mainfrom
odoo-instances

Conversation

@andrewthomaslee

Copy link
Copy Markdown
Member

Summary

hostSpec.services.odoo goes from one fixed instance (nixpkgs services.odoo) to 0..n local test instances, each resettable to a fresh database.

 hostSpec.services.odoo = {
   enable = true;
-  domain = "odoo.localhost";   # one instance: odoo.service, db odoo
-  demoData = true; workers = 2; addons = [];
+  baseDomain = "odoo.localhost";  # https://odoo.localhost = index page
+  instances = {
+    demo = {};                  # https://demo.odoo.localhost, demo data
+    blank.demoData = false;     # https://blank.odoo.localhost, empty
+  };
 };

Per instance <name>, everything is odoo-<name>: unit, system user, PostgreSQL role and database (peer auth), state /var/lib/private/odoo-<name>, config /run/odoo-<name>/odoo.cfg. Ports are automatic from basePort 18069 (or port), loopback only.

odoo-reset NAME... | --all [--yes]   stop, DROP/CREATE database, empty state, start
                                     -> first-start init again (demo data per instance),
                                        provisioned admin password
odoo-reset --list
odoo-purge [NAME...] [--yes]         list / delete database, role, state of removed instances

Files:

  • flake-parts/nixosModules/odoo.nix: own units instead of nixpkgs services.odoo (single-instance); one cert for odoo.localhost + *.odoo.localhost (CA name constraint unchanged); shared passwords; index page; odoo-reset, odoo-purge. PostgreSQL stays on while enabled, even with no instances, so odoo-purge always works.
  • vm-tests/odoo.nix (rewritten), vm-tests/odoo-reset.nix, vm-tests/odoo-firefox.nix (new), _odoo-common.nix (fake secrets, helpers), _odoo-probe.py (per-instance probe).
  • tests/fixtures/nixos.nix: two instances under eval-all-enabled.
  • documentation/docs/odoo.md (new, in nav): usage, reset, purge, one-time cleanup of the old single instance. README/index link to it.

Evidence

  • Before: one instance; the only reset was manual dropdb, which left the .odoo.initialized marker and an Odoo pointed at an empty database. Firefox trust was only asserted as "policies.json exists".
    After: all on euc-hel-0, sandboxed builds, exit 0:
vm-test odoo --remote          exit 0   14 subtests: 2 instances up, names on loopback, trusted HTTPS,
                                        index, logins, demo vs blank, isolation (odoo-demo cannot read
                                        odoo-blank), websocket 101, master password not in store,
                                        db manager off, loopback only (outsider refused), UI password
                                        survives restart, reboot does not re-init, 0 instances = only PostgreSQL
vm-test odoo-reset --remote    exit 0   seed records/attachment/UI password -> refusals change nothing
                                        -> odoo-reset demo: all gone, demo data back, blank untouched
                                        -> --all: each as configured -> odoo-purge lists/deletes leftovers
vm-test odoo-firefox --remote  exit 0   home-manager Firefox (homeModules.default) headless: request reaches
                                        nginx for demo.odoo.localhost; untrusted control aborts in TLS;
                                        CA present in the fresh profile
fmt; check                     exit 0

Merge Danger

Door: two-way

Breaking option change (no shim, per org practice): domain, demoData, workers, addons move under instances.<name>. The old instance's data (odoo database/role, /var/lib/private/odoo) is left in place, not migrated; deleting it is a manual step in the docs.

Blast Radius: beelink

Only beelink enables Odoo. Merge order: this PR, then the home PR bumps modules and gives beelink demo + blank. On deploy: clan vars generate beelink regenerates odoo-tls (wildcard SAN); the CA stays, so Firefox keeps trusting it. URL change: https://odoo.localhost becomes the index; instances move to https://demo.odoo.localhost / https://blank.odoo.localhost.

🤖 Generated with Claude Code

hostSpec.services.odoo ran one instance through nixpkgs services.odoo,
whose unit, database and ports are fixed, and its demo data could only
be reset by hand (dropping the database without the init marker broke
it). Local testing needs several instances, demo and blank, and a
one-command way back to a fresh database.

Breaking: the single instance (odoo.service, database odoo,
https://odoo.localhost) becomes hostSpec.services.odoo.instances.<name>,
each odoo-<name> (unit, user, role, database, state) at
https://<name>.odoo.localhost; odoo.localhost is an index. One
certificate covers *.odoo.localhost (odoo-tls regenerates once; the CA
is unchanged), passwords are shared. odoo-reset recreates an instance's
database with or without demo data; odoo-purge removes what removed
instances leave. VM tests: odoo, odoo-reset, odoo-firefox (a
home-manager Firefox trusts the CA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant