SELinux, Atomic, and day-2 ops
SELinux, Atomic, and day-2 ops
Goal: Keep Fedora’s security and immutability model while running Nix—without disabling SELinux—and operate the store like an adult (disk, daemon, upgrades).
SELinux: do not “fix” Nix by disabling it
Fedora’s packaged Nix is built to work under enforcing SELinux. Prefer:
getenforce
sudo ausearch -m avc -ts recent 2>/dev/null | tail -20If you see denials after a non-Fedora install method, switch to the Fedora package before opening policy holes.
| Do | Don’t |
|---|---|
dnf install nix |
setenforce 0 as permanent fix |
Read /usr/share/doc/nix/ |
Copy random chcon -R from old blog posts without understanding |
| File bugs against Fedora nix package when policy is wrong | Disable SELinux system-wide |
Atomic desktops and bootc
Problem
Image-based systems often make /usr immutable and restrict creating /nix on root.
Pattern A — bind mount
sudo mkdir -p /var/nix
# ensure /nix exists as mount point
sudo mkdir -p /nixsystemd .mount unit bind /var/nix → /nix (see Install chapter). Then install Nix packages and enable daemon if supported on that image.
Pattern B — rootless / pure user Nix
Fedora packaging notes mention pure rootless mode useful on Atomic. Follow current README.fedora.md—flags and subpackages change.
Pattern C — Nix in a toolbox/distrobox
Some Atomic users keep the host minimal and run a Fedora toolbox with classic /nix for heavy dev. Tradeoff: another layer; still teaches Nix well.
# illustrative
toolbox create -i fedora-toolbox:44 nixdev
toolbox enter nixdev
# then dnf install nix inside toolbox if appropriateDay-2 operations checklist
Daemon health
systemctl status nix-daemon --no-pager
journalctl -u nix-daemon -b --no-pager | tail -40Disk
df -h /nix
nix store gc
# optional deep clean of old generations
# nix-collect-garbage -dTrust and config
nix show-config | rg -n 'substituter|trusted|sandbox|experimental'Upgrade Nix itself (Fedora)
sudo dnf upgrade nix
sudo systemctl restart nix-daemon
nix --versionFlake-locked nixpkgs upgrades are separate from upgrading the Nix binary.
Networking / proxies / corporate TLS
If substitutes fail:
curl -I https://cache.nixos.org
# corporate MITM: may need custom CA trust for Nix — advanced; document carefullyBackup thoughts
| Path | Back up? |
|---|---|
flake.nix / flake.lock / HM repo |
Yes — this is the real config |
/nix/store |
Optional; can rebuild from locks (slow) |
| Profile generation list | Nice; not required if flakes exist |
On NixOS you will also back up host flake + secrets—not the entire store.
Performance tips (laptop)
- Keep direnv projects few and GC occasionally
- Use
nix-output-monitorfor readability, not speed
- Prefer substitutes; local compiles of browsers hurt battery
nix settings/max-jobsandcorescan be tuned innix.conf
# example user conf — adjust to CPU
# max-jobs = auto
# cores = 0Daemon may need matching system conf for multi-user.
Lab
- With SELinux enforcing, run
nix run nixpkgs#helloand confirm no new AVCs.
- Measure
df -h /nixbefore/afternix developon a heavy shell; runnix store gc.
- If on Atomic, document your
/nixstrategy in the lab charter.
Checkpoint
- SELinux remains enforcing
- Daemon healthy after reboot
- Disk budget monitored
- Atomic path documented if applicable