fix(plex): shared mount

This commit is contained in:
arcnmx 2024-09-27 19:04:49 -07:00
parent 8f4ea912a1
commit 455aca9312
2 changed files with 23 additions and 5 deletions

View file

@ -10,12 +10,23 @@
in { in {
services.plex.enable = mkDefault true; services.plex.enable = mkDefault true;
systemd.services.plex = mkIf cfg.enable { systemd.services.plex = mkIf cfg.enable {
gensokyo-zone = {
sharedMounts.plex.path = mkDefault cfg.dataDir;
cacheMounts = {
"plex/Cache" = {
path = mkDefault "${cfg.dataDir}/Cache";
};
"plex/Logs" = {
path = mkDefault "${cfg.dataDir}/Logs";
};
"plex/mesa_shader_cache" = {
path = mkDefault "${cfg.dataDir}/mesa_shader_cache";
};
};
};
# /var/lib/plex/mesa_shader_cache # /var/lib/plex/mesa_shader_cache
environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir; environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir;
serviceConfig = { serviceConfig = {
BindPaths = [
''/mnt/caches/plex/Cache:${cfg.dataDir}/Cache''
];
ExecStartPre = let ExecStartPre = let
# systemd doesn't seem to like spaces so use a symlink instead... # systemd doesn't seem to like spaces so use a symlink instead...
preStartScript = pkgs.writeShellScript "plex-run-prestart" '' preStartScript = pkgs.writeShellScript "plex-run-prestart" ''
@ -25,6 +36,7 @@ in {
${pkgs.coreutils}/bin/install -d -m 0755 -o ${escapeShellArg cfg.user} -g ${escapeShellArg cfg.group} "$PLEX_DATADIR/Plex Media Server" ${pkgs.coreutils}/bin/install -d -m 0755 -o ${escapeShellArg cfg.user} -g ${escapeShellArg cfg.group} "$PLEX_DATADIR/Plex Media Server"
fi fi
${pkgs.coreutils}/bin/ln -sfT ../Cache "$PLEX_DATADIR/Plex Media Server/Cache" ${pkgs.coreutils}/bin/ln -sfT ../Cache "$PLEX_DATADIR/Plex Media Server/Cache"
${pkgs.coreutils}/bin/ln -sfT ../Logs "$PLEX_DATADIR/Plex Media Server/Logs"
''; '';
in in
mkForce [ mkForce [

View file

@ -165,11 +165,17 @@ mkcache plex 0 0 0755
if [[ ! -d /rpool/caches/plex/Cache ]]; then if [[ ! -d /rpool/caches/plex/Cache ]]; then
mkdir /rpool/caches/plex/Cache mkdir /rpool/caches/plex/Cache
fi fi
if [[ ! -d /rpool/caches/plex/Logs ]]; then
mkdir /rpool/caches/plex/Logs
fi
if [[ ! -d /rpool/caches/plex/mesa_shader_cache ]]; then
mkdir /rpool/caches/plex/mesa_shader_cache
fi
if [[ ! -d /rpool/caches/plex/tautulli/cache ]]; then if [[ ! -d /rpool/caches/plex/tautulli/cache ]]; then
mkdir -p /rpool/caches/plex/tautulli/cache mkdir -p /rpool/caches/plex/tautulli/cache
fi fi
chown 100193:100193 /rpool/caches/plex/Cache chown 100193:100193 /rpool/caches/plex/{Cache,Logs,mesa_shader_cache}
chmod 0775 /rpool/caches/plex/Cache chmod 0775 /rpool/caches/plex/{Cache,Logs,mesa_shader_cache}
chown 100195:65534 /rpool/caches/plex/tautulli/cache chown 100195:65534 /rpool/caches/plex/tautulli/cache
chmod 0755 /rpool/caches/plex/tautulli/cache chmod 0755 /rpool/caches/plex/tautulli/cache