nix/README.md
2025-11-28 12:29:05 +08:00

1.5 KiB

How to setup nix on Fedora.

Nix has two different modes of operation:

Daemon mode for multi-user setup

This is recommended by upstream and more seamless. The nix-daemon requires functioning systemd.

Just install the nix package, which pulls in nix-daemon, by running:

$ sudo dnf install nix nix-daemon
$ sudo systemctl enable --now nix-daemon

Single-user mode without nix-daemon

This mode also works in rootless containers and without systemd.

Run:

$ sudo dnf install nix --exclude nix-daemon
$ sudo usermod -aG nixbld $USER

and restart your login session: make sure the nixbld group appears in id output.

This avoids the need to run nix-daemon.

Rootless nix store under /home

Alternatively one can run rootless nix (which uses chroots) with just:

$ dnf install nix-core nix-legacy

The user nix store is: ~/.local/share/nix/root/nix/store.

This also allows sharing one's nix store with toolboxes, etc. However then nix profiles can only be used inside nix shells.

Nixpkgs

You may want to setup a default nix channel.

$ nix-channel add https://nixos.org/channels/nixos-25.11 nixpkgs

for legacy commands, if you don't want to use rolling nixos-unstable.

Testing

A simple way to check nix is working is to run e.g. nix-shell -p hello. After a while of downloading, this should put you in a nix shell subprocess where you should be able to run hello.

Run nix --help to learn more about the nix CLI or read https://nix.dev/.