feat: migrate the site to React and add a Nix flake #2

Merged
marti merged 4 commits from t3/migrate-site-react-nix-flake into main 2026-11-12 02:28:19 +01:00
Owner

Summary

Rewrites the static landing page as a client-only React app (Vite, Tailwind 4, Radix, TanStack Router) and adds a Nix flake with a devShell, a package and a NixOS module.

Each tab is now a route. The URL decides which tab is selected, and Radix Tabs handles the keyboard and ARIA behaviour that app.js used to do by hand:

<RootLayout> (src/routes/__root.tsx)       hgroup, CV links, 404
  <SectionTabs> (src/components)           Radix Tabs, value = current route
    /          -> <Projects>  ┐
    /links     -> <Links>     ├ <LeaderList>  dotted "term . . . detail" rows
    /contact   -> <Contact>   ┘
src/content.ts                             all projects, links, contacts, CVs
nix/
├── package.nix   # dist/ + .gz files, deps read from package-lock.json (importNpmLock, no hash to bump)
├── module.nix    # services.marti-web: nginx vhost, SPA fallback, caching, security headers
└── test.nix      # NixOS VM test of the module
services.marti-web = {
  enable = true;
  domain = "example.com";
  openFirewall = true;
  virtualHost = { enableACME = true; forceSSL = true; };
};

Evidence

  • Before: index.html + style.css + app.js, one URL, no tests.
    After: pixel-identical at 1100px and 375px (compared with screenshots of main), and /links and /contact can be linked to directly.
  • npm test: 4 passed. Covers the default tab, moving through tabs with the arrow keys (URL and focus follow), loading a tab from its URL, and the 404 page.
  • nix flake check: all checks passed. The NixOS VM test boots nginx with the module and checks that:
    • /links and /contact return index.html
    • index.html is sent with Cache-Control: no-cache, no ETag, and a CSP
    • /assets/*.js is immutable and served gzip-compressed
    • a missing asset returns 404, not index.html
  • Built site loaded in Chromium with the module's CSP: renders, fonts load, no console errors.
  • Bundle: JS 105 kB gz (React plus the router), CSS 3 kB gz. The whole nix build output is 497 KiB and depends on nothing else.

Merge Danger

Door: two-way

Nothing is deployed until a NixOS host enables services.marti-web. Reverting the merge restores the old static files.

Blast Radius: small

  • The first load now runs about 105 kB of JS before anything shows; the old page was plain HTML. On a slow device the content appears later.
  • Any server other than the NixOS module needs its own fallback from unknown paths to index.html, or /links and /contact return 404 on reload.
  • The CSP is default-src 'self'. Adding a third-party script, font or embed later means loosening it in nix/module.nix.

🤖 Generated with Claude Code

## Summary Rewrites the static landing page as a client-only React app (Vite, Tailwind 4, Radix, TanStack Router) and adds a Nix flake with a devShell, a package and a NixOS module. Each tab is now a route. The URL decides which tab is selected, and Radix Tabs handles the keyboard and ARIA behaviour that `app.js` used to do by hand: ```text <RootLayout> (src/routes/__root.tsx) hgroup, CV links, 404 <SectionTabs> (src/components) Radix Tabs, value = current route / -> <Projects> ┐ /links -> <Links> ├ <LeaderList> dotted "term . . . detail" rows /contact -> <Contact> ┘ src/content.ts all projects, links, contacts, CVs ``` ```text nix/ ├── package.nix # dist/ + .gz files, deps read from package-lock.json (importNpmLock, no hash to bump) ├── module.nix # services.marti-web: nginx vhost, SPA fallback, caching, security headers └── test.nix # NixOS VM test of the module ``` ```nix services.marti-web = { enable = true; domain = "example.com"; openFirewall = true; virtualHost = { enableACME = true; forceSSL = true; }; }; ``` ## Evidence - **Before:** `index.html` + `style.css` + `app.js`, one URL, no tests. **After:** pixel-identical at 1100px and 375px (compared with screenshots of `main`), and `/links` and `/contact` can be linked to directly. - `npm test`: 4 passed. Covers the default tab, moving through tabs with the arrow keys (URL and focus follow), loading a tab from its URL, and the 404 page. - `nix flake check`: all checks passed. The NixOS VM test boots nginx with the module and checks that: - `/links` and `/contact` return `index.html` - `index.html` is sent with `Cache-Control: no-cache`, no ETag, and a CSP - `/assets/*.js` is `immutable` and served gzip-compressed - a missing asset returns 404, not `index.html` - Built site loaded in Chromium with the module's CSP: renders, fonts load, no console errors. - Bundle: JS 105 kB gz (React plus the router), CSS 3 kB gz. The whole `nix build` output is 497 KiB and depends on nothing else. ## Merge Danger **Door:** two-way Nothing is deployed until a NixOS host enables `services.marti-web`. Reverting the merge restores the old static files. **Blast Radius:** small - The first load now runs about 105 kB of JS before anything shows; the old page was plain HTML. On a slow device the content appears later. - Any server other than the NixOS module needs its own fallback from unknown paths to `index.html`, or `/links` and `/contact` return 404 on reload. - The CSP is `default-src 'self'`. Adding a third-party script, font or embed later means loosening it in `nix/module.nix`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The tabs are now routes (/, /links, /contact) driven by Radix Tabs, so
each section has its own URL while keeping the keyboard and ARIA
behaviour. Content lives in src/content.ts. Fonts are bundled through
Vite so they get hashed, cacheable names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The package builds the static site from package-lock.json via
importNpmLock (no npmDepsHash to maintain) and precompresses text
assets. The NixOS module serves it with nginx: SPA fallback, immutable
caching for hashed assets, gzip_static and security headers.
nix flake check runs the unit tests and a VM test of the module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marti merged commit 0071950ccd into main 2026-11-12 02:28:19 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marti/web!2
No description provided.