From ArchWiki
Jump to navigation Jump to search

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Installation procedures in the AUR do not work. (Discuss in Talk:Nix)

Nix is a purely functional package manager that aims to make package management reliable and reproducible.


There are three choices for a Nix installation, one is supported by Arch Linux, the next officially supported by Nix, and the last not being supported at all.


Install the nix package.

Upstream installation script

Download the file with curl --proto '=https' --tlsv1.2 -sSfL -o, view it: less ./, and run the script ./ --daemon to start Nix installation.

Warning: Running curl some-url | sh, as the Nix documentation suggests, is considered as a security risk, because it executes unknown code, that might even be corrupted during the download. Therefore it is recommended to manually download the script and check it, before executing it.


archlinux-nixAUR can be used to 'bootstrap' an Arch Linux compatible Nix system by setting up the required groups and permissions.

After installing nix and archlinux-nixAUR, list the available commands:

$ archlinux-nix

To complete the installation, follow all of these steps:

Prepare Arch for the Nix installation:

# archlinux-nix setup-build-group  # setup build groups
# archlinux-nix bootstrap          # bootstrap the system

Configure a default Nix channel and update it:

$ nix-channel --add
$ nix-channel --update
$ nix-env -u

After first install, and before rebooting, activate Nix in each new shell:

$ source /etc/profile.d/nix{,-daemon}.sh

This makes Nix's daemon (and package manager) functional without rebooting. It update your PATH to Nix's liking. Check it by echo $PATH. Run this in each new shell session until you have restarted.


To have the Nix daemon launched at boot time, enable nix-daemon.service.

Add required users to the nix-users group in order to access the daemon socket.

Add a channel and update it.

$ nix-channel --add
$ nix-channel --update

Tips and tricks

With the shell configured, the following should install hello into your updated PATH: /nix/store/[hash]-hello-[version]/bin/hello.

$ nix-env -iA nixpkgs.hello

Run hello and make sure it is in the right PATH. If it works, you can remove it simply by

$ nix-env --uninstall hello

Or you can check the list of installed program by (q stands for query)

$ nix-env -q

You can also check generations by

$ nix-env --list-generations

Check more details in the nix-env(1) manual.


Permission denied

Running nix repl or nix-env -u as user produces

cannot connect to daemon at '/nix/var/nix/daemon-socket/socket: permission denied

If you just installed nix, you need to reboot.

Warning message about root user channels

warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring

If the above message shows up when using Nix, the root user will need to update their channels.

# nix-channel --update

Sandbox build issues

error: while setting up the build environment: executing '/usr/bin/bash': No such file or directory
error: builder for '/nix/store/mh8hl6c7gyyqrnzrln4j2jxg79n32slf-nixpkgs-21.11pre300283.f930ea227ce.drv' failed with exit code 1
error: build of '/nix/store/mh8hl6c7gyyqrnzrln4j2jxg79n32slf-nixpkgs-21.11pre300283.f930ea227ce.drv' failed
error: program '/usr/bin/nix-env' failed with exit code 100
error: while setting up the build environment: mounting /proc: Operation not permitted
error: program '/usr/bin/nix-env' failed with exit code 1

The issue is known upstream: #2311, #3000, and #4636.

The most common fix is to disable sandboxing in the configuration file, then Restart the nix-daemon service.

# disable sandboxing
sandbox = false

See also