{ moduleFunctions }:
let
  inherit (moduleFunctions.devicesFunctions)
    sshfsOptions
    fileModeAndDirMode
    ceresStorageDriveName
    ownerExclusiveReadWriteMask
    readWritePermissions
    sambaPermissions
    userIdForUser0
    ceresIP
    deviceNames
    ;
  inherit (moduleFunctions.usersFunctions) user0;
  inherit (moduleFunctions.devicesFunctions) externalIP;

  ceresName = deviceNames.server;
in
{
  label = deviceNames.serverLabel;
  name = ceresName;
  sync = {
    address0 = "";
  };
  ip = {
    address0 = ceresIP;
  };
  boot = {
    options = ownerExclusiveReadWriteMask;
  };
  wireguard = {
    ip0 = "10.100.0.1";
  };
  storage0 = {
    mount = "/mnt/media/${ceresStorageDriveName}";
    device = "/dev/disk/by-label/${ceresStorageDriveName}";
    options = readWritePermissions;
  };
  samba0 = {
    mount = "/mnt/media/${ceresName}";
    device = "//${ceresIP}";
    options = sambaPermissions ++ fileModeAndDirMode ++ userIdForUser0;
  };
  remote0 = {
    mount = "/mnt/media/remote";
    device = "${user0}@${externalIP}:/mnt/media/${ceresStorageDriveName}";
    options = sshfsOptions;
  };
}
