Chris Stryczynski

Software Developer / Consultant

How to install a new Nixos from previous configuration

This is a bit of a rough guide - you may need to change some details. Hopefully it’s still helpful! There is another helpful guide here: https://beyermatthias.de/blog/2017/02/23/how-to-install-nixos-from-nixos/

1. Boot the ISO.

You’ll need the minimal Nixos ISO https://nixos.org/nixos/download.html. You may need to setup your WIFI if using wireless.

2. Setup one or more disk partitions if required

You’ll need an EFI boot partition if using GPT.

I’m installing it on a fresh empty disk (warning it’ll format the disk! - Delete any data on there).

nix-env -i git zip wget

gdisk /dev/sda
gdisk> n
gdisk> enter (partition number 1)
gdisk> enter (first sector)
gdisk> enter (last sector)
gdisk> enter (hex code)
gdisk> w 
gdisk> y enter (accept) 

mkfs.ext4 /dev/sda1

3. Mount and create the config directories / files

mount /dev/sda1 /mnt
mkdir -p /mnt/etc/nixos
???

copy your config here to /etc/nixos/...

4. Update the hard disk UUID

blkid -s UUID -o value /dev/sda will output the UUID. Modify the uuid value in hardware-configuration.nix

5. Nixos install

nixos-install