Home Explore Blog Models CI



nixpkgs

8th chunk of `nixos/doc/manual/installation/installing.chapter.md`
7d9188d70664703055d570525de3a3e78678dc7cb6165f3f0000000100000c8b
    one). Every time you change the NixOS configuration (see [Changing
    Configuration](#sec-changing-config)), a new item is added to the
    menu. This allows you to easily roll back to a previous
    configuration if something goes wrong.

    Use your declared user account to log in.
    If you didn’t declare one, you should still be able to log in using the `root` user.

    ::: {.note}
    Some graphical display managers such as SDDM do not allow `root` login by default, so you might need to switch to TTY.
    Refer to [](#sec-user-management) for details on declaring user accounts.
    :::

    You may also want to install some software. This will be covered in
    [](#sec-package-management).

### Installation summary {#sec-installation-manual-summary}
[]{#sec-installation-summary} <!-- legacy anchor -->

To summarise, [Example: Commands for Installing NixOS on `/dev/sda`](#ex-install-sequence)
shows a typical sequence of commands for installing NixOS on an empty hard
drive (here `/dev/sda`). [Example: NixOS Configuration](#ex-config) shows a
corresponding configuration Nix expression.

::: {#ex-partition-scheme-MBR .example}
### Example partition schemes for NixOS on `/dev/sda` (MBR)
```ShellSession
# parted /dev/sda -- mklabel msdos
# parted /dev/sda -- mkpart primary 1MB -8GB
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
```
:::

::: {#ex-partition-scheme-UEFI .example}
### Example partition schemes for NixOS on `/dev/sda` (UEFI)
```ShellSession
# parted /dev/sda -- mklabel gpt
# parted /dev/sda -- mkpart root ext4 512MB -8GB
# parted /dev/sda -- mkpart swap linux-swap -8GB 100%
# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# parted /dev/sda -- set 3 esp on
```
:::

::: {#ex-install-sequence .example}
### Commands for Installing NixOS on `/dev/sda`

With a partitioned disk.

```ShellSession
# mkfs.ext4 -L nixos /dev/sda1
# mkswap -L swap /dev/sda2
# swapon /dev/sda2
# mkfs.fat -F 32 -n boot /dev/sda3        # (for UEFI systems only)
# mount /dev/disk/by-label/nixos /mnt
# mkdir -p /mnt/boot                      # (for UEFI systems only)
# mount -o umask=077 /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
# nixos-generate-config --root /mnt
# nano /mnt/etc/nixos/configuration.nix
# nixos-install
# reboot
```
:::

::: {#ex-config .example}
### Example: NixOS Configuration
```ShellSession
{ config, pkgs, ... }: {
  imports = [
    # Include the results of the hardware scan.
    ./hardware-configuration.nix
  ];

  boot.loader.grub.device = "/dev/sda";   # (for BIOS systems only)
  boot.loader.systemd-boot.enable = true; # (for UEFI systems only)

  # Note: setting fileSystems is generally not
  # necessary, since nixos-generate-config figures them out
  # automatically in hardware-configuration.nix.
  #fileSystems."/".device = "/dev/disk/by-label/nixos";

  # Enable the OpenSSH server.
  services.sshd.enable = true;
}
```
:::

## Additional installation notes {#sec-installation-additional-notes}

```{=include=} sections
installing-usb.section.md
installing-pxe.section.md
installing-kexec.section.md
installing-virtualbox-guest.section.md
installing-from-other-distro.section.md
installing-behind-a-proxy.section.md
```

Title: NixOS Installation Summary: Partitioning, Commands, and Basic Configuration
Summary
This chunk concludes the initial NixOS installation guide by detailing post-installation actions, such as the GRUB boot menu's rollback feature and user login procedures, noting potential root login restrictions in graphical display managers. It then provides a comprehensive 'Installation summary' with practical examples. These include `parted` commands for example partition schemes on `/dev/sda` for both MBR and UEFI systems, a typical command sequence for installing NixOS on a partitioned disk (covering filesystem creation, mounting, configuration generation, and installation), and an example NixOS configuration snippet that sets up the bootloader and enables SSH. The chunk ends by introducing a section on 'Additional installation notes'.