diff --git a/modules/autofs.nix b/modules/autofs.nix index ce45f8c..12b5ec3 100644 --- a/modules/autofs.nix +++ b/modules/autofs.nix @@ -32,26 +32,32 @@ in }; }; - config = mkIf cfg.enable { - services.autofs = { - enable = true; - timeout = 300; - autoMaster = - let - # Build server list: primary host followed by replicas - allHosts = [ cfg.remoteHost ] ++ cfg.replicas; - # Format as "host1:/path host2:/path host3:/path" - locations = concatStringsSep " " (map (host: "${host}:${cfg.remotePath}") allHosts); - in - '' - ${cfg.mountPoint} -fstype=nfs4,rw,soft,intr,noatime ${locations} + config = mkIf cfg.enable ( + let + # Build server list: primary host followed by replicas + allHosts = [ cfg.remoteHost ] ++ cfg.replicas; + # Format as "host1,host2,host3:/path" for NFS replicas + locations = "${concatStringsSep "," allHosts}:${cfg.remotePath}"; + in + { + services.autofs = { + enable = true; + timeout = 300; + autoMaster = '' + /- /etc/auto.nfs --timeout=300 ''; - }; + }; - systemd.tmpfiles.rules = [ - "d ${cfg.mountPoint} 0755 root root -" - ]; + # Create the auto.nfs map file + environment.etc."auto.nfs".text = '' + ${cfg.mountPoint} -fstype=nfs4,rw,soft,intr,noatime ${locations} + ''; - environment.systemPackages = [ pkgs.nfs-utils ]; - }; + systemd.tmpfiles.rules = [ + "d ${cfg.mountPoint} 0755 root root -" + ]; + + environment.systemPackages = [ pkgs.nfs-utils ]; + } + ); } diff --git a/modules/nfs.nix b/modules/nfs.nix index 1669848..7793dce 100644 --- a/modules/nfs.nix +++ b/modules/nfs.nix @@ -26,7 +26,7 @@ in services.nfs.server = { enable = true; exports = '' - ${cfg.exportPath} ${concatStringsSep " " (map (net: "${net}(rw,sync,no_subtree_check,no_root_squash)") cfg.allowedNetworks)} + ${cfg.exportPath} ${concatStringsSep " " (map (net: "${net}(rw,sync,no_subtree_check,no_root_squash,fsid=0)") cfg.allowedNetworks)} ''; }; };