One repo runs everything — Claude Code from my NixOS dotfiles

Claude CodeMCPAI IntegrationNixOSAutomationDevOps
Image 1
Image 2
Image 3
Image 4
Image 5

Slides (PDF)

What it is

I run my servers, my monitoring, my research and about 30 projects from one folder: my NixOS repo, my-nixos-infrastructure. Every machine I manage is a profile in it: desktops, laptops, a rented VPS and the NAS. I open Claude Code in that folder, and from there it works on all of it.

The repo is more than the machine configs. It holds the rules the assistant follows, its slash commands, the MCP servers it connects to, the registry of my other projects and the plans for what comes next.

Infrastructure: change, commit, the machines deploy themselves

  • It edits the Nix files. A change to a server is a change to a file in the repo, the same as a change to my laptop.
  • It commits and pushes to my own Git server. A build farm builds every machine profile from that commit.
  • The servers deploy themselves on their schedule, and run a check after the deploy. If the check fails, the server rolls back.
  • My desktop and laptop deploy when I click, or when I ask the assistant: it runs the guarded deploy script. A hook blocks the bare rebuild-and-switch, because that command can pick up the wrong hardware config on a remote machine.

Monitoring: it reads what the machines report

  • Prometheus directly. It reads the firing alerts and the metrics from the server, without me copying graphs into the chat.
  • Alerts that read Docker itself. After the NAS outage of 4 November, a collector on the server and the NAS asks Docker which containers failed or are unhealthy, and Grafana alerts on it.
  • Server deploys report their result with a health check of the machine after it.
  • Slash commands for the repeated checks: health of the databases, the uptime monitors, the services that are behind on updates.

Research: questions become plans in the repo

  • A daily security pipeline. It lists what runs on my machines, matches it against the new CVE records and the list of exploited bugs, and an AI model judges what really affects me. In one 7-day run, 17,073 records became one message. Details: security-news-pipeline.
  • Bigger questions become plans. The assistant reads the code, the docs and the web, sometimes with parallel agents, and the result lands in the repo as a plan document. There are 57 now: migrations, upgrades, runbooks, hardware, new services.
  • Private work stays at home. A local model runs on the NAS GPU, for anything that shouldn't leave my network.

All my projects: one registry, separate repos

  • Each project keeps its own repo, rules and memory. The workout app, this portfolio, my fork of Plane, knowledge bases and more.
  • The dotfiles repo holds the registry: where each project lives, where its memory is and which ticket project it uses. Before the assistant touches a project, it reads that project's memory first.
  • One ticket tracker. Most projects have a ticket project in my self-hosted Plane. It creates, comments and closes work items there through MCP.
  • The same setup on desktop and laptop. Memory, skills and sessions sync every 15 minutes, so I can close a session on one machine and continue on the other.

What it may touch

  • Code first. One Nix module generates the Claude Code settings: 94 allow rules and 34 deny rules in the base, plus the grants I approve one by one. Reading SSH keys and credential files is blocked. A hook checks every shell command and every file read, edit, write and search before it runs, in about 10 ms per hook.
  • A second AI. Since November every step gets an audit by a second model (Opus), then I verify each finding in the code and test. The first 5 audits found 5 rounds of real defects; 3 were introduced by the change being audited, and one had shipped with green tests. This is a rule I gave the assistant, not code.
  • Me. I decide what gets built, I review it, and anything that goes out under my name, like this post, I publish myself.

Less context, loaded when it applies

With this much in one repo, the instructions have to stay small. The two CLAUDE.md files that load in every session went from 25.3 KB to 14.4 KB:

  • Per-machine rules are injected at session start, by machine profile.
  • File rules load when a matching file is read or edited. Editing a Nix file brings the Nix rules; the deploy rules load when the deploy script is opened.
  • Each project's facts stay in that project's memory, not in the dotfiles one.

What broke

A read-only settings file ate my permission grants. The first version of the module installed the settings file as a read-only link into the Nix store. When Claude Code asked for a new permission and I clicked yes, the write failed without a message, and the same prompt came back next session. Fix (March 2026): the module writes a normal file, and on every activation it re-syncs only the keys it owns (hooks, deny rules), so the grants I click stay.

Today

WhatState
MachinesDesktops, laptops, a VPS and the NAS, one profile each
DeploysBuild farm; servers deploy themselves with a check and rollback, workstations on demand
ProjectsAbout 30 in the registry, each with its own memory
MCP servers6 in the repo: tickets, Grafana, PostgreSQL, n8n and two more
Slash commandsAbout 30 for the repeated ops work
Plans in the repo57
Permission rules94 allow / 34 deny in the base, generated by one Nix module
Second-AI auditMy rule since November 2026, not enforced by code

Stack

NixOS, Home Manager, Claude Code, Model Context Protocol (MCP), Plane (self-hosted), Grafana, Prometheus, PostgreSQL, n8n, Gitea, Bash.

Status

In daily use. The repo is private; it is the same codebase as my-nixos-infrastructure.

Related: deploy-sh-guardrail (the deploy guard), security-news-pipeline (the daily CVE triage), workout-app (an app I built with its own MCP server).