# NFS mount of nixdesk (14900k) bulk storage for clients. Exports live in
#   modules/hosts/14900k/_private/jellyfin-nfs-export.nix
#
# Jellyfin library paths (see also jellyfin.nix):
#   Movies → /mnt/nixdesk-jellyfin/movies
#   Shows  → /mnt/nixdesk-jellyfin/tv
#
# If you see "Stale file handle" under /mnt after changing exports or fsid on nixdesk, drop the
# old client mount and let automount reattach, e.g.:
#   sudo umount -l /mnt/nixdesk-jellyfin
#   ls /mnt/nixdesk-jellyfin
{ ... }:
{
  flake.nixosModules.nixdeskJellyfin =
    { lib, ... }:
    let
      nfsExportHost = "192.168.2.25";
      # nfsvers+tcp: predictable Linux↔Linux; lookupcache=none: fewer stale dentries after export changes.
      nfsClientOpts = [
        "rw"
        "noatime"
        "nofail"
        "_netdev"
        "nfsvers=3"
        "tcp"
        "lookupcache=none"
        "x-systemd.automount"
        "x-systemd.idle-timeout=3600"
      ];
    in
    {
      fileSystems."/mnt/nixdesk-jellyfin" = {
        device = "${nfsExportHost}:/mnt/deep/jellyfin";
        fsType = "nfs";
        options = nfsClientOpts;
      };
    };
}
