Chris Stryczynski

Software Developer / Consultant

How to install Nixos using just a nixos configuration

Posted on: 06/05/2018

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/

All you need to install Nixos, is the few nix files. In my particular case I have https://github.com/chrissound/nixconfig where I manage multiple’s machines config’s in one project (which also makes it easy to share configs between machines).

By default (if you generated your configs with nixos-generate-config) these would be in:

/etc/nixos/configuration.nix
/etc/nixos/hardware-configuration.nix

So some practical steps to carry this out:

1. Boot Nixos

You’ll need the minimal Nixos ISO https://nixos.org/nixos/download.html. You may need to setup your WIFI connection, if using wireless - I had to use the terminal wpa_supplicant utility.

Install any necessary dependencies you need:

nix-env -i git zip wget

2. Setup disk partitions

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

And at the end make the partitions:

mkfs.fat -F 32 /dev/sda1
mkfs.ext4 /dev/sda2

3. Mount and create the config directories / files

mount /dev/sda2 /mnt

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

4. Update the hardware config / the hard disk UUID

You can run nixos-generate-config --root /mnt to update hardware-configuration.nix (it won’t overwrite configuration.nix)

If you want to change the UUID of an existing disk:

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

5. Nixos install

nixos-install
Comments

No comments, yet!

Submit a comment