Nix

From ArchWiki
Jump to navigation Jump to search

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

See the Nix Package Manager Guide for more information.

Installation

Nix is available in the AUR as nixAUR.

Nix is installed by default in the /nix folder.

Installation using archlinux-nix

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

After installing nixAUR, which should install 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 https://nixos.org/channels/nixpkgs-unstable
$ 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. Run it in each new shell session until you have restarted.

Test Installation

$ nix-build -iA hello

Extra Configuration

If using Nix with an unprivileged account is desired, run:

# chown -R $USER: /nix/var/nix/{gcroots,profiles}

If only using unprivileged Nix access, run to silence "warning: Nix search path entry '...' does not exist":

# nix-channel --update