feat(nix): add NixOS flake for production deployment (#50)
* docs: add NixOS flake design for atBB deployment
NixOS module with systemd services for appview + web, nginx
virtualHost integration, and optional PostgreSQL provisioning.
* docs: add NixOS flake implementation plan
Six-task plan: flake skeleton, package derivation with pnpm.fetchDeps,
NixOS module options, systemd services, nginx virtualHost, final verify.
* chore: scaffold Nix flake with placeholder package and module
* feat(nix): implement package derivation with pnpm workspace build
* feat(nix): add NixOS module option declarations for services.atbb
* feat(nix): add systemd services and PostgreSQL to NixOS module
* feat(nix): add nginx virtualHost with ACME to NixOS module
* fix(nix): address code review findings in NixOS module
- Use drizzle-kit/bin.cjs directly instead of .bin shim
- Add network.target to atbb-web service ordering
- Equalize hardening directives across all services
- Add assertion for ensureDBOwnership name constraint
* chore: add Nix result symlink to .gitignore
* fix(nix): address PR review feedback
- Include packages/db/src/ in package output for drizzle.config.ts
schema path resolution (../../packages/db/src/schema.ts)
- Use .bin/drizzle-kit shim directly instead of node + bin.cjs
(patchShebangs rewrites the shebang, making it self-contained)
- Add requires = [ "atbb-appview.service" ] to atbb-web so it
stops if appview goes down (after alone only orders startup)
- Add ACME prerequisites assertion (acceptTerms + email)
* feat(nix): expose atbb CLI as a bin wrapper
makeWrapper creates $out/bin/atbb pointing at the CLI's dist/index.js
with the Nix store Node binary. This puts `atbb init`, `atbb category`,
and `atbb board` on PATH for the deployed system.
* fix(nix): add fetcherVersion and real pnpmDeps hash
- Add fetcherVersion = 1 (required by updated nixpkgs fetchPnpmDeps API)
- Set real pnpmDeps hash obtained from Linux build via Docker
- Keep pnpm_9.fetchDeps/configHook for consistency; mixing with the
top-level pnpmConfigHook (pnpm 10) caused lefthook to be missing
from the offline store during pnpm install
* fix(nix): use x86_64-linux pnpm deps hash
The previous hash was computed on aarch64-linux (Apple Silicon Docker).
pnpm_9.fetchDeps fetches platform-specific optional packages (e.g.
lefthook-linux-arm64 vs lefthook-linux-x64), so the store content
differs per architecture.
Hash corrected to the x86_64-linux value reported by the Colmena build.
* docs(nix): add example Caddyfile for Caddy users
Provides an alternative to the built-in nginx reverse proxy for operators
who prefer Caddy. Includes:
- Correct routing for /.well-known/* (must reach appview for AT Proto OAuth)
- /api/* → appview, /* → web UI
- NixOS integration snippet using services.caddy.virtualHosts with
references to services.atbb port options
* docs: add NixOS deployment section to deployment guide
Covers the full NixOS deployment path as an alternative to Docker:
- Adding the atBB flake as a nixosModules.default input
- Creating the environment file with Unix socket DATABASE_URL
- Module configuration with key options reference table
- Running atbb-migrate one-shot service
- Caddy alternative to built-in nginx (referencing Caddyfile.example)
- Upgrade procedure via nix flake update
* feat(nix): add atbb CLI to environment.systemPackages
The atbb binary was built into the package but not put on PATH.
Adding cfg.package to systemPackages makes `atbb init`, `atbb category`,
and `atbb board` available to all users after nixos-rebuild switch.
* fix(nix): set PGHOST explicitly for Unix socket connections
postgres.js does not reliably honour ?host= as a query parameter in
connection string URLs, causing it to fall back to TCP (127.0.0.1:5432)
and triggering md5 password auth instead of peer auth.
Setting PGHOST=/run/postgresql in all systemd service environments and
in the env file template ensures postgres.js uses the Unix socket
directory directly, regardless of URL parsing behaviour.
* fix(nix): add nodejs to PATH for atbb-migrate service
pnpm .bin/ shims are shell scripts that invoke `node` by name in their
body. patchShebangs only patches the shebang line, leaving the body's
`node` call as a PATH lookup. Systemd's default PATH excludes the Nix
store, so drizzle-kit fails with "node not found".
Setting PATH=${nodejs}/bin in the service environment resolves this.
* fix(nix): use path option instead of environment.PATH for nodejs
Setting environment.PATH conflicts with NixOS's default systemd PATH
definition. The `path` option is the NixOS-idiomatic way to add
packages to a service's PATH — it prepends package bin dirs without
replacing the system defaults.