53 lines
1.2 KiB
Nix
53 lines
1.2 KiB
Nix
{ config, lib, ... }:
|
|
|
|
# https://wiki.nixos.org/wiki/NFS
|
|
|
|
# TODO: use tailscale if enabled
|
|
# TODO: wireguard/tailscale
|
|
# TODO: nfsv4 and idmapping
|
|
#boot.kernelParams = [ "nfs.nfs4_disable_idmapping=0" "nfsd.nfs4_disable_idmapping=0" ];
|
|
|
|
let
|
|
cfg = config.pbsds.nfs-lazy-mount;
|
|
in
|
|
{
|
|
options.pbsds = {
|
|
|
|
nfs-lazy-mount.enable = lib.mkEnableOption "nfs-lazy-mount";
|
|
|
|
nfs-lazy-mount.nfsOptions = lib.mkOption {
|
|
type = with lib.types; listOf str;
|
|
default = [];
|
|
internal = true;
|
|
};
|
|
|
|
};
|
|
|
|
# same default as `fileSystems.<name>.options`
|
|
# https://search.nixos.org/options?channel=unstable&query=fileSystems.%3Cname%3E.options
|
|
# https://man.archlinux.org/man/core/util-linux/mount.8.en
|
|
config.pbsds.nfs-lazy-mount.nfsOptions = lib.mkMerge [
|
|
|
|
[
|
|
# nixos default
|
|
"defaults"
|
|
# retry attempts before major timeout occurs. default is 3
|
|
"retrans=2"
|
|
"timeo=5" # wait time during boot in seconds?
|
|
# time before systemd gives up
|
|
"x-systemd.mount-timeout=5s"
|
|
]
|
|
|
|
# https://wiki.nixos.org/wiki/NFS#Lazy-mounting
|
|
(lib.mkIf cfg.enable [
|
|
# lazy mount
|
|
"x-systemd.automount"
|
|
"noauto"
|
|
# disconnect after 10 minutes
|
|
"x-systemd.idle-timeout=600"
|
|
])
|
|
|
|
];
|
|
|
|
}
|