2024-01-28 10:48:13 +00:00
|
|
|
{ lib, config, machine, ... }:
|
2024-01-06 23:22:44 +00:00
|
|
|
let cfg = config.lab.storage;
|
|
|
|
in {
|
|
|
|
options.lab.storage = {
|
|
|
|
osDisk = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
The disk to be used for the machine's operating system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataPartition = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
Partition to be used for data storage on this machine.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataMountPoint = lib.mkOption {
|
|
|
|
default = "/mnt/data";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
Mount point of the machine's data partition.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-28 10:48:13 +00:00
|
|
|
config = lib.mkIf (machine.type == "physical") {
|
2024-01-06 23:22:44 +00:00
|
|
|
fileSystems.${cfg.dataMountPoint}.device = cfg.dataPartition;
|
|
|
|
|
|
|
|
# TODO: Rename this to 'osDisk'. Unfortunately, we would need to run nixos-anywhere again then.
|
|
|
|
disko.devices.disk.vdb = {
|
|
|
|
device = cfg.osDisk;
|
|
|
|
type = "disk";
|
|
|
|
|
|
|
|
content = {
|
|
|
|
type = "gpt";
|
|
|
|
|
|
|
|
partitions = {
|
|
|
|
swap.size = "100%";
|
|
|
|
|
|
|
|
ESP = {
|
|
|
|
type = "EF00";
|
|
|
|
size = "500M";
|
|
|
|
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/boot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
root = {
|
|
|
|
end = "-4G";
|
|
|
|
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "btrfs";
|
|
|
|
mountpoint = "/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|