Directly modifying hardware-configuration.nix file
To achieve the same results as mentioned in other answers, you can as well add another fileSystems config entry in hardware-configuration.nix:
{
...
fileSystems."${mount_location}" = {
device = "/dev/${device}";
fsType = "${filesystem_extension}";
};
...
}
NOTES:
To get filesystem extension information about a particular partition run:
df -T | grep /dev/${device}
Example configuration for /dev/sda1 device, having ext4 file system extension, that is to be mounted at /mnt/sda1 location:
{
...
fileSystems."/mnt/sda1" = {
device = "/dev/sda1";
fsType = "ext4";
};
...
}
I think that such a solution is more unique, as the device name would not be overwritten by NixOS specific namespaces as in nixos-generate-config's solution.