nixos-install
8
NixOS

# `nixos-install`

install NixOS

        nixos-install

## Description

This command installs NixOS in the file system mounted on `/mnt`, based on the NixOS configuration specified in `/mnt/etc/nixos/configuration.nix`. It performs the following steps:

- It copies Nix and its dependencies to `/mnt/nix/store`.

- It runs Nix in `/mnt` to build the NixOS configuration specified in `/mnt/etc/nixos/configuration.nix`.

- It installs the GRUB boot loader on the device specified in the option `boot.loader.grub.device`, and generates a GRUB configuration file that boots into the NixOS configuration just installed.

- It prompts you for a password for the root account.

This command is idempotent: if it is interrupted or fails due to a temporary problem (e.g. a network issue), you can safely re-run it.

## Examples

A typical NixOS installation is done by creating and mounting a file system on `/mnt`, generating a NixOS configuration in `/mnt/etc/nixos/configuration.nix`, and running `nixos-install`. For instance, if we want to install NixOS on an `ext4` file system created in `/dev/sda1`:

    $ mkfs.ext4 /dev/sda1
    $ mount /dev/sda1 /mnt
    $ nixos-generate-config --root /mnt
    $ # edit /mnt/etc/nixos/configuration.nix
    $ nixos-install