From 59808530ecd2aa0899364f1094d955eb73ff32c5 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sun, 21 Jan 2024 10:56:23 -0800 Subject: [PATCH] feat(mediabox): mediatomb --- modules/nixos/mediatomb.nix | 4 ++-- nixos/deluge.nix | 11 ++++++----- systems/mediabox/nixos.nix | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/modules/nixos/mediatomb.nix b/modules/nixos/mediatomb.nix index ac0d38c9..53f54749 100644 --- a/modules/nixos/mediatomb.nix +++ b/modules/nixos/mediatomb.nix @@ -48,7 +48,7 @@ in { config.systemd.services.mediatomb = mkIf cfg.enable { confinement.enable = mkIf cfg.confine (mkDefault true); bindsTo = map (dir: mkIf (dir.mountPoint != null) - "${utils.escapeSystemdPath dir.mountPoint}" + "${utils.escapeSystemdPath dir.mountPoint}.mount" ) cfg.mediaDirectories; unitConfig.RequiresMountsFor = mkMerge ( map (dir: dir.paths) cfg.mediaDirectories @@ -56,7 +56,7 @@ in { serviceConfig = { RestartSec = mkDefault 15; StateDirectory = mkDefault cfg.package.pname; - BindReadOnlyPaths = mkIf cfg.config (mkMerge ( + BindReadOnlyPaths = mkIf cfg.confine (mkMerge ( map (dir: dir.paths) cfg.mediaDirectories )); }; diff --git a/nixos/deluge.nix b/nixos/deluge.nix index d9dc274e..36c77c44 100644 --- a/nixos/deluge.nix +++ b/nixos/deluge.nix @@ -37,23 +37,24 @@ in { }; services.mediatomb.mediaDirectories = let - parent = builtins.dirOf cfg.config.download_location; - hasCompletedSubdir = cfg.config.move_completed && hasPrefix parent cfg.config.move_completed_path; + downloadLocation = cfg.config.download_location or (cfg.dataDir + "/Downloads"); + parent = builtins.dirOf downloadLocation; + hasCompletedSubdir = cfg.config.move_completed or false && hasPrefix parent cfg.config.move_completed_path; completedSubdir = removePrefix parent cfg.config.move_completed_path; downloadDir = if hasCompletedSubdir then { path = parent; subdirectories = [ - (builtins.baseNameOf cfg.config.download_location) + (builtins.baseNameOf downloadLocation) completedSubdir ]; } else { - path = cfg.config.download_location; + path = downloadLocation; }; completedDir = { path = cfg.config.move_completed_path; }; in mkIf cfg.enable (mkAfter [ downloadDir - (mkIf (cfg.config.move_completed && !hasCompletedSubdir) completedDir) + (mkIf (cfg.config.move_completed or false && !hasCompletedSubdir) completedDir) ]); } diff --git a/systems/mediabox/nixos.nix b/systems/mediabox/nixos.nix index ea10831b..c276e740 100644 --- a/systems/mediabox/nixos.nix +++ b/systems/mediabox/nixos.nix @@ -16,6 +16,7 @@ nixos.tautulli nixos.ombi nixos.deluge + nixos.mediatomb # yarr harr fiddle dee dee >w< nixos.radarr @@ -47,6 +48,24 @@ }; }; + services.mediatomb = { + serverName = "tewi"; + mediaDirectories = [ + rec { + path = "/mnt/Anime"; + mountPoint = path; + } + rec { + path = "/mnt/Shows"; + mountPoint = path; + } + rec { + path = "/mnt/Movies"; + mountPoint = path; + } + ]; + }; + hardware.opengl = { enable = true; extraPackages = with pkgs; [ mesa.drivers vaapiVdpau libvdpau-va-gl ];