Install Nix on Fedora 44
Install Nix on Fedora 44
Goal: Install Nix from Fedora’s official packages, enable the daemon (or choose single-user/rootless deliberately), verify flakes, and know where Fedora documents live on disk.
Prefer dnf install nix on Fedora 44+ over the classic curl | sh upstream installer unless you have a specific reason (custom builds, non-Fedora policy). The distro package is the supported path for SELinux and /nix integration.
Prerequisites
| Need | Check |
|---|---|
Fedora 44 (or current release with nix in repos) |
cat /etc/os-release |
| sudo | Wheel user |
| Disk | Prefer ≥20 GB free on the filesystem that will hold /nix |
| Network | For first substitutes from cache.nixos.org |
free -h
df -h /
# or wherever /nix will liveInstall modes (choose one)
Fedora packaging supports several setups (see package docs):
| Mode | Install sketch | Who builds | Best for |
|---|---|---|---|
| Multi-user + daemon (recommended) | dnf install nix + enable nix-daemon |
nixbld users via daemon |
Desktops, shared machines, matches NixOS mental model |
| Single-user | install excluding daemon / singleuser subpackage | Your UID | Solo laptops if daemon undesired |
| Rootless / Atomic | special /nix storage (bind mount) |
Your UID / constrained | Silverblue, Kinoite, bootc images |
This chapter emphasizes multi-user daemon on classic Workstation/Server, then notes Atomic.
Multi-user install (Workstation / Server)
1. Install packages
sudo dnf install -y nixOn some releases you may see related packages (nix-daemon, docs). Let dnf pull the recommended set.
rpm -q nix
rpm -ql nix | head
ls /usr/share/doc/nix/ 2>/dev/null || trueRead the Fedora-specific README if present:
less /usr/share/doc/nix/README.fedora.md
# or
rpm -qd nix2. Enable the daemon
sudo systemctl enable --now nix-daemon.service
systemctl status nix-daemon --no-pager3. Groups and shell environment
Multi-user installs typically put builders in nixbld and may require your user in a group to talk to the daemon. Fedora’s README is authoritative; common pattern:
# If docs say so:
getent group nixbld
groups # ensure you can use nix after re-loginLog out/in or open a new login shell so profile snippets from /etc/profile.d/ or /nix/... apply.
# Common: bash/zsh pick up nix from profile.d
bash -l -c 'command -v nix && nix --version'4. First smoke test
nix --version
nix doctor || true
# Classic hello (works even if you still learn modern CLI)
nix-shell -p hello --run hello
# Modern CLI + flakes (Fedora enables flakes in packaging — verify):
nix show-config | rg -n 'experimental-features|flakes|nix-command' || true
nix run nixpkgs#helloIf nix run nixpkgs#hello works, flakes + substitutes are alive.
Configure system vs user
Daemon / system config
Multi-user security options often live in /etc/nix/nix.conf (read by the daemon). Examples operators care about:
# Inspect effective config
nix show-config | rg -n 'sandbox|experimental|substituter|trusted'
# Example: ensure sandbox (security) — only if not already set by package defaults
# sudo tee -a /etc/nix/nix.conf <<'EOF'
# sandbox = true
# EOF
# sudo systemctl restart nix-daemonDo not casually set trusted-users = * or disable sandbox “to go faster” on a daily driver. Prefer package defaults; change with intent.
User config
mkdir -p ~/.config/nixFedora may already enable flakes system-wide. If nix flake fails, set:
cat >> ~/.config/nix/nix.conf <<'EOF'
experimental-features = nix-command flakes
EOFRe-check:
nix show-config | rg experimental-featuresSingle-user mode (optional)
When you intentionally avoid the daemon (read Fedora docs for exact package names):
# Illustrative — confirm package set on your release:
# sudo dnf install nix --exclude nix-daemon
# or: sudo dnf install nix-singleuserTypical consequences:
- Builds run as your user
- Socket/daemon workflow differs
- Closer to “my laptop only,” farther from NixOS’s always-daemon world
If you plan NixOS soon, prefer multi-user so daemon habits match.
Atomic / immutable desktops (Silverblue, Kinoite, bootc)
Immutable systems often make /nix not writable as a normal directory. Community patterns:
- Store data under
/var/nix(writable)
- Bind-mount
/var/nix→/nix(Nix rejects a mere symlink for the store root in many setups)
Example systemd mount unit (adapt paths; verify against current Atomic guidance):
# /etc/systemd/system/nix.mount (illustrative)
[Unit]
Description=Bind mount /var/nix to /nix
[Mount]
What=/var/nix
Where=/nix
Type=none
Options=bind
[Install]
WantedBy=local-fs.targetsudo mkdir -p /var/nix /nix
sudo systemctl daemon-reload
sudo systemctl enable --now nix.mount
# then install/enable nix packages per Atomic docsAlso expect SELinux labeling steps on some images. Prefer Fedora documentation and the nix package README over blog posts when they disagree.
Verify deeply (acceptance checklist)
# Binary + version
nix --version
# Daemon (multi-user)
systemctl is-active nix-daemon
# Store exists and is a directory (not a broken symlink)
findmnt /nix || ls -ld /nix
df -h /nix
# Flake metadata (network)
nix flake metadata nixpkgs --json | head -c 200; echo
# Build something small and inspect store path
nix build nixpkgs#hello --print-out-paths
nix path-info -r $(nix build nixpkgs#hello --print-out-paths) | headRecord versions in your lab notes:
mkdir -p ~/lab/nixos-book/nix-on-linux
{
echo "date: $(date -Iseconds)"
echo "os: $(. /etc/os-release; echo $PRETTY_NAME)"
nix --version
rpm -q nix
systemctl is-active nix-daemon || echo "daemon inactive"
} | tee ~/lab/nixos-book/nix-on-linux/install-record.txtUpstream installer vs Fedora package
Fedora dnf package |
Upstream multi-user script | |
|---|---|---|
| SELinux | Integrated for Fedora | Often needs extra steps |
| Updates | dnf upgrade |
Separate Nix upgrade story |
| Flakes | Packaged defaults (enabled OOTB historically) | You enable experimental features |
| Support story | Fedora + Nix communities | Nix upstream |
| Custom Nix builds | Harder | Easier |
You can still use nixpkgs the same way either way. This book assumes Fedora packaging on F44+.
Uninstall / reset notes
If you need a clean slate (lab machine):
# Stop daemon first
sudo systemctl disable --now nix-daemon 2>/dev/null || true
# Remove packages
sudo dnf remove nix
# WARNING: deleting the store removes all Nix software
# sudo rm -rf /nixOnly wipe /nix if you accept redownloading everything.
Common failures
| Symptom | Likely cause | Direction |
|---|---|---|
nix: command not found |
No login shell / PATH | New login; check profile.d |
| Cannot connect to daemon | nix-daemon down; permissions |
systemctl status nix-daemon; groups |
| Flakes experimental error | features not enabled | ~/.config/nix/nix.conf or /etc/nix/nix.conf |
| SELinux denials | Mislabel / non-Fedora install | ausearch -m avc -ts recent; prefer dnf package |
/nix read-only |
Atomic without bind mount | Atomic section above |
| Disk full during build | Store on small root | Move store / free space / GC later chapter |
Lab
- Complete multi-user install on Fedora 44.
- Capture
install-record.txtas above.
- Run
nix run nixpkgs#cowsay -- "fedora+nix".
- Skim
/usr/share/doc/nix/and note three Fedora-specific warnings in your lab journal.
Checkpoint
nix run nixpkgs#hellosucceeds
- Daemon mode intentional (or single-user/rootless documented)
- You know where system vs user
nix.conflive
- Free space plan for
/nixwritten down
Further depth
- Store, profiles, GC
- Concepts: Modern CLI, Flakes