Setting Up Nix on Fedora 44
In the previous post, I covered why I finally adopted Nix on Fedora 44: isolation, reproducibility, and cross-platform consistency.
But rationale only gets you so far. At some point, you have to roll up your sleeves and actually set it up. The good news? Fedora 44 now packages Nix officially, so the process is cleaner than ever - no more wrestling with SELinux contexts or upstream installers by hand.
Here’s how I did it, step by step.
1. Install Nix (Multi-User, Daemon Mode)
Fedora 44 packages Nix in its official repos, so installation is straightforward:
sudo dnf install nix
sudo systemctl enable --now nix-daemon
Run source ~/.zshrc or source ~/.bashrc (depending on your shell) to pick up the new environment variables, then verify the installation:
nix-shell -p hello --run hello
If you see Hello, world!, Nix is working.
2. Configure Nix
Nix’s configuration is split between system-level (read by the daemon) and user-level settings. The split matters: some options, like sandbox, are restricted in multi-user mode and must be set at the system level.
System-Level Configuration
Enable the sandbox (critical for security and isolation):
sudo tee -a /etc/nix/nix.conf <<< "sandbox = true"
sudo systemctl restart nix-daemon
User-Level Configuration
Enable Nix’s modern features in ~/.config/nix/nix.conf:
experimental-features = nix-command flakes
Verify the sandbox is active:
nix show-config | grep sandbox
3. Install Ergonomic Tooling
Nix’s power comes from its ecosystem. These tools make it more usable:
nix profile install \
nixpkgs#direnv \
nixpkgs#nix-direnv \
nixpkgs#nix-your-shell \
nixpkgs#nix-output-monitor \
nixpkgs#nix-tree
Here’s what each does:
- direnv: Auto-loads/unloads per-directory environments when you
cd. - nix-direnv: Makes direnv use Nix flakes, with caching and garbage collection roots.
- nix-your-shell: Keeps you in your preferred shell (e.g., zsh) when entering
nix shellornix develop. - nix-output-monitor (nom): Pipes build output through a readable, structured format.
- nix-tree: A TUI to inspect the Nix store and identify disk usage.
4. Configure direnv
This is critical to our future workflow with nix develop.
direnv auto-loads and unloads per-directory environments when you cd, so with nix-direnv, every project gets its own isolated, reproducible Nix shell. No manual setup, and this can easily be commited together with code in the gitrepo you are working on.
direnv needs a bit of setup to work with Nix. Create its config directory and hook it into your shell:
mkdir -p ~/.config/direnv
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' >> ~/.config/direnv/direnvrc
5. Zsh / Oh-My-Zsh Configuration
Add direnv to Oh-My-Zsh Plugins
Edit ~/.zshrc and add direnv to your plugins list:
plugins=(... direnv)
The Oh-My-Zsh direnv plugin automatically loads direnv’s zsh hook, so environments are loaded/unloaded as you cd without manual setup.
Last, enable nix-your-shell by adding this line after Oh-My-Zsh is sourced:
nix-your-shell zsh | source /dev/stdin
This keeps you in your zsh session - with all your aliases, plugins, etc. - when entering nix shell or nix develop instead of moving your to bash.
The Payoff
With these steps, you now have a Nix setup on Fedora 44 that:
- Runs in multi-user daemon mode with SELinux fully enforcing.
- Integrates seamlessly with direnv for per-project shells.
- Stays consistent across all your machines and projects.
- And more importantly, uses flakes for reproducible environments.
No more curl | sh installers. No more manual version pinning. No more “works on my machine” surprises. Just a clean, declarative, and sandboxed dev environment - exactly as it should be.
In the next post, I’ll put it all together and walk through my workflow for setting up dev environments with nix develop.