diff --git a/nixos/systems/tewi/mediatomb.nix b/nixos/systems/tewi/mediatomb.nix index 89343501..ecc94bec 100644 --- a/nixos/systems/tewi/mediatomb.nix +++ b/nixos/systems/tewi/mediatomb.nix @@ -1,19 +1,28 @@ -{ config, lib, ... }: let +{ config, lib, ... }: with lib; let cfg = config.services.mediatomb; shadowDir = "/mnt/shadow"; + inherit (config.services) deluge; + delugeDir = "${shadowDir}/deluge"; in { services.mediatomb = { enable = true; openFirewall = true; serverName = config.networking.hostName; uuid = "082fd344-bf69-5b72-a68f-a5a4d88e76b2"; - mediaDirectories = lib.singleton { - path = "${shadowDir}/media"; - recursive = true; - hidden-files = false; - }; + mediaDirectories = [ + { + path = "${shadowDir}/media"; + recursive = true; + hidden-files = false; + } + (mkIf deluge.enable { + path = delugeDir; + recursive = true; + hidden-files = false; + }) + ]; }; - systemd.services.mediatomb = rec { + systemd.services.mediatomb = { confinement.enable = true; unitConfig = { RequiresMountsFor = [ @@ -22,11 +31,12 @@ in { }; serviceConfig = { StateDirectory = cfg.package.pname; - BindReadOnlyPaths = map (path: "${shadowDir}/media/${path}") [ - "anime" "movies" "tv" "unsorted" - "music" "music-to-import" "music-raw" - ] ++ [ - "${shadowDir}/deluge/complete" + BindReadOnlyPaths = mkMerge [ + (map (path: "${shadowDir}/media/${path}") [ + "anime" "movies" "tv" "unsorted" + "music" "music-to-import" "music-raw" + ]) + (mkIf deluge.enable [ "${delugeDir}/complete" ]) ]; }; };