Jump to content

NixOS

From David's Wiki
Revision as of 23:10, 21 December 2025 by David (talk | contribs)
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Install

The graphical installer is trivial. However, the minimal ISO doesn't handle partitioning for you.

Partitioning and Formatting

# Create a new GPT partition table
parted /dev/sda -- mklabel gpt

# Create the EFI Boot partition
parted /dev/sda -- mkpart ESP fat32 1MB 512MB
parted /dev/sda -- set 1 esp on

# Create the Root partition (ext4)
parted /dev/sda -- mkpart primary ext4 512MB 100%

# Format partitions
mkfs.fat -F 32 -n boot /dev/sda1
mkfs.ext4 -L nixos /dev/sda2

# Mount the root partition
mount /dev/disk/by-label/nixos /mnt

# Mount the boot partition
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot

# Create a 4GB swapfile (adjust size as needed)
dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile

Generate a config and install

nixos-generate-config --root /mnt
# Edit the config to your desire
nano /mnt/etc/nixos/configuration.nix

nixos-install

Resources