46 lines
1.2 KiB
Nix
46 lines
1.2 KiB
Nix
{ config, lib, ... }:
|
|
|
|
{
|
|
options.homelab.nfsMounts = lib.mkOption {
|
|
type = lib.types.attrsOf (lib.types.submodule {
|
|
options = {
|
|
device = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "The NFS device, e.g. 192.168.0.11:/mnt/POOL/DATA";
|
|
};
|
|
readOnly = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Whether to mount the NFS share read-only";
|
|
};
|
|
extraOptions = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [
|
|
"async"
|
|
"soft"
|
|
"timeo=100"
|
|
"retry=50"
|
|
"actimeo=1800"
|
|
"lookupcache=all"
|
|
];
|
|
description = "Extra NFS mount options to append";
|
|
};
|
|
};
|
|
});
|
|
default = {};
|
|
description = "NFS mounts to automatically configure with standard homelab options";
|
|
};
|
|
|
|
config = {
|
|
fileSystems = lib.mapAttrs (path: cfg: {
|
|
device = cfg.device;
|
|
fsType = "nfs";
|
|
options = [
|
|
"nfsvers=4.2"
|
|
"nosuid"
|
|
"tcp"
|
|
] ++ (if cfg.readOnly then [ "ro" ] else [ "rw" ])
|
|
++ cfg.extraOptions;
|
|
}) config.homelab.nfsMounts;
|
|
};
|
|
}
|