refactor: abstract NFS mount creation via custom options
This commit is contained in:
parent
d4d655e735
commit
1403b1f9c0
9 changed files with 93 additions and 120 deletions
|
|
@ -2,6 +2,7 @@
|
|||
imports = [
|
||||
./docker.nix
|
||||
./monitoring.nix
|
||||
./nfs.nix
|
||||
];
|
||||
|
||||
config = {
|
||||
|
|
|
|||
46
modules/common/nfs.nix
Normal file
46
modules/common/nfs.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{ 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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue