nix/disko/default.nix

292 lines
9.1 KiB
Nix
Raw Normal View History

{
2024-07-17 20:22:16 -05:00
standardWithHibernateSwap = {
disks ? ["/dev/sda"],
swapSize,
...
}: {
# this is my standard partitioning scheme for my machines which probably want hibernation capabilities
# a UEFI-compatible boot partition
# it includes an LUKS-encrypted btrfs volume
# a swap partition big enough to dump all the machine's RAM into
disko.devices = {
disk = {
primary = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
ESP = {
label = "EFI";
name = "ESP";
2024-07-17 20:34:36 -05:00
size = "4G";
2024-07-17 20:22:16 -05:00
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
swap = {
size = swapSize;
content = {
type = "swap";
discardPolicy = "both";
resumeDevice = true; # resume from hiberation from this device
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
extraOpenArgs = ["--allow-discards"];
# if you want to use the key for interactive login be sure there is no trailing newline
# for example use `echo -n "password" > /tmp/secret.key`
keyFile = "/tmp/secret.key"; # Interactive
# settings.keyFile = "/tmp/password.key";
# additionalKeyFiles = ["/tmp/additionalSecret.key"];
content = {
type = "btrfs";
extraArgs = ["-f"];
subvolumes = {
"/nixos" = {
mountpoint = "/";
mountOptions = ["compress=zstd" "noatime"];
};
"/home" = {
mountpoint = "/home";
mountOptions = ["compress=zstd" "noatime"];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = ["compress=zstd" "noatime"];
};
};
2024-07-17 20:22:16 -05:00
};
};
};
};
};
};
};
};
};
2023-10-03 11:52:44 -05:00
standard = {disks ? ["/dev/vda"], ...}: {
2023-09-05 15:33:20 -05:00
# this is my standard partitioning scheme for my machines: an LUKS-encrypted
# btrfs volume
disko.devices = {
disk = {
2023-10-02 14:40:35 -05:00
primary = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
ESP = {
label = "EFI";
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
2023-10-03 11:52:44 -05:00
extraOpenArgs = ["--allow-discards"];
2023-10-02 14:40:35 -05:00
# if you want to use the key for interactive login be sure there is no trailing newline
# for example use `echo -n "password" > /tmp/secret.key`
keyFile = "/tmp/secret.key"; # Interactive
# settings.keyFile = "/tmp/password.key";
# additionalKeyFiles = ["/tmp/additionalSecret.key"];
content = {
type = "btrfs";
2023-10-03 11:52:44 -05:00
extraArgs = ["-f"];
2023-10-02 14:40:35 -05:00
subvolumes = {
"/root" = {
mountpoint = "/";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-10-02 14:40:35 -05:00
};
"/home" = {
mountpoint = "/home";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-10-02 14:40:35 -05:00
};
"/nix" = {
mountpoint = "/nix";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-10-02 14:40:35 -05:00
};
};
};
};
};
};
};
};
};
};
};
# TODO: figure out what I can't have an optiona/default 'name' attribute here so I can DRY with "standard"
2023-10-03 11:52:44 -05:00
thinker = {disks ? ["/dev/vda"], ...}: {
2023-10-02 14:40:35 -05:00
disko.devices = {
disk = {
2023-10-04 13:49:48 -05:00
vdb = {
2023-09-05 15:33:20 -05:00
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
ESP = {
label = "EFI";
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
2023-10-03 11:52:44 -05:00
extraOpenArgs = ["--allow-discards"];
2023-09-05 15:33:20 -05:00
# if you want to use the key for interactive login be sure there is no trailing newline
# for example use `echo -n "password" > /tmp/secret.key`
keyFile = "/tmp/secret.key"; # Interactive
# settings.keyFile = "/tmp/password.key";
# additionalKeyFiles = ["/tmp/additionalSecret.key"];
content = {
type = "btrfs";
2023-10-03 11:52:44 -05:00
extraArgs = ["-f"];
2023-09-05 15:33:20 -05:00
subvolumes = {
"/root" = {
mountpoint = "/";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-09-05 15:33:20 -05:00
};
"/home" = {
mountpoint = "/home";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-09-05 15:33:20 -05:00
};
"/nix" = {
mountpoint = "/nix";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-09-05 15:33:20 -05:00
};
};
};
};
};
};
};
};
};
};
};
2023-10-03 11:52:44 -05:00
unencrypted = {disks ? ["/dev/vda"], ...}: {
2023-09-05 15:33:20 -05:00
disko.devices = {
disk = {
primary = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "gpt";
partitions = {
ESP = {
label = "EFI";
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
root = {
size = "100%";
content = {
type = "btrfs";
2023-10-03 11:52:44 -05:00
extraArgs = ["-f"];
2023-09-05 15:33:20 -05:00
subvolumes = {
"/root" = {
mountpoint = "/";
2023-10-03 11:52:44 -05:00
mountOptions = [];
2023-09-05 15:33:20 -05:00
};
"/home" = {
mountpoint = "/home";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd"];
2023-09-05 15:33:20 -05:00
};
"/nix" = {
mountpoint = "/nix";
2023-10-03 11:52:44 -05:00
mountOptions = ["compress=zstd" "noatime"];
2023-09-05 15:33:20 -05:00
};
};
};
};
};
};
};
};
};
};
2023-10-06 10:42:19 -05:00
legacy = {disks ? ["/dev/vda"], ...}: {
disko.devices = {
disk = {
primary = {
device = builtins.elemAt disks 0;
type = "disk";
content = {
type = "table";
format = "gpt";
partitions = [
{
2024-01-06 11:43:30 -06:00
label = "EFI";
2023-10-06 10:42:19 -05:00
name = "ESP";
2024-01-06 11:43:30 -06:00
size = "512M";
2023-10-06 10:42:19 -05:00
bootable = true;
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
}
{
name = "root";
start = "500M";
end = "100%";
part-type = "primary";
bootable = true;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}
];
};
};
};
};
};
2023-09-05 15:33:20 -05:00
}