{ config, pkgs, ... }:

{
  environment.systemPackages = [ pkgs.cifs-utils ];

  fileSystems."/mnt/nas/Audio" = {
    device = "//192.168.10.90/audio/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Appz" = {
    device = "//192.168.10.90/appz/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Backup" = {
    device = "//192.168.10.90/backup/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Files" = {
    device = "//192.168.10.90/files/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Downloads" = {
    device = "//192.168.10.90/downloads/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Emulator" = {
    device = "//192.168.10.90/emulator/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Games" = {
    device = "//192.168.10.90/games/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/ISO" = {
    device = "//192.168.10.90/iso/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Multimedia" = {
    device = "//192.168.10.90/multimedia/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Public" = {
    device = "//192.168.10.90/public/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Share" = {
    device = "//192.168.10.90/share/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/Work" = {
    device = "//192.168.10.90/work/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/XXX" = {
    device = "//192.168.10.90/xxx/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

  fileSystems."/mnt/nas/homes" = {
    device = "//192.168.10.90/homes/";
    fsType = "cifs";
    options = let
      # this line prevents hanging on network split
      automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user,users";
    in ["${automount_opts},credentials=/etc/nixos/secrets/samba-secrets,uid=1000,gid=100"];
  };

}
