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
|
|
@ -61,29 +61,26 @@ in {
|
|||
virtualisation.containers.enable = lib.mkIf inUse true;
|
||||
};
|
||||
|
||||
fileSystems = let
|
||||
mkFileSystem = device: {
|
||||
inherit device;
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"hard"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
homelab.nfsMounts = let
|
||||
hugoBackup = "192.168.0.11:/mnt/BIG/BACKUP";
|
||||
arrOptions = [
|
||||
"auto"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"hard"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev"
|
||||
];
|
||||
mkMount = device: {
|
||||
inherit device;
|
||||
extraOptions = arrOptions;
|
||||
};
|
||||
in lib.mkIf inUse {
|
||||
"/srv/bazarr-backup" = lib.mkIf cfg.bazarr.enable (mkFileSystem "${hugoBackup}/BAZARR");
|
||||
"/srv/prowlarr-backup" = lib.mkIf cfg.bazarr.enable (mkFileSystem "${hugoBackup}/PROWLARR");
|
||||
"/srv/qbittorrent" = lib.mkIf cfg.qbittorrent.enable (mkFileSystem "192.168.0.11:/mnt/SMALL/CONFIG/QBITTORRENT");
|
||||
"/srv/radarr-backup" = lib.mkIf cfg.radarr.enable (mkFileSystem "${hugoBackup}/RADARR");
|
||||
"/srv/sonarr-backup" = lib.mkIf cfg.sonarr.enable (mkFileSystem "${hugoBackup}/SONARR");
|
||||
"/srv/torrent" = mkFileSystem "192.168.0.11:/mnt/SMALL/MEDIA/TORRENT";
|
||||
"/srv/bazarr-backup" = lib.mkIf cfg.bazarr.enable (mkMount "${hugoBackup}/BAZARR");
|
||||
"/srv/prowlarr-backup" = lib.mkIf cfg.bazarr.enable (mkMount "${hugoBackup}/PROWLARR");
|
||||
"/srv/qbittorrent" = lib.mkIf cfg.qbittorrent.enable (mkMount "192.168.0.11:/mnt/SMALL/CONFIG/QBITTORRENT");
|
||||
"/srv/radarr-backup" = lib.mkIf cfg.radarr.enable (mkMount "${hugoBackup}/RADARR");
|
||||
"/srv/sonarr-backup" = lib.mkIf cfg.sonarr.enable (mkMount "${hugoBackup}/SONARR");
|
||||
"/srv/torrent" = mkMount "192.168.0.11:/mnt/SMALL/MEDIA/TORRENT";
|
||||
};
|
||||
|
||||
# Make sure the Docker network exists.
|
||||
|
|
|
|||
|
|
@ -42,17 +42,13 @@ in {
|
|||
shell = null;
|
||||
};
|
||||
|
||||
fileSystems."${books}" = {
|
||||
homelab.nfsMounts."${books}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/MEDIA/BOOKS";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
extraOptions = [
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
"_netdev"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -66,17 +62,13 @@ in {
|
|||
|
||||
# Calibre desktop
|
||||
(lib.mkIf cfg.desktop.enable {
|
||||
fileSystems."${calibre-config}" = {
|
||||
homelab.nfsMounts."${calibre-config}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/CALIBRE";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
extraOptions = [
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
"_netdev"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -124,17 +116,13 @@ in {
|
|||
|
||||
# Calibre Web
|
||||
(lib.mkIf cfg.web.enable {
|
||||
fileSystems."${calibre-web-config}" = {
|
||||
homelab.nfsMounts."${calibre-web-config}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/CALIBRE-WEB";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
extraOptions = [
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
"_netdev"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,18 +20,13 @@ in {
|
|||
lib.mkIf cfg.enable {
|
||||
homelab.virtualisation.containers.enable = true;
|
||||
|
||||
fileSystems."/srv/freshrss" = {
|
||||
homelab.nfsMounts."/srv/freshrss" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/FRESHRSS";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
extraOptions = [
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft" "timeo=600"
|
||||
"timeo=600"
|
||||
"retrans=2"
|
||||
"_netdev"
|
||||
"nosuid"
|
||||
"tcp"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,32 +40,13 @@ in {
|
|||
|
||||
# Use filesystem mounts because rootless containers otherwise don't have access to the mount path (nested in docker directories).
|
||||
# You could probably fix this by modifying the access rights on the path, but what would the point of that be?
|
||||
fileSystems = {
|
||||
# Mount options:
|
||||
# - hard: retry requests indefinitely if the server becomes unresponsive.
|
||||
# - nosuid: prevent set-user-id and set-group-id bits
|
||||
homelab.nfsMounts = {
|
||||
"/srv/gitea-config" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/GITEA";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft" "timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid"
|
||||
"tcp"
|
||||
];
|
||||
};
|
||||
|
||||
"/srv/gitea-git" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/DATA/GIT";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft" "timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid"
|
||||
"tcp"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,15 +34,10 @@ in {
|
|||
shell = null;
|
||||
};
|
||||
|
||||
fileSystems."${homepage-config}" = {
|
||||
homelab.nfsMounts."${homepage-config}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/HOMEPAGE";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
extraOptions = [
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft" "timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,42 +25,15 @@ in {
|
|||
virtualisation.containers.enable = true;
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
"/srv/audio" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/MEDIA/AUDIO";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"ro"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft"
|
||||
"timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
"/srv/homevideo" = {
|
||||
device = "192.168.0.11:/mnt/BIG/MEDIA/HOMEVIDEO/ARCHIVE";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"ro"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft"
|
||||
"timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
"/srv/photo" = {
|
||||
device = "192.168.0.11:/mnt/BIG/MEDIA/PHOTO/ARCHIVE";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"ro"
|
||||
"nfsvers=4.2"
|
||||
"async" "soft"
|
||||
"timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
||||
"nosuid" "tcp"
|
||||
];
|
||||
homelab.nfsMounts = let
|
||||
mkMount = device: {
|
||||
inherit device;
|
||||
readOnly = true;
|
||||
};
|
||||
in {
|
||||
"/srv/audio" = mkMount "192.168.0.11:/mnt/SMALL/MEDIA/AUDIO";
|
||||
"/srv/homevideo" = mkMount "192.168.0.11:/mnt/BIG/MEDIA/HOMEVIDEO/ARCHIVE";
|
||||
"/srv/photo" = mkMount "192.168.0.11:/mnt/BIG/MEDIA/PHOTO/ARCHIVE";
|
||||
};
|
||||
|
||||
users.users.jellyfin = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue