Why I love NixOS

Source

Summary

NixOS treats the entire operating system as a deterministic, reproducible artifact built from a single declarative config file, eliminating state drift that plagues traditional distros. The article and HN discussion converge on a surprisingly strong thesis: NixOS is uniquely suited for the AI coding agent era because its declarative nature means agents can safely install toolchains, modify system configs, and experiment - with guaranteed rollback if anything breaks.

Key Insight

  • NixOS is not just another Linux distro - it is the output of the Nix functional package manager. The OS is a build artifact, not accumulated state. This means you can rebuild, diff, and rollback the entire system like code.
  • The “one file to rule them all” aspect is the real value: packages, desktop settings, keyboard mappings, services, and deployment configs all live in a single declarative Nix DSL file (or a set of them under version control).
  • Nix works cross-platform (macOS via nix-darwin, Linux, experimentally FreeBSD) - so your dev tooling stays uniform even if you don’t run NixOS on every machine.
  • The AI agent angle is the most actionable insight: coding agents (Claude Code, Codex, etc.) can use nix shell or nix develop to bring in toolchains without polluting the base system. One commenter packaged “super daunting” software in hours that would have taken weeks manually, letting Claude/Codex spin unsupervised.
  • A concrete example from the article: building a Rust voice-to-text agent without ever installing rustup globally. The agent pulled in the entire Rust toolchain via Nix, compiled in an isolated shell, and left zero traces on the host.
  • nix flake check transforms ad-hoc agent experiments into reproducible, verifiable artifacts - a much stronger foundation for production than hoping the environment matches.
  • For deployment, dockerTools.buildLayeredImage produces deterministic, smaller Docker images - better than traditional Dockerfiles.
  • HN consensus: the learning curve is steep (the Nix language is widely disliked), documentation is scattered, and AI models hallucinate Nix package names. But the mcp-nixos MCP server and cloning nixpkgs locally were cited as practical workarounds.
  • Multiple HN users report that NixOS is the only OS where they trust AI agents to make system-level changes, because changes are auditable in git diffs before activation and rollback is guaranteed.