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
(Created page with "Category:Technical guides = introduction = this uses flakes # obtain nixos ISO (graphical installer is nicer i guess) # boot it # open up a terminal and partition disk # wipe your disk: blkdiscard /dev/nvme0n1 = partition your disk = # create boot partition # create root partition # parted <device> # mklabel gpt # mkpart partitoin name? boot file system type? fat32 start? 0% end? 2GB # mkpart partitoin name? root file system type? btrfs start? 2GB end? 100% # set 1...")
 
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Technical guides]]
[[Category:Technical guides]]


= introduction =
= Introduction =
this uses flakes
This is an incomplete guide on installing NixOs, using flakes and home-manager.


# obtain nixos ISO (graphical installer is nicer i guess)
Be sure to have an ISO image of NixOS, which can be obtained here: https://nixos.org/download/#nixos-iso.
# boot it
# open up a terminal and partition disk
# wipe your disk: blkdiscard /dev/nvme0n1
= partition your disk =
# create boot partition
# create root partition
# parted <device>
# mklabel gpt
# mkpart
partitoin name? boot
file system type? fat32
start? 0%
end? 2GB
# mkpart
partitoin name? root
file system type? btrfs
start? 2GB
end? 100%
# set 1 esp on
# set 1 boot on
# quit
# mkfs.btrfs  /dev/<root partition>
# mkfs.vfat -F32 /dev/<boot partition>


= mount your disk =
= Installation guide =
# mount /dev/<root partition> /mnt
== Partitioning your disk ==
# mkdir /mnt/boot
# Boot the installation medium.
# mount /dev/<boot partition> /mnt/boot
# Open a terminal.
# Wipe your disk: {{ic|$ blkdiscard /dev/<installation disk>}}.
# Create root and boot partitions:
===== Use parted =====
<pre>
$ parted <installation disk>
(parted) mklabel gpt
</pre>
===== Boot partition =====
<pre>
(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
</pre>
===== Root partition =====
<pre>
(parted) mkpart
(parted) Partitoin name? root
(parted) File system type? btrfs
(parted) Start? 2GB
(parted) End? 100%
(parted) quit
</pre>


= generate config =
== Configure and mount partitions ==
sudo nixos-generate-config --root /mnt
# {{ic|$ mkfs.btrfs  /dev/<root partition>}}
nvim /mnt/etc/nixos/configuration.nix
# {{ic|$ mkfs.vfat -F32 /dev/<boot partition>}}
nvim /mnt/etc/nixos/hardware-configuration.nix
# {{ic|$ mount /dev/<root partition> /mnt}}
# {{ic|$ mkdir /mnt/boot}}
# {{ic|$ mount /dev/<boot partition> /mnt/boot}}


= install =
== Generate and edit config  ==
sudo nixos-install
# {{ic|$ sudo nixos-generate-config --root /mnt}}
# Edit your configuration: {{ic|$ nvim /mnt/etc/nixos/configuration.nix}}
# Checkout your hardware config: {{ic|$ nvim /mnt/etc/nixos/hardware-configuration.nix}}
# Remember to add the following to {{ic|configuration.nix}} so that grub works with EFI:
<pre>
boot.loader.grub.enable = true;
boot.loader.grub.efiSupport = true;
boot.loader.grub.device = "nodev";
boot.loader.efi.canTouchEfiVariables = true;
</pre>
{{note|This is an example of my configuration: https://git.posixlycorrect.com/fabian/desktop_config}}
 
== Install ==
# {{ic|$ sudo nixos-install}}
# Set root password when prompted to do so.
# Reboot your machine
# Login as root and set a password for your user: {{ic|$ passwd <username>}}
# Logout and login as your user
 
 
= Enable flakes and replace your config with your flake =
==== Flake ====
# {{ic|$ mkdir nix}}
# Create your {{ic|$ vim flake.nix}}
# {{ic|$ nixos rebuidl switch}}
 
==== Home manager ====
# {{ic|$ nix repl .}}
<pre>
home = homeConfigurations.<configuration name>
home.activationPackage
</pre>
# Copy the resulting path and do:
# {{ic|$ build <path>}}
# ./result/activate

Latest revision as of 20:14, 2 September 2024


Introduction

This is an incomplete guide on installing NixOs, using flakes and home-manager.

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. Boot the installation medium.
  2. Open a terminal.
  3. Wipe your disk: $ blkdiscard /dev/<installation disk>.
  4. 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;
Note: This is an example of my configuration: https://git.posixlycorrect.com/fabian/desktop_config

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


Enable flakes and replace your config with your flake

Flake

  1. $ mkdir nix
  2. Create your $ vim flake.nix
  3. $ nixos rebuidl switch

Home manager

  1. $ nix repl .
home = homeConfigurations.<configuration name>
home.activationPackage
  1. Copy the resulting path and do:
  2. $ build <path>
  3. ./result/activate