{ config, pkgs, lib, ... }:

# TODO: use tailscale if enabled

# don't mount if local VM
lib.mkIf (!config.virtualisation.isVmVariant)

{
  # TODO: wireguard
  #boot.kernelParams = [ "nfs.nfs4_disable_idmapping=0" "nfsd.nfs4_disable_idmapping=0" ];

  fileSystems = let
    mkMount = mountpoint: server: subdir: {
      "${mountpoint}${subdir}" = {
        device = "${server}${subdir}";
        fsType = "nfs";
        #options = [ "nfsvers=4.2" ];
      };
    };
    # TODO: combine nameValuePair and listToAttrs
    joinSets = sets: builtins.foldl' (l: r: l // r) {} sets;
  # TODO: space in dirname is not supported
  in joinSets (map (mkMount "/mnt/reidun" "192.168.1.3:/Reidun/shared") [
      ""
      #"/Comics"
      "/Downloads"
      "/Various"
      "/Various/Zotero"
      "/Various/resilio"
      "/Video"
      "/Video/Anime"
      "/Video/Concerts"
      "/Video/Documentaries"
      "/Video/Movies"
      "/Video/Musicvideos"
      "/Video/Series"
      "/Work"
      "/Work/Documents"
      "/Work/FL-Studio"
      "/Work/Programming"
      "/Work/School"
      "/pub"
    ]);

}
