{ config, ... }:

let
  installDisk =
    if config ? ultracloud
      && config.ultracloud ? install
      && config.ultracloud.install ? diskDevice
      && config.ultracloud.install.diskDevice != null then
      config.ultracloud.install.diskDevice
    else
      "/dev/vda";
in

{
  disko.devices = {
    disk.main = {
      type = "disk";
      device = installDisk;
      content = {
        type = "gpt";
        partitions = {
          BIOS = {
            size = "1M";
            type = "EF02";
          };
          ESP = {
            size = "512M";
            type = "EF00";
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
              mountOptions = [ "umask=0077" ];
            };
          };
          root = {
            size = "100%";
            content = {
              type = "filesystem";
              format = "ext4";
              mountpoint = "/";
            };
          };
        };
      };
    };
  };
}
