Smoking habit tracker
README.md

smoker #

Nuxt 3 cigarette tracker — full-stack TypeScript, SQLite, TailwindCSS.

One repo, one flake, two CI systems (Tangled + Hydra).

Dev shell #

No global installs needed — enter the Nix-provided shell:

nix develop

Provides:

  • node (v22 LTS), bun, sqlite3, git
  • Language servers: Volar (vue-language-server), typescript-language-server, tailwindcss-language-server, vscode-langservers-extracted (html/css/json/eslint), yaml-language-server, nixd (Nix LSP)
  • Formatter: nixpkgs-fmt

Dev SQLite lives at ./data/smoker.db (gitignored).

Verify the shell #

nix flake check                      # eval + devShellTools + lint + typecheck + unit (audit runs in Spindle CI)
nix develop -c bun run test          # 97 unit tests (vitest)
nix develop -c bun run test:integration # 129 integration tests (better-sqlite3)

Tests #

TypeScript vitest suites under tests/ — 97 unit + 129 integration = 226 total:

nix develop -c bun test             # unit only (excludes tests/integration/**)
nix develop -c bun run test:integration # integration (requires bun in devShell for native .node)
npx vitest run --config vitest.integration.config.ts # fallback without nix
nix build .#checks.x86_64-linux.unit  # Nix unit check (pure logic only)

Integration tests need better-sqlite3 / @node-rs/argon2 native builds, so they run via bun in the devShell — the Nix FOD (bun install --frozen-lockfile --ignore-scripts) skips native builds and excludes them from the unit check by design (vitest.config.ts excludes tests/integration/**).

Flake outputs #

Output Purpose nix build / nix eval
devShells.x86_64-linux.default Development shell with Node 22, bun, language servers nix develop
packages.x86_64-linux.default Built Nuxt app (store path contains .output/server/index.mjs) nix build .#default
packages.x86_64-linux.dockerImage Nix‑built OCI image for kackhost nix build .#dockerImage
checks.x86_64-linux.* devShellTools · lint · typecheck · unit (npm audit runs in Spindle CI — needs registry network, unavailable to sandboxed Nix builds) nix build .#checks.x86_64-linux.lint etc.
hydraJobs.x86_64-linux.* Stable aliases for Hydra jobset nix build .#hydraJobs.x86_64-linux.app

CI & deployment #

One repo, one flake, three Spindle workflows. All checks and artifacts are defined in flake.nix (INFRA-03/04/05/06):

  • .tangled/workflows/ci.yml — per-push/PR fast feedback on the microvm/NixOS engine: lint, typecheck, unit tests, integration tests (native modules built via bun install), npm audit, production build. node_modules is cached on bun.lock.
  • .tangled/workflows/e2e.yml — per-push/PR Playwright + Chromium (nixpkgs chromium via PLAYWRIGHT_CHROMIUM_PATH in playwright.config.ts) against a scratch SQLite DB.
  • .tangled/workflows/release.yml — on v* tags: full integration suite + all flake gate checks, then builds packages.default + packages.dockerImage from the flake and pushes the OCI image to the registry (secrets: REGISTRY_USER / REGISTRY_TOKEN; adjust IMAGE_BASE).
  • Hydra (main only): artifact factory — builds packages.dockerImage and publishes to the binary cache; hydraJobs mirrors checks + packages for stable jobset references.

There is no separate docs/infra-*.md yet — flake.nix comments, the workflow files, and this README are the current source of truth for cache wiring and deployment. Runtime config is DATABASE_PATH / JWT_SECRET / PORT (see nuxt.config.ts runtimeConfig and server/utils/config.ts).

Secrets #

  • Runtime injection only — in production JWT_SECRET (and any other secret) is injected via environment or vault; never hardcode or commit secrets.

  • Never commit .env — .env and .env.* (except .env.example) are gitignored. Copy .env.example locally and fill values out of band.

  • Rotate any exposed dev secret — if a secret was ever committed or printed in CI/logs, generate a new one (openssl rand -hex 32) and invalidate the old value.

  • Pre-commit hook — a hook at .githooks/pre-commit rejects staged files containing JWT_SECRET=[0-9a-f]{32,}. Enable it once per clone:

    git config core.hooksPath .githooks
    

    The check is local (core.hooksPath is not set globally by the repo).