{
  flake,
  config,
  ...
}:
let
  inherit (flake.config.machines.devices) ceres;
  ceresSecrets = config.sops.secrets."network/server".path;

  sambaDrives = [
    "samba0"
  ];

  sambaFolders = [
    "storage"
  ];

  sambaMounts = sambaDrive: folder: {
    name = "${ceres.${sambaDrive}.mount}/${folder}";
    value = {
      device = "${ceres.${sambaDrive}.device}/${folder}";
      fsType = "cifs";
      options = ceres.${sambaDrive}.options ++ [
        "credentials=${ceresSecrets}"
      ];
    };
  };

in

{
  fileSystems = {
    "/" = {
      device = "/dev/disk/by-uuid/df2d42e7-e91c-4525-a8d9-80aa0897b1be";
      fsType = "ext4";
    };
    "/boot" = {
      device = "/dev/disk/by-uuid/B645-7527";
      fsType = "vfat";
    };
    "/mnt/raid0" = {
      device = "/dev/md127";
      fsType = "ext4";
      options = [
        "defaults"
        "nofail"
      ];
    };
  }
  // (builtins.listToAttrs (
    builtins.concatMap (drive: map (folder: sambaMounts drive folder) sambaFolders) sambaDrives
  ));

  swapDevices = [
    { device = "/dev/disk/by-uuid/9a2e032d-8627-49cf-8f3f-8fdf2be5fed4"; }
  ];

  boot.swraid.enable = true;
  boot.swraid.mdadmConf = ''
    ARRAY /dev/md0 level=raid0 num-devices=2 metadata=1.2
  '';

  services.udisks2.enable = true;
}
