Im trying to automate the process of installing NixOS and for the that Im currently looking into setting up my disk-partitions with disko
. My configuration looks something like this:
# disk-config.nix
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/vda";
content = {
type = "gpt";
partitions = {
ESP = {
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
extraOpenArgs = [ ];
settings = {
keyFile = "/tmp/secret.key";
allowDiscards = true;
};
content = {
type = "lvm_pv";
vg = "pool";
};
};
};
};
};
};
};
lvm_vg = {
pool = {
type = "lvm_vg";
lvs = {
encryptedSwap = {
size = "32G";
content = {
type = "swap";
randomEncryption = true;
priority = 100;
};
};
root = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [
"defaults"
];
};
};
};
};
};
};
}
Running this with
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko ./disk-config.nix
creates the partitioning exactly as I would expect it.
What I currently struggling with is how to do some of the post processing, i.e. after running the disko
command I need to run swapon /dev/pool/encryptedSwap
. I also need to know the uuid of the partitions so that I can setup something like this
boot.initrd.luks.devices.luksroot = {
device = "/dev/disk/by-uuid/<UUID>";
preLVM = true;
allowDiscards = true;
};
Any ideas on how to do this? Does nix offer some help with this?