summaryrefslogtreecommitdiff
path: root/nixos/modules/services/dlnatoad.nix
blob: 8f50c7259318e48d5b685b716987bf9e41bc9a8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ 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" ];
      path = [ pkgs.ffmpeg ];
      serviceConfig = {
        DynamicUser = true;

        CacheDirectory = systemdDirectoryName;

        ExecStart = "${pkgs.eth.dlnatoad}/bin/dlnatoad ${concatStringsSep " " cfg.directories} --db ${cacheDirectory}/db --thumbs ${cacheDirectory} --verbose";

        NoNewPrivileges = true;
        ProtectHome = true;
        ProtectKernelTunables = true;
        ProtectControlGroups = true;
        ProtectKernelModules = true;
      };
    };
  };

}