From cb9acfbddec2a95ba676f41c88e663c045a5c3e1 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Fri, 23 Feb 2024 13:52:00 -0800 Subject: [PATCH] feat(mediabox): cache storage --- nixos/plex.nix | 11 ++++++++--- nixos/tautulli.nix | 12 ++++++++++-- packages/default.nix | 8 ++++---- systems/mediabox/lxc.json | 1 + systems/reisen/setup.sh | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/nixos/plex.nix b/nixos/plex.nix index 5d0a5ff4..07c7cb35 100644 --- a/nixos/plex.nix +++ b/nixos/plex.nix @@ -2,12 +2,17 @@ inherit (lib.modules) mkIf mkDefault; cfg = config.services.plex; in { - services.plex.enable = true; + services.plex.enable = mkDefault true; systemd.services.plex = mkIf cfg.enable { # /var/lib/plex/mesa_shader_cache environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir; - # KillMode = "mixed" doesn't behave as expected... - serviceConfig.TimeoutStopSec = 5; + serviceConfig = { + BindPaths = [ + "/mnt/caches/plex/Cache:${cfg.dataDir}/Plex Media Server/Cache" + ]; + # KillMode = "mixed" doesn't behave as expected... + TimeoutStopSec = 5; + }; }; # Plex Media Server: diff --git a/nixos/tautulli.nix b/nixos/tautulli.nix index fcdaad15..9ccd62df 100644 --- a/nixos/tautulli.nix +++ b/nixos/tautulli.nix @@ -1,8 +1,16 @@ -{lib, ...}: let - inherit (lib.modules) mkDefault; +{config, lib, ...}: let + inherit (lib.modules) mkIf mkDefault; + cfg = config.services.tautulli; in { services.tautulli = { enable = mkDefault true; port = mkDefault 8181; }; + systemd.services.tautulli = mkIf cfg.enable { + serviceConfig = { + BindPaths = [ + "/mnt/caches/plex/tautulli/cache:${cfg.dataDir}/cache" + ]; + }; + }; } diff --git a/packages/default.nix b/packages/default.nix index e2b56373..0add4931 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -36,10 +36,10 @@ inherit (inputs.self.lib.lib) userIs; inherit (inputs.self.nixosConfigurations.hakurei.config) users; authorizedKeys = list.concatMap (user: user.openssh.authorizedKeys.keys) ( - list.filter (userIs "wheel") users.users + list.filter (userIs "wheel") (set.values users.users) ); - inputs = { - INPUT_ROOT_SSH_AUTHORIZEDKEYS = pkgs.writeTextFile "root.authorized_keys" ( + inputAttrs = { + INPUT_ROOT_SSH_AUTHORIZEDKEYS = pkgs.writeText "root.authorized_keys" ( string.intercalate "\n" authorizedKeys ); INPUT_TF_SSH_AUTHORIZEDKEYS = reisen + "/tf.authorized_keys"; @@ -51,7 +51,7 @@ INPUT_INFRA_MKPAM = reisen + "/bin/mkpam.sh"; INPUT_INFRA_CT_CONFIG = reisen + "/bin/ct-config.sh"; }; - inputVars = set.mapToValues (key: path: ''${key}="$(base64 -w0 < ${path})"'') inputs; + inputVars = set.mapToValues (key: path: ''${key}="$(base64 -w0 < ${path})"'') inputAttrs; in pkgs.writeShellScriptBin "nf-setup-node" '' ${exports} NF_SETUP_INPUTS=( diff --git a/systems/mediabox/lxc.json b/systems/mediabox/lxc.json index ad6fa924..2f0fc50f 100644 --- a/systems/mediabox/lxc.json +++ b/systems/mediabox/lxc.json @@ -3,6 +3,7 @@ "lxc.mount.entry": [ "/mnt/kyuuto-media/library mnt/kyuuto-media/library none bind,optional,create=dir", "/mnt/kyuuto-media/downloads/deluge mnt/kyuuto-media/downloads/deluge none bind,optional,create=dir", + "/rpool/caches/plex mnt/caches/plex none bind,optional,create=dir", "/dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file" ], "lxc.idmap": [ diff --git a/systems/reisen/setup.sh b/systems/reisen/setup.sh index 7945a698..64f41c19 100644 --- a/systems/reisen/setup.sh +++ b/systems/reisen/setup.sh @@ -109,3 +109,20 @@ if [[ ! -d /rpool/shared/nix/var ]]; then mkdir /rpool/shared/nix/var fi chown 100000:100000 /rpool/shared/nix/var + +if [[ ! -d /rpool/caches ]]; then + zfs create rpool/caches +fi +if [[ ! -d /rpool/caches/plex ]]; then + zfs create rpool/caches/plex +fi +if [[ ! -d /rpool/caches/plex/Cache ]]; then + mkdir /rpool/caches/plex/Cache +fi +if [[ ! -d /rpool/caches/plex/tautulli/cache ]]; then + mkdir -p /rpool/caches/plex/tautulli/cache +fi +chown 100193:100193 /rpool/caches/plex/Cache +chmod 0775 /rpool/caches/plex/Cache +chown 100195:65534 /rpool/caches/plex/tautulli/cache +chmod 0755 /rpool/caches/plex/tautulli/cache