nix-config/disk-config.nix

93 lines
4.2 KiB
Nix
Raw Normal View History

2024-06-10 14:49:48 +00:00
# NOTE: ... is needed because dikso passes diskoFile
{
lib,
disk ? [ "/dev/vda" ],
withSwap ? true,
swapSize ? "16",
...
}:
{
disko.devices = {
disk = {
2024-06-10 15:03:35 +00:00
main = {
2024-06-10 14:49:48 +00:00
type = "disk";
device = "/dev/disk/by-id/nvme-eui.002538d211111953";
content = {
type = "gpt";
partitions = {
ESP = {
# name = "ESP";
priority = 1;
start = "1M";
end = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "defaults" ];
};
};
luks = {
# name = "root";
size = "100%";
content = {
type = "luks";
name = "crypted";
# disable settings.keyFile if you want to use interactive password entry
# passwordFile = "/tmp/secret.key"; # Interactive
settings = {
allowDiscards = true;
# keyFile = "/tmp/secret.key";
};
# additionalKeyFiles = [ "/tmp/hdd.key" ];
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
"@root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-lib" = {
mountpoint = "/var/lib";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-log" = {
mountpoint = "/var/log";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-tmp" = {
mountpoint = "/var/tmp";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@swap" = lib.mkIf withSwap {
mountpoint = "/.swapvol";
swap.swapfile.size = "${swapSize}G";
};
};
};
};
};
};
};
};
};
};
}