From 46040ea7b1911c09b270f65cf5a5548a91f16e95 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Sun, 24 May 2020 22:13:17 +0100 Subject: add DLNAtoad package & service module --- modules/services/dlnatoad.nix | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 modules/services/dlnatoad.nix (limited to 'modules/services/dlnatoad.nix') diff --git a/modules/services/dlnatoad.nix b/modules/services/dlnatoad.nix new file mode 100644 index 0000000..90b2b39 --- /dev/null +++ b/modules/services/dlnatoad.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: +with lib; + +let + cfg = config.eth.services.dlnatoad; + + systemdDirectoryName = "dlnatoad"; + cacheDirectory = "/var/cache/${systemdDirectoryName}"; + +in { + + options.eth.services.dlnatoad = { + enable = mkEnableOption "Whether to enable DLNAtoad"; + + directories = mkOption { + type = types.listOf types.str; + default = []; + description = "A list of paths to index & serve."; + example = [ "/mnt/md0/media" ]; + }; + }; + + + config = mkIf cfg.enable { + systemd.services.dlnatoad = { + enable = true; + description = "DLNAtoad UPnP ContentDirectory service"; + wants = [ "network.target" ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + DynamicUser = true; + + CacheDirectory = systemdDirectoryName; + + ExecStart = "${pkgs.eth.dlnatoad}/bin/dlnatoad ${concatStringsSep " " cfg.directories} --db ${cacheDirectory}/db --thumbs ${cacheDirectory}"; + + NoNewPrivileges = true; + ProtectHome = true; + ProtectKernelTunables = true; + ProtectControlGroups = true; + ProtectKernelModules = true; + }; + }; + }; + +} + -- cgit v1.2.3