Improve disko snippets

This commit is contained in:
Lauren Lagarde 2025-06-10 21:35:21 -05:00
parent fa5a7fd0e0
commit 4befc47285
8 changed files with 132 additions and 72 deletions

View File

@ -0,0 +1,13 @@
{ ... }: {
disko.devices.disk.vda.content.partitions.luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
content = {
type = "lvm_pv";
vg = "pool";
};
};
};
}

View File

@ -0,0 +1,16 @@
{ ... }: {
disko.devices.lvm_vg.pool = {
type = "lvm_vg";
lvs.root = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [
"defaults"
];
};
};
};
}

9
disko/libvirt/lvm.nix Normal file
View File

@ -0,0 +1,9 @@
{ ... }: {
disko.devices.disk.vda.content.partitions.lvm = {
size = "100%";
content = {
type = "lvm_pv";
vg = "pool";
};
};
}

View File

@ -0,0 +1,21 @@
{ ... }: {
disko.devices.disk.vda = {
type = "disk";
device = "/dev/vda";
content = {
type = "gpt";
partitions = {
boot = {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
};
};
};
}

View File

@ -1,50 +0,0 @@
{ ... }: {
disko.devices = {
disk = {
vda = {
type = "disk";
device = "/dev/vda";
content = {
type = "gpt";
partitions = {
boot = {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
primary = {
size = "100%";
content = {
type = "lvm_pv";
vg = "pool";
};
};
};
};
};
};
lvm_vg = {
pool = {
type = "lvm_vg";
lvs = {
root = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [
"defaults"
];
};
};
};
};
};
};
}

View File

@ -7,7 +7,7 @@
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
boot = { ESP = {
size = "1G"; size = "1G";
type = "EF00"; type = "EF00";
content = { content = {
@ -17,35 +17,40 @@
mountOptions = [ "umask=0077" ]; mountOptions = [ "umask=0077" ];
}; };
}; };
luks = { zfs = {
size = "100%"; size = "100%";
content = { content = {
type = "luks"; type = "zfs";
name = "crypted"; pool = "rpool";
content = {
type = "lvm_pv";
vg = "pool";
};
}; };
}; };
}; };
}; };
}; };
}; };
lvm_vg = { zpool = {
pool = { rpool = {
type = "lvm_vg"; type = "zpool";
lvs = {
root = { options = {
size = "100%FREE"; ashift = "12";
content = { };
type = "filesystem";
format = "ext4"; rootFsOptions = {
mountpoint = "/"; mountpoint = "none";
mountOptions = [ compression = "zstd";
"defaults" acltype = "posixacl";
]; xattr = "sa";
}; canmount = "off";
};
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
postCreateHook = ''
zfs snapshot rpool/root@blank
'';
}; };
}; };
}; };

View File

@ -0,0 +1,13 @@
{ ... }: {
disko.devices.zpool.rpool = {
rootFsOptions = {
encryption = "aes-256-gcm";
keyformat = "passphrase";
keylocation = "prompt";
};
postCreateHook = ''
zfs set keylocation="prompt" rpool
'';
};
}

View File

@ -0,0 +1,33 @@
# https://github.com/KornelJahn/nixos-disko-zfs-test/blob/main/hosts/testhost-disko.nix
{ ... }: {
disko.devices = {
disk.vdb = {
type = "disk";
device = "/dev/vdb";
content = {
type = "gpt";
partitions = {
ESP = {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot1";
mountOptions = [ "umask=0077" ];
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
zpool.rpool.mode = "mirror";
};
}