add nfs and autofs system
This commit is contained in:
parent
27408723d9
commit
73b137dc84
6 changed files with 92 additions and 341 deletions
44
modules/autofs.nix
Normal file
44
modules/autofs.nix
Normal 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 ];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue