Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

NixOS installation guide: Difference between revisions

From posixlycorrect wiki
No edit summary
No edit summary
Line 45: Line 45:
== Generate and edit config  ==
== Generate and edit config  ==
# {{ic|$ sudo nixos-generate-config --root /mnt}}
# {{ic|$ sudo nixos-generate-config --root /mnt}}
# {{ic|$ nvim /mnt/etc/nixos/configuration.nix}}
# Edit your configuration: {{ic|$ nvim /mnt/etc/nixos/configuration.nix}}
# {{ic|$ nvim /mnt/etc/nixos/hardware-configuration.nix}}
# Checkout your hardware config: {{ic|$ nvim /mnt/etc/nixos/hardware-configuration.nix}}
# Remember to add the following configuration so that grub works with EFI:
# Remember to add the following to {{ic|configuration.nix}} so that grub works with EFI:
<pre>
<pre>
boot.loader.grub.enable = true;
boot.loader.grub.enable = true;

Revision as of 22:27, 30 August 2024


Introduction

This is a complete guide on installing NixOs, using flakes.

Be sure to have an ISO image of NixOS, which can be obtained here: https://nixos.org/download/#nixos-iso.

Installation guide

Partitioning your disk

  1. Open a terminal.
  2. Wipe your disk: $ blkdiscard /dev/<installation disk>.
  3. Create root and boot partitions:
Use parted
$ parted <installation disk>
(parted) mklabel gpt
Boot partition
(parted) mkpart
(parted) Partitoin name? boot
(parted) File system type? fat32
(parted) Start? 0%
(parted) End? 2GB
(parted) set 1 esp on
(parted) set 1 boot on
Root partition
(parted) mkpart
(parted) Partitoin name? root
(parted) File system type? btrfs
(parted) Start? 2GB
(parted) End? 100%
(parted) quit

Configure and mount partitions

  1. $ mkfs.btrfs /dev/<root partition>
  2. $ mkfs.vfat -F32 /dev/<boot partition>
  3. $ mount /dev/<root partition> /mnt
  4. $ mkdir /mnt/boot
  5. $ mount /dev/<boot partition> /mnt/boot

Generate and edit config

  1. $ sudo nixos-generate-config --root /mnt
  2. Edit your configuration: $ nvim /mnt/etc/nixos/configuration.nix
  3. Checkout your hardware config: $ nvim /mnt/etc/nixos/hardware-configuration.nix
  4. Remember to add the following to configuration.nix so that grub works with EFI:
boot.loader.grub.enable = true;
boot.loader.grub.efiSupport = true;
boot.loader.grub.device = "nodev";
boot.loader.efi.canTouchEfiVariables = true;

Install

  1. $ sudo nixos-install
  2. Set root password when prompted to do so.
  3. Reboot your machine
  4. Login as root and set a password for your user: $ passwd <username>
  5. Logout and login as your user