mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
fix(plex): cache mount
This commit is contained in:
parent
0ff920215b
commit
dc4072da45
2 changed files with 21 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
{config, lib, ...}: let
|
{config, lib, pkgs, ...}: let
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
inherit (lib.modules) mkIf mkForce mkDefault;
|
||||||
|
inherit (lib.strings) escapeShellArg;
|
||||||
cfg = config.services.plex;
|
cfg = config.services.plex;
|
||||||
in {
|
in {
|
||||||
services.plex.enable = mkDefault true;
|
services.plex.enable = mkDefault true;
|
||||||
|
|
@ -8,7 +9,20 @@ in {
|
||||||
environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir;
|
environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
BindPaths = [
|
BindPaths = [
|
||||||
"/mnt/caches/plex/Cache:${cfg.dataDir}/Plex Media Server/Cache"
|
''/mnt/caches/plex/Cache:${cfg.dataDir}/Cache''
|
||||||
|
];
|
||||||
|
ExecStartPre = let
|
||||||
|
# systemd doesn't seem to like spaces so use a symlink instead...
|
||||||
|
preStartScript = pkgs.writeShellScript "plex-run-prestart" ''
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [[ ! -d $PLEX_DATADIR ]]; then
|
||||||
|
${pkgs.coreutils}/bin/install -d -m 0755 -o ${escapeShellArg cfg.user} -g ${escapeShellArg cfg.group} "$PLEX_DATADIR/Plex Media Server"
|
||||||
|
fi
|
||||||
|
${pkgs.coreutils}/bin/ln -sfT ../Cache "$PLEX_DATADIR/Plex Media Server/Cache"
|
||||||
|
'';
|
||||||
|
in mkForce [
|
||||||
|
''!${preStartScript}''
|
||||||
];
|
];
|
||||||
# KillMode = "mixed" doesn't behave as expected...
|
# KillMode = "mixed" doesn't behave as expected...
|
||||||
TimeoutStopSec = 5;
|
TimeoutStopSec = 5;
|
||||||
|
|
|
||||||
|
|
@ -95,24 +95,24 @@ EOF
|
||||||
if [[ ! -d /rpool/shared ]]; then
|
if [[ ! -d /rpool/shared ]]; then
|
||||||
zfs create rpool/shared
|
zfs create rpool/shared
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d /rpool/shared/nix ]]; then
|
if [[ ! -d /rpool/shared/nix ]]; then
|
||||||
zfs create rpool/shared/nix
|
zfs create rpool/shared/nix
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d /rpool/shared/nix/store ]]; then
|
if [[ ! -d /rpool/shared/nix/store ]]; then
|
||||||
zfs create -o compression=zstd rpool/shared/nix/store
|
zfs create -o compression=zstd rpool/shared/nix/store
|
||||||
fi
|
fi
|
||||||
chown 100000:30000 /rpool/shared/nix/store
|
|
||||||
chmod 1775 /rpool/shared/nix/store
|
|
||||||
|
|
||||||
if [[ ! -d /rpool/shared/nix/var ]]; then
|
if [[ ! -d /rpool/shared/nix/var ]]; then
|
||||||
mkdir /rpool/shared/nix/var
|
mkdir /rpool/shared/nix/var
|
||||||
fi
|
fi
|
||||||
|
chown 100000:30000 /rpool/shared/nix/store
|
||||||
|
chmod 1775 /rpool/shared/nix/store
|
||||||
chown 100000:100000 /rpool/shared/nix/var
|
chown 100000:100000 /rpool/shared/nix/var
|
||||||
|
|
||||||
if [[ ! -d /rpool/caches ]]; then
|
if [[ ! -d /rpool/caches ]]; then
|
||||||
zfs create rpool/caches
|
zfs create rpool/caches
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d /rpool/caches/plex ]]; then
|
if [[ ! -d /rpool/caches/plex ]]; then
|
||||||
zfs create rpool/caches/plex
|
zfs create rpool/caches/plex
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue