Skip to content

Instantly share code, notes, and snippets.

@adamlwgriffiths
Last active October 2, 2020 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamlwgriffiths/53b7ac5d6173a925a6eb980a3ac86b4d to your computer and use it in GitHub Desktop.
Save adamlwgriffiths/53b7ac5d6173a925a6eb980a3ac86b4d to your computer and use it in GitHub Desktop.
NixOS installation commands

NixOS Installation Commands

Changes to standard installation

  • moved /home on a different hard-drive
  • used percentages with parted's mkpart to avoid non-aligned performance warnings.

Note: these commands are relevant to my particular machine. Specific values that may differ for you:

  • HDD names (/dev/sda*, /dev/nvme0np1)
  • partition sizes
  • initial user's name

The HDDs in question are:

  • /dev/nvme0n = 512GB SSD = OS installation
  • /dev/sda = 4TB HDD = User homes

# parted, avoiding alignment issues
$ parted /dev/nvme0n
> mklabel gpt
> mkpart primary 1GiB -4%
> mkpart primary linux-swap -4% 100%
> mkpart ESP fat32 1MiB 1GiB
> set 3 boot on

$ parted /dev/sda
> mklabel gpt
> mkpart primary 0% 100%

$ mkfs.ext4 -L nixos /dev/nvme0np1
$ mkswap -L swap /dev/nvme0np2
$ mkfs.fat -F 32 -n boot /dev/nvme0np3

# separate home
$ mkfs.ext4 -L home /dev/sda1

$ mount /dev/disk/by-label/nixos /mnt

$ mkdir -p /mnt/boot
$ mount /dev/disk/by-label/boot /mnt/boot

$ mkdir -p /mnt/home
$ mount /dev/disk/by-label/home /mnt/home

$ swapon /dev/nvme0np2

$ nixos-generate-config --root /mnt
$ vim /mnt/etc/nixos/configuration.nix

$ nixos-install

$ reboot
$ sudo su -
$ passwd adam

# home-manager channel
$ nix-channel --add https://github.com/rycee/home-manager/archive/release-20.03.tar.gz home-manager
$ nix-channel --update

$ nixos-rebuild switch

$ home-manager switch

Alt+F2 > restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment