Using Nix Day-to-Day
This page focuses on how Nix fits into everyday development work.
You don’t need to “go all in” on Nix to get value. Many teams start by using Nix as:
- a tool installer
- a dev environment manager
- a way to make workflows predictable
We’ll explore common patterns and commands you can use immediately.
Mental Model: Nix as a Tool, Not a Lifestyle
Section titled “Mental Model: Nix as a Tool, Not a Lifestyle”You can think of Nix as:
- a package runner (
nix run) - a temporary environment (
nix shell) - a build orchestrator (
nix build)
All of these can coexist with your existing tools.
Running Tools Without Installing Them
Section titled “Running Tools Without Installing Them”One of the fastest wins with Nix is running tools without modifying your system.
Run a tool once
Section titled “Run a tool once”nix run nixpkgs#ripgrep -- --versionThis:
- downloads the tool if needed
- runs it
- leaves your system unchanged
Run a specific version
Section titled “Run a specific version”nix run nixpkgs/nixos-23.11#ripgrep -- --versionCompare with your system version
Section titled “Compare with your system version”rg --version || echo "ripgrep not installed globally"This is especially useful for CI parity and trying tools safely.
Temporary Shell Environments
Section titled “Temporary Shell Environments”Temporary shells are a common daily workflow.
Create a shell with specific tools
Section titled “Create a shell with specific tools”nix shell nixpkgs#git nixpkgs#jq nixpkgs#curlNow check what’s available:
which gitwhich jqwhich curlExit the shell:
exitUse a shell to run a command
Section titled “Use a shell to run a command”nix shell nixpkgs#nodejs -c node --versionWhy nix shell Is Different from Virtualenvs or Containers
Section titled “Why nix shell Is Different from Virtualenvs or Containers”- Tools are explicitly declared
- No activation scripts
- No mutation of global state
- Fast to enter and exit
If it breaks, you exit the shell and you’re back to normal.
Reproducible Project Environments
Section titled “Reproducible Project Environments”For projects, you usually want the same tools every time.
Quick ad-hoc approach (no files yet)
Section titled “Quick ad-hoc approach (no files yet)”nix shell nixpkgs#nodejs nixpkgs#pnpm nixpkgs#jqMove toward a project file (preview)
Section titled “Move toward a project file (preview)”Later, this becomes:
nix develop(with configuration living in the repo)
We’ll cover this more in Dev Environments and Flakes.
Running Existing Build Tools Inside Nix
Section titled “Running Existing Build Tools Inside Nix”Nix works well with existing ecosystems.
Java example
Section titled “Java example”nix shell nixpkgs#jdk17 nixpkgs#maven -c mvn testNode example
Section titled “Node example”nix shell nixpkgs#nodejs nixpkgs#npm -c npm testPython example
Section titled “Python example”nix shell nixpkgs#python3 -c python --versionThe important thing: the toolchain becomes reproducible, even if the build system stays the same.
Working with Multiple Versions Side by Side
Section titled “Working with Multiple Versions Side by Side”Nix makes it easy to compare versions.
Run two versions of the same tool
Section titled “Run two versions of the same tool”nix shell nixpkgs/nixos-23.11#nodejs -c node --versionnix shell nixpkgs/nixos-24.05#nodejs -c node --versionUse different versions in different projects
Section titled “Use different versions in different projects”No global installs. No conflicts.
Using Nix in CI Locally
Section titled “Using Nix in CI Locally”Many teams first adopt Nix by matching CI locally.
Example: mimic a CI environment
Section titled “Example: mimic a CI environment”nix shell nixpkgs#jdk17 nixpkgs#maven nixpkgs#git -c bashThen run the same commands CI runs.
“Works in this shell” becomes meaningful.
When Things Go Wrong (Normalizing Failure)
Section titled “When Things Go Wrong (Normalizing Failure)”Nix failures often feel abrupt at first.
Common failure modes
Section titled “Common failure modes”- missing dependency
- build blocked from accessing something
- wrong version pinned
These are signals, not random breakage.
Debug approach
Section titled “Debug approach”- read the error
- identify what input is missing
- add it explicitly
Nix failures usually mean “you forgot to declare something.”
Patterns That Scale Well
Section titled “Patterns That Scale Well”These patterns tend to work across teams:
- Use
nix runfor one-off tools - Use
nix shellfor ad-hoc environments - Use
nix developfor project environments - Keep Nix usage near the edges at first
What You Don’t Need to Do Yet
Section titled “What You Don’t Need to Do Yet”You do not need to:
- package everything
- write complex Nix code
- adopt NixOS
- replace your build system
Early success comes from using Nix as a helper, not a replacement.
Optional Exercises
Section titled “Optional Exercises”A) Run a tool you don’t normally have
Section titled “A) Run a tool you don’t normally have”nix run nixpkgs#terraform -- versionB) Create a shell and inspect PATH differences
Section titled “B) Create a shell and inspect PATH differences”env | grep PATHnix shell nixpkgs#jq -c 'env | grep PATH'C) Compare system vs Nix-provided tool
Section titled “C) Compare system vs Nix-provided tool”which gitnix shell nixpkgs#git -c which gitPractical Takeaways
Section titled “Practical Takeaways”- Nix can be useful without full adoption
- Day-to-day workflows focus on
run,shell, anddevelop - Explicit environments reduce surprise
- You can add structure gradually