My configuration has extra helper scripts for partitioning and mounting the system.
These scripts live in [hosts/HOSTNAME/disks.nix] (which must customized to fit your specific configuration).
Make sure you check the capitalized variables located within the let
block in your device’s hosts/HOSTNAME/hardware/hardware-configuration.nix
and hosts/HOSTNAME/hardware/disks.nix
files! These values are crucial to the scripts you’ll run in the next steps as well as for how NixOS configures itself to read your partitions.
NOTES:
- When editing any of the path variables, always include
/
in the beginning and where else is necessary! - In order to get the get the correct value for the
DISK
variable located indisks.nix
for your drive, check the/dev/disk/by-id
and locate the name of your drive (without anything at the end like-part1
)- The path should look something like
/dev/by/disk/by-id/InterfaceType-OEMINFO
withInterfaceType
being how its connected to your machine (like usb or nvme) andOEMINFO
being the extremely long string that has the OEM of the device aswell as serial number (in some cases).
- The path should look something like
- Make sure the
SWAP_PATH
andSWAP_SIZE
variables inhardware-configuration.nix
anddisks.nix
match each other! TheSWAP_SIZE
variable indisks.nix
is string while the one inhardware-configuration.nix
is an integer. - For the
SWAP_FILE
variable in thedisks.nix
file, the path is relative to/mnt
on the iso (since that’s where it will be mounted to when running thedisks-mount
command).
Execute nix run .#nixosConfigurations.$HOSTNAME.config.disks-create
to create the disks. Please be warned that this command will destroy everything on the disk so make sure you correctly defined the device in the configs and backed up everything!!! If necessary, unplug important devices you don’t want to get wiped!
Execute nix run .#nixosConfigurations.$HOSTNAME.config.disks-format
to format the filesystems on the newly created partitions
Execute nix run .#nixosConfigurations.$HOSTNAME.config.disks-mount
to mount all of the newly created partitions to the live installer
Execute nix run .#nixosConfigurations.$HOSTNAME.config.disks-retrieve
to obtain the necessary values for the variables MAIN_PART
and BOOT_PART
, needed for the hardware-configuration.nix
file. The output is preformatted with the variable names and their respect partition IDs, so one just simply needs to copy over the output into the file. The output should follow the following format in the console:
MAIN_PART = "/dev/disk/by-uuid/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
BOOT_PART = "/dev/disk/by-uuid/XXXX-XXXX";
If the output isn’t correct, then instead run nixos-generate-config --show-hardware-config --root /mnt
, it will output a base configuration file that the installer provides; containing the partition ids and see what are the ids for the newly created partitions (as well as other additional settings that are needed for your system).
Only do these if you’re using a setup that includes what my setup uses (like swapfiles)
Execute nix run .#nixosConfigurations.$HOSTNAME.config.create-swapfile
to create the swapfile aswell as calculate what the resume-offset
value should be for the current system. This is required since I’m using swapfiles and want to enable hibernation. Since there is no swap partition, the system needs to know where the swap header is on the system’s disk (aka, it needs to know on which disk block sector the swapfile is located). Once it’s ran, the resume offset value is echoed into the console; then you must take this value and put it in the hosts/HOSTNAME/hardware/hardware-configuration.nix
file under the RESUME_OFFSET
variable.
- Once you finish all of these steps, move on to the next steps of Installation!