add nfs and autofs system

This commit is contained in:
Yan Lin 2025-10-25 15:30:08 +02:00
parent 27408723d9
commit 73b137dc84
6 changed files with 92 additions and 341 deletions

44
modules/autofs.nix Normal file
View file

@ -0,0 +1,44 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.autofs-custom;
in
{
options.services.autofs-custom = {
enable = mkEnableOption "AutoFS automatic mounting";
remoteHost = mkOption {
type = types.str;
description = "Remote NFS server hostname or IP";
};
remotePath = mkOption {
type = types.str;
description = "Remote path to mount";
};
mountPoint = mkOption {
type = types.str;
description = "Local mount point";
};
};
config = mkIf cfg.enable {
services.autofs = {
enable = true;
timeout = 300;
autoMaster = ''
${cfg.mountPoint} -fstype=nfs4,rw,soft,intr,noatime ${cfg.remoteHost}:${cfg.remotePath}
'';
};
systemd.tmpfiles.rules = [
"d ${cfg.mountPoint} 0755 root root -"
];
environment.systemPackages = [ pkgs.nfs-utils ];
};
}