{ pkgs, ... }:
{
  # NFS client for /data/services
  # Mounts from data-services.service.consul (Consul DNS for automatic failover)
  # The NFS server registers itself in Consul, so this will automatically
  # point to whichever host is currently running the NFS server
  #
  # Uses persistent mount (not automount) with nofail to prevent blocking boot.
  # The mount is established at boot time and persists - no auto-unmount.
  # This prevents issues with Docker bind mounts seeing empty automount stubs.

  imports = [
    ./wait-for-dns-ready.nix
  ];

  fileSystems."/data/services" = {
    device = "data-services.service.consul:/persist/services";
    fsType = "nfs";
    options = [
      "nofail"                      # Don't block boot if mount fails
      "x-systemd.mount-timeout=30s" # Timeout for mount attempts
      "x-systemd.after=wait-for-dns-ready.service" # Wait for DNS to actually work
      "_netdev"                     # Network filesystem (wait for network)
    ];
  };

  # Ensure NFS client packages are available
  environment.systemPackages = [ pkgs.nfs-utils ];
}
