{ lib, config, machine, ... }: let cfg = config.lab.storage; in { options.lab.storage = { osDisk = lib.mkOption { type = with lib.types; nullOr str; description = '' The disk to be used for the machine's operating system. ''; }; dataPartition = lib.mkOption { default = null; type = lib.types.nullOr 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. ''; }; }; config = { fileSystems = lib.attrsets.mergeAttrsList [ (lib.optionalAttrs machine.isHypervisor { "${cfg.dataMountPoint}".device = cfg.dataPartition; }) (lib.optionalAttrs machine.isRaspberryPi { "/" = { device = "/dev/disk/by-label/NIXOS_SD"; fsType = "ext4"; options = [ "noatime" ]; }; }) ]; disko = lib.mkIf machine.isHypervisor { # TODO: Rename this to 'osDisk'. Unfortunately, we would need to run nixos-anywhere again then. 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 = "/"; }; }; }; }; }; }; }; }