Reproducible Chaos: Why I Switched to Nix Flakes
Introduction
"It works on my machine."
This sentence is the tombstone of productivity. It is the lie we tell ourselves when a new hire spends three days trying to get the backend running because they have postgres version 15 installed via Homebrew, but the project requires version 14.
We fixed deployment with Docker. We containerized production. But local development? It’s still the Wild West. We rely on README.md files that are six months out of date, nvm commands we forget to run, and the hope that brew upgrade doesn't break our entire Python environment.
The Solution: Nix Flakes
Nix Flakes are the "package.json" for your entire OS. They allow you to define exactly what binaries, compilers, and tools your project needs, pinned to the exact git commit hash.
Imagine this:
- You
cdinto a project directory. - Your prompt changes.
- Suddenly,
nodeis version 20.11.0.postgresis 14.2.cargois available. - You
cdout. They are gone.
No docker-compose up. No nvm use. It just works.
Conclusion: Stop installing things globally
If you take one thing away from this article: Stop using brew install for project dependencies. Your project dependencies belong in your project, described by code, versioned by Git.