3 comments

[ 3.8 ms ] story [ 29.9 ms ] thread
NixOS + Flakes turns your entire operating system into a folder of .nix files. That folder is a git repo. Give Claude Code access to that repo and it can manage everything — packages, services, hardware config, shell, bootloader. I've been calling this ClaudeOS: an operating system entirely managed by Claude Code.

I'm not a developer. My background is data science and finance. Six months ago I couldn't tell you what a Nix derivation was.

I started because I wanted Claude Code to manage my system, not just my code. Tried it on Ubuntu first and it was a disaster — Claude would edit .bashrc and break my shell, install packages that conflicted with each other, no way to undo any of it cleanly. A friend mentioned NixOS, I installed it on my Framework laptop, and within a week I realized this is what AI-assisted system management should look like. Claude edits a .nix file, I rebuild, if it breaks I roll back in one command. No more "what did the AI just do to my system?"

It snowballed from there. ~470 commits later I'm running 7 machines off this config — my Framework 16 dev workstation, a ThinkPad, and a bunch of business laptops for people who've never opened a terminal. Two profiles: a "tech" profile with 350+ packages and a full AI toolchain (Claude Code, Cursor, local speech-to-text), and a "business" profile with ~40 curated packages for office use. Adding a new machine is three lines in flake.nix.

Some things I built along the way:

A script that spins up Claude Code in a sandboxed git worktree with bubblewrap + seccomp so it can work autonomously in the background. It runs in a tmux session and loops with fresh context up to 5 times. I use it for overnight refactoring.

Custom NixOS installer ISOs — I ship a USB stick to someone, they plug it in, and they get a working system with Claude Code pre-configured as their "sysadmin." They ask Claude to install software, Claude edits the config, they rebuild. I manage their machines remotely via git push.

CI/CD with BATS tests, ShellCheck, security scanning. A two-branch model where personal (my dev branch) auto-syncs to master via CI with path sanitization so nothing personal leaks to the public repo.

The core insight: NixOS is the only OS I've used where AI can't permanently break anything. Declarative config means Claude always knows the exact system state. Atomic upgrades mean every rebuild either succeeds completely or doesn't happen. If something goes wrong, I pick the previous generation from the boot menu. I've bricked my system maybe 15 times and recovered in under a minute every time.

What still sucks: the Nix learning curve is real even with AI. Claude writes non-idiomatic Nix all the time and I can't always tell. Flake lock updates break things in ways that take hours to debug. Error messages are famously terrible. And NixOS is not for everyone — it's a tradeoff between upfront complexity and long-term reliability.

Is anyone else doing something like this? Not just using AI to write code, but to manage and evolve their actual operating system?

Repo: https://github.com/jacopone/nixos-config

How do you manage secrets in this setup? Are they injected at build time? Or does it require some manual setup by the user once the system is up and running?
I don't know how OP manages their secrets, but I am running NixOs and am letting 1Password manage all my secrets. 1Password can manage SSH agents, can inject environment variables and manage passwords/keys in the browser. All I need to do when I setup a new machine with NixOS is connect my 1Password to its account manually, after that it's all automated.