fix: Separate nfs config
This commit is contained in:
parent
c541fa4e6e
commit
48fb68c2fd
5 changed files with 100 additions and 64 deletions
|
|
@ -38,6 +38,11 @@ in {
|
||||||
sonarr.enable = true;
|
sonarr.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fileSystems.media.video = {
|
||||||
|
enable = true;
|
||||||
|
permissions = [ "read" "write" ];
|
||||||
|
};
|
||||||
|
|
||||||
virtualisation.containers.enable = lib.mkIf inUse true;
|
virtualisation.containers.enable = lib.mkIf inUse true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -139,20 +144,6 @@ in {
|
||||||
"_netdev" "nosuid" "tcp"
|
"_netdev" "nosuid" "tcp"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
"/srv/video" = {
|
|
||||||
device = "192.168.0.11:/mnt/SMALL/MEDIA/VIDEO";
|
|
||||||
fsType = "nfs";
|
|
||||||
options = [
|
|
||||||
"rw"
|
|
||||||
"auto"
|
|
||||||
"nfsvers=4.2"
|
|
||||||
"soft"
|
|
||||||
"rsize=1048576" "wsize=1048576"
|
|
||||||
"timeo=600" "retrans=2"
|
|
||||||
"_netdev" "nosuid" "tcp"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Make sure the Docker network exists.
|
# Make sure the Docker network exists.
|
||||||
|
|
@ -226,7 +217,9 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation.oci-containers.containers = {
|
virtualisation.oci-containers.containers = let
|
||||||
|
videoHostPath = config.homelab.fileSystems.media.video.hostPath;
|
||||||
|
in {
|
||||||
bazarr = let
|
bazarr = let
|
||||||
port = 6767;
|
port = 6767;
|
||||||
in lib.mkIf cfg.bazarr.enable {
|
in lib.mkIf cfg.bazarr.enable {
|
||||||
|
|
@ -252,8 +245,8 @@ in {
|
||||||
|
|
||||||
"/srv/bazarr-backup:/config/backup"
|
"/srv/bazarr-backup:/config/backup"
|
||||||
|
|
||||||
"/srv/video/Films:/media/movies"
|
"${videoHostPath}/Films:/media/movies"
|
||||||
"/srv/video/Series:/media/series"
|
"${videoHostPath}/Series:/media/series"
|
||||||
];
|
];
|
||||||
labels = {
|
labels = {
|
||||||
"traefik.enable" = "true";
|
"traefik.enable" = "true";
|
||||||
|
|
@ -374,7 +367,7 @@ in {
|
||||||
"/srv/radarr-backup:/config/Backups"
|
"/srv/radarr-backup:/config/Backups"
|
||||||
|
|
||||||
"/srv/torrent:/media/cache"
|
"/srv/torrent:/media/cache"
|
||||||
"/srv/video/Films:/media/movies"
|
"${videoHostPath}/Films:/media/movies"
|
||||||
];
|
];
|
||||||
labels = {
|
labels = {
|
||||||
"traefik.enable" = "true";
|
"traefik.enable" = "true";
|
||||||
|
|
@ -407,7 +400,7 @@ in {
|
||||||
"/srv/sonarr-backup:/config/Backups"
|
"/srv/sonarr-backup:/config/Backups"
|
||||||
|
|
||||||
"/srv/torrent:/media/cache"
|
"/srv/torrent:/media/cache"
|
||||||
"/srv/video/Series:/media/series"
|
"${videoHostPath}/Series:/media/series"
|
||||||
];
|
];
|
||||||
labels = {
|
labels = {
|
||||||
"traefik.enable" = "true";
|
"traefik.enable" = "true";
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ in {
|
||||||
apps.enable = true;
|
apps.enable = true;
|
||||||
media.enable = true;
|
media.enable = true;
|
||||||
};
|
};
|
||||||
|
fileSystems.media.video.enable = true;
|
||||||
virtualisation.containers.enable = true;
|
virtualisation.containers.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -25,22 +26,11 @@ in {
|
||||||
shell = null;
|
shell = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/srv/video" = {
|
virtualisation.oci-containers.containers.plex = let
|
||||||
device = "192.168.0.11:/mnt/SMALL/MEDIA/VIDEO";
|
videoHostPath = config.homelab.fileSystems.media.video.hostPath;
|
||||||
fsType = "nfs";
|
in {
|
||||||
options = [
|
|
||||||
"ro"
|
|
||||||
"nfsvers=4.2"
|
|
||||||
"async" "soft"
|
|
||||||
"timeo=100" "retry=50" "actimeo=1800" "lookupcache=all"
|
|
||||||
"nosuid" "tcp"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualisation.oci-containers.containers = {
|
|
||||||
plex = {
|
|
||||||
hostname = "plex";
|
hostname = "plex";
|
||||||
image = "plexinc/pms-docker:1.41.0.8992-8463ad060";
|
image = "plexinc/pms-docker:1.41.6.9685-d301f511a";
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
ports = [
|
ports = [
|
||||||
"32400:32400/tcp" # Plex Media Server
|
"32400:32400/tcp" # Plex Media Server
|
||||||
|
|
@ -56,23 +46,24 @@ in {
|
||||||
#ADVERTISE_AP = "..."; # TODO Configure ip
|
#ADVERTISE_AP = "..."; # TODO Configure ip
|
||||||
ALLOWED_NETWORKS = "192.168.0.0/24,172.16.0.0/16";
|
ALLOWED_NETWORKS = "192.168.0.0/24,172.16.0.0/16";
|
||||||
CHANGE_CONFIG_DIR_OWNERSHIP = "false";
|
CHANGE_CONFIG_DIR_OWNERSHIP = "false";
|
||||||
HOSTNAME = "PlexServer";
|
HOSTNAME = "Hugo-Plex";
|
||||||
#PLEX_CLAIM = "..."; # TODO Add token
|
PLEX_CLAIM = "claim-d5MqsjMeCZrUF6oUvssr";
|
||||||
PLEX_UID = toString config.users.users.plex.uid;
|
PLEX_UID = toString config.users.users.plex.uid;
|
||||||
PLEX_GID = toString config.users.groups.media.gid;
|
PLEX_GID = toString config.users.groups.media.gid;
|
||||||
TZ = config.time.timeZone;
|
TZ = config.time.timeZone;
|
||||||
};
|
};
|
||||||
volumes = [
|
volumes = [
|
||||||
"plex-config:/var/lib/plexmediaserver"
|
# TODO Backup over NFS
|
||||||
|
"plex-config:/config"
|
||||||
"plex-transcode:/transcode"
|
"plex-transcode:/transcode"
|
||||||
"/srv/video:/data/video"
|
|
||||||
|
"${videoHostPath}:/data/video:ro"
|
||||||
];
|
];
|
||||||
labels = {
|
labels = {
|
||||||
"traefik.enable" = "true";
|
"traefik.enable" = "true";
|
||||||
"traefik.http.routers.plex.rule=" = "Host(`plex.depeuter.dev`)";
|
"traefik.http.routers.plex.rule" = "Host(`plex.depeuter.dev`)";
|
||||||
"traefik.http.services.plex.loadbalancer.server.port" = "32400";
|
"traefik.http.services.plex.loadbalancer.server.port" = "32400";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
modules/fileSystems/default.nix
Normal file
5
modules/fileSystems/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./media
|
||||||
|
];
|
||||||
|
}
|
||||||
5
modules/fileSystems/media/default.nix
Normal file
5
modules/fileSystems/media/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./video
|
||||||
|
];
|
||||||
|
}
|
||||||
42
modules/fileSystems/media/video/default.nix
Normal file
42
modules/fileSystems/media/video/default.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.homelab.fileSystems.media.video;
|
||||||
|
|
||||||
|
remotePath = "/mnt/SMALL/MEDIA/VIDEO";
|
||||||
|
|
||||||
|
maxPermissions = permissions:
|
||||||
|
if builtins.elem "write" permissions then "rw"
|
||||||
|
else "ro";
|
||||||
|
permissionsOption = maxPermissions cfg.permissions;
|
||||||
|
in {
|
||||||
|
options.homelab.fileSystems.media.video = {
|
||||||
|
enable = lib.mkEnableOption "MEDIA/VIDEO dataset";
|
||||||
|
hostPath = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "/srv/video";
|
||||||
|
description = "Mountpath on host";
|
||||||
|
};
|
||||||
|
permissions = lib.mkOption {
|
||||||
|
type = lib.types.listOf (lib.types.enum [ "read" "write" ]);
|
||||||
|
default = [ "read" ];
|
||||||
|
description = "Mount options permissions";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
fileSystems."${cfg.hostPath}" = {
|
||||||
|
device = "192.168.0.11:${remotePath}";
|
||||||
|
fsType = "nfs";
|
||||||
|
options = [
|
||||||
|
permissionsOption
|
||||||
|
"auto"
|
||||||
|
"nfsvers=4.2"
|
||||||
|
"async" "soft"
|
||||||
|
"rsize=1048576" "wsize=1048576"
|
||||||
|
"timeo=600" "retry=50" "retrans=2" "actimeo=1800" "lookupcache=all"
|
||||||
|
"_netdev" "nosuid" "tcp"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue