nix-super/doc/manual/src/installation/installing-binary.md
Valentin Gagarin a2fed6db9e
manual: Contributing -> Development, Hacking -> Building (#9014)
* manual: Contributing -> Development, Hacking -> Building

what's currently called "hacking" are really instructions for setting up
a development environment and compiling from source. we have
a contribution guide in the repo (which rightly focuses on GitHub
workflows), and the material in the manual is more about working
on the code itself.

since we'd otherwise have three headings that amount to "Building Nix",
this change also moves the "classic Nix" instructions to the top.

we may want to reorganise this in the future, and bring
contributor-oriented information closer to the code, but for now let's
stick to more accurate names to ease navigation.
2024-07-25 02:53:06 +00:00

5.3 KiB
Raw Blame History

Installing a Binary Distribution

To install the latest version Nix, run the following command:

$ curl -L https://nixos.org/nix/install | sh

This performs the default type of installation for your platform:

  • Multi-user:
    • Linux with systemd and without SELinux
    • macOS
  • Single-user:
    • Linux without systemd
    • Linux with SELinux

We recommend the multi-user installation if it supports your platform and you can authenticate with sudo.

The installer can configured with various command line arguments and environment variables. To show available command line flags:

$ curl -L https://nixos.org/nix/install | sh -s -- --help

To check what it does and how it can be customised further, download and edit the second-stage installation script.

Installing a pinned Nix version from a URL

Version-specific installation URLs for all Nix versions since 1.11.16 can be found at releases.nixos.org. The directory for each version contains the corresponding SHA-256 hash.

All installation scripts are invoked the same way:

$ export VERSION=2.19.2 
$ curl -L https://releases.nixos.org/nix/nix-$VERSION/install | sh

Multi User Installation

The multi-user Nix installation creates system users and a system service for the Nix daemon.

Supported systems:

  • Linux running systemd, with SELinux disabled
  • macOS

To explicitly instruct the installer to perform a multi-user installation on your system:

$ bash <(curl -L https://nixos.org/nix/install) --daemon

You can run this under your usual user account or root. The script will invoke sudo as needed.

Single User Installation

To explicitly select a single-user installation on your system:

$ bash <(curl -L https://nixos.org/nix/install) --no-daemon

In a single-user installation, /nix is owned by the invoking user. The script will invoke sudo to create /nix if it doesnt already exist. If you dont have sudo, manually create /nix as root:

$ su root
# mkdir /nix
# chown alice /nix

Installing from a binary tarball

You can also download a binary tarball that contains Nix and all its dependencies:

Example

$ pushd $(mktemp -d)
$ export VERSION=2.19.2
$ export SYSTEM=x86_64-linux
$ curl -LO https://releases.nixos.org/nix/nix-$VERSION/nix-$VERSION-$SYSTEM.tar.xz
$ tar xfj nix-$VERSION-$SYSTEM.tar.xz
$ cd nix-$VERSION-$SYSTEM
$ ./install
$ popd

The installer can be customised with the environment variables declared in the file named install-multi-user.

Native packages for Linux distributions

The Nix community maintains installers for some Linux distributions in their native packaging format(https://nix-community.github.io/nix-installers/).

macOS Installation

[]{#sect-macos-installation-change-store-prefix}[]{#sect-macos-installation-encrypted-volume}[]{#sect-macos-installation-symlink}[]{#sect-macos-installation-recommended-notes}

We believe we have ironed out how to cleanly support the read-only root file system on modern macOS. New installs will do this automatically.

This section previously detailed the situation, options, and trade-offs, but it now only outlines what the installer does. You don't need to know this to run the installer, but it may help if you run into trouble:

  • create a new APFS volume for your Nix store
  • update /etc/synthetic.conf to direct macOS to create a "synthetic" empty root directory to mount your volume
  • specify mount options for the volume in /etc/fstab
    • rw: read-write
    • noauto: prevent the system from auto-mounting the volume (so the LaunchDaemon mentioned below can control mounting it, and to avoid masking problems with that mounting service).
    • nobrowse: prevent the Nix Store volume from showing up on your desktop; also keeps Spotlight from spending resources to index this volume
    • if you have FileVault enabled
      • generate an encryption password
      • put it in your system Keychain
      • use it to encrypt the volume
  • create a system LaunchDaemon to mount this volume early enough in the boot process to avoid problems loading or restoring any programs that need access to your Nix store