dotfiles/hosts/Common/nfs.nix

71 lines
2.1 KiB
Nix
Raw Normal View History

2024-09-22 16:27:43 +02:00
{pkgs, serverIP, ...}:
let
sharePath = "/home/server";
mountPath = "/home/server";
common_options = [
"noauto"
"_netdev"
2024-12-01 00:56:43 +01:00
"soft"
"bg"
"intr"
2024-09-22 16:27:43 +02:00
"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}";
2024-07-12 16:23:49 +02:00
fsType = "nfs";
2024-09-22 16:27:43 +02:00
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";
};
2024-07-12 16:23:49 +02:00
};
fileSystems."/home/user/Workspace" = {
device = "/home/server/Workspace";
2024-09-22 16:27:43 +02:00
options = bind_options;
2024-07-12 16:23:49 +02:00
};
fileSystems."/home/user/Documents" = {
device = "/home/server/Storage/Thomas/Documents";
2024-09-22 16:27:43 +02:00
options = bind_options;
2024-07-12 16:23:49 +02:00
};
fileSystems."/home/user/Pictures" = {
device = "/home/server/Storage/Thomas/Pictures";
2024-09-22 16:27:43 +02:00
options = bind_options;
2024-07-12 16:23:49 +02:00
};
fileSystems."/home/user/Videos" = {
device = "/home/server/Storage/Thomas/Videos";
2024-09-22 16:27:43 +02:00
options = bind_options;
2024-07-12 16:23:49 +02:00
};
2024-12-01 00:56:43 +01:00
systemd.extraConfig = ''
DefaultTimeoutStartSec=15s
DefaultTimeoutStopSec=15s
DefaultTimeoutAbortSec=15s
DefaultDeviceTimeoutSec=15s
'';
2024-07-12 16:23:49 +02:00
}