71 lines
2.1 KiB
Nix
71 lines
2.1 KiB
Nix
{pkgs, serverIP, ...}:
|
|
|
|
let
|
|
sharePath = "/home/server";
|
|
mountPath = "/home/server";
|
|
common_options = [
|
|
"noauto"
|
|
"_netdev"
|
|
"soft"
|
|
"bg"
|
|
"intr"
|
|
"x-systemd.automount"
|
|
"x-systemd.idle-timeout=600"
|
|
"x-systemd.device-timeout=2s"
|
|
"x-systemd.mount-timeout=2s"
|
|
"timeo=5"
|
|
"x-gvfs-hide"
|
|
"x-systemd.after=network-online.target"
|
|
"x-systemd.requires=network-online.target"
|
|
];
|
|
bind_options = [
|
|
"bind"
|
|
"x-systemd.after=${builtins.replaceStrings ["/"] ["-"] mountPath}.mount"
|
|
] ++ common_options;
|
|
in {
|
|
services.rpcbind.enable = true;
|
|
boot.supportedFilesystems = [ "nfs" ];
|
|
fileSystems.${mountPath} = {
|
|
device = "${serverIP}:${sharePath}";
|
|
fsType = "nfs";
|
|
options = [
|
|
"x-systemd.after=wg-quick-Tunnel.service"
|
|
"x-systemd.after=wg-quick-OPNsense.service"
|
|
] ++ common_options;
|
|
};
|
|
|
|
systemd.services."${builtins.replaceStrings ["/"] ["-"] mountPath}-unmount" = {
|
|
description = "Unmount NFS share before shutdown";
|
|
wantedBy = [ "shutdown.target" ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = "/bin/true";
|
|
ExecStop = "${pkgs.util-linux}/bin/umount -f -l ${mountPath}";
|
|
TimeoutStopSec = "10s";
|
|
};
|
|
};
|
|
fileSystems."/home/user/Workspace" = {
|
|
device = "/home/server/Workspace";
|
|
options = bind_options;
|
|
};
|
|
fileSystems."/home/user/Documents" = {
|
|
device = "/home/server/Storage/Thomas/Documents";
|
|
options = bind_options;
|
|
};
|
|
fileSystems."/home/user/Pictures" = {
|
|
device = "/home/server/Storage/Thomas/Pictures";
|
|
options = bind_options;
|
|
};
|
|
fileSystems."/home/user/Videos" = {
|
|
device = "/home/server/Storage/Thomas/Videos";
|
|
options = bind_options;
|
|
};
|
|
systemd.extraConfig = ''
|
|
DefaultTimeoutStartSec=15s
|
|
DefaultTimeoutStopSec=15s
|
|
DefaultTimeoutAbortSec=15s
|
|
DefaultDeviceTimeoutSec=15s
|
|
'';
|
|
}
|