2014-04-14 16:26:48 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2013-02-16 23:08:53 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.minidlna;
|
2024-10-05 11:28:22 +03:00
|
|
|
format = pkgs.formats.keyValue { listsAsDuplicateKeys = true; };
|
|
|
|
cfgfile = format.generate "minidlna.conf" cfg.settings;
|
2013-02-16 23:08:53 +01:00
|
|
|
|
2024-10-05 11:28:22 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.minidlna.enable = lib.mkEnableOption "MiniDLNA, a simple DLNA server. Consider adding `openFirewall = true` into your config";
|
|
|
|
options.services.minidlna.openFirewall = lib.mkEnableOption "opening HTTP (TCP) and SSDP (UDP) ports in the firewall";
|
|
|
|
options.services.minidlna.package = lib.mkPackageOption pkgs "minidlna" { };
|
2021-11-19 17:44:09 +03:00
|
|
|
|
2024-09-08 13:34:19 +03:00
|
|
|
options.services.minidlna.settings = lib.mkOption {
|
2021-11-19 17:44:09 +03:00
|
|
|
default = { };
|
2025-01-27 02:10:23 +01:00
|
|
|
description = "Configuration for {manpage}`minidlna.conf(5)`.";
|
2024-09-08 13:34:19 +03:00
|
|
|
type = lib.types.submodule {
|
2024-10-05 11:28:22 +03:00
|
|
|
freeformType = format.type;
|
2021-11-19 17:44:09 +03:00
|
|
|
|
2024-09-08 13:34:19 +03:00
|
|
|
options.media_dir = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2021-11-19 17:44:09 +03:00
|
|
|
default = [ ];
|
|
|
|
example = [
|
|
|
|
"/data/media"
|
|
|
|
"V,/home/alice/video"
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
Directories to be scanned for media files.
|
2022-08-02 00:26:23 +03:00
|
|
|
The `A,` `V,` `P,` prefixes restrict a directory to audio, video or image files.
|
|
|
|
The directories must be accessible to the `minidlna` user account.
|
2013-02-16 23:08:53 +01:00
|
|
|
'';
|
2021-11-19 17:44:09 +03:00
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.notify_interval = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2021-11-19 17:44:09 +03:00
|
|
|
default = 90000;
|
|
|
|
description = ''
|
2020-01-19 14:06:27 +01:00
|
|
|
The interval between announces (in seconds).
|
2022-08-02 00:26:23 +03:00
|
|
|
Instead of waiting for announces, you should set `openFirewall` option to use SSDP discovery.
|
2024-10-05 11:28:22 +03:00
|
|
|
Lower values (e.g. 30 seconds) should be used if your network is blocking the SSDP multicast.
|
|
|
|
Some relevant information can be found [here](https://sourceforge.net/p/minidlna/discussion/879957/thread/1389d197/).
|
2021-07-23 00:02:08 +03:00
|
|
|
'';
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2021-11-19 17:44:09 +03:00
|
|
|
default = 8200;
|
|
|
|
description = "Port number for HTTP traffic (descriptions, SOAP, media transfer).";
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.db_dir = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
2021-11-19 17:44:09 +03:00
|
|
|
default = "/var/cache/minidlna";
|
|
|
|
example = "/tmp/minidlna";
|
2024-10-05 11:28:22 +03:00
|
|
|
description = "Specify the directory to store database and album art cache.";
|
2021-11-19 17:44:09 +03:00
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.friendly_name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2022-08-02 00:26:23 +03:00
|
|
|
default = config.networking.hostName;
|
2024-09-08 13:34:19 +03:00
|
|
|
defaultText = lib.literalExpression "config.networking.hostName";
|
2021-11-19 17:44:09 +03:00
|
|
|
example = "rpi3";
|
2024-10-05 11:28:22 +03:00
|
|
|
description = "Name that the server presents to clients.";
|
2021-11-19 17:44:09 +03:00
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.root_container = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2023-01-12 10:51:00 +03:00
|
|
|
default = "B";
|
|
|
|
example = ".";
|
2021-11-19 17:44:09 +03:00
|
|
|
description = "Use a different container as the root of the directory tree presented to clients.";
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.log_level = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-11-19 17:44:09 +03:00
|
|
|
default = "warn";
|
|
|
|
example = "general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn";
|
|
|
|
description = "Defines the type of messages that should be logged and down to which level of importance.";
|
|
|
|
};
|
2024-10-05 11:27:56 +03:00
|
|
|
options.enable_subtitles = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
|
|
|
"yes"
|
|
|
|
"no"
|
|
|
|
];
|
|
|
|
default = "yes";
|
|
|
|
description = "Enable subtitle support on unknown clients.";
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.inotify = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
|
|
|
"yes"
|
|
|
|
"no"
|
|
|
|
];
|
2021-11-19 17:44:09 +03:00
|
|
|
default = "no";
|
|
|
|
description = "Whether to enable inotify monitoring to automatically discover new files.";
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.enable_tivo = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
|
|
|
"yes"
|
|
|
|
"no"
|
|
|
|
];
|
2021-11-19 17:44:09 +03:00
|
|
|
default = "no";
|
|
|
|
description = "Support for streaming .jpg and .mp3 files to a TiVo supporting HMO.";
|
|
|
|
};
|
2024-09-08 13:34:19 +03:00
|
|
|
options.wide_links = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
|
|
|
"yes"
|
|
|
|
"no"
|
|
|
|
];
|
2021-11-19 17:44:09 +03:00
|
|
|
default = "no";
|
2022-08-02 00:26:23 +03:00
|
|
|
description = "Set this to yes to allow symlinks that point outside user-defined `media_dir`.";
|
2021-11-19 17:44:09 +03:00
|
|
|
};
|
2013-02-16 23:08:53 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-08 13:34:19 +03:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.settings.port ];
|
|
|
|
networking.firewall.allowedUDPPorts = lib.mkIf cfg.openFirewall [ 1900 ];
|
2021-07-23 00:02:08 +03:00
|
|
|
|
2024-10-05 11:28:22 +03:00
|
|
|
users.groups.minidlna.gid = config.ids.gids.minidlna;
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.minidlna = {
|
2013-08-26 15:20:25 +02:00
|
|
|
description = "MiniDLNA daemon user";
|
|
|
|
group = "minidlna";
|
|
|
|
uid = config.ids.uids.minidlna;
|
|
|
|
};
|
|
|
|
|
2023-01-12 10:51:00 +03:00
|
|
|
systemd.services.minidlna = {
|
|
|
|
description = "MiniDLNA Server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
2013-02-16 23:08:53 +01:00
|
|
|
|
2023-01-12 10:51:00 +03:00
|
|
|
serviceConfig = {
|
|
|
|
User = "minidlna";
|
|
|
|
Group = "minidlna";
|
|
|
|
CacheDirectory = "minidlna";
|
|
|
|
RuntimeDirectory = "minidlna";
|
|
|
|
PIDFile = "/run/minidlna/pid";
|
2024-10-05 11:28:22 +03:00
|
|
|
ExecStart = "${lib.getExe cfg.package} -S -P /run/minidlna/pid -f ${cfgfile}";
|
2013-02-16 23:08:53 +01:00
|
|
|
};
|
2023-01-12 10:51:00 +03:00
|
|
|
};
|
2013-02-16 23:08:53 +01:00
|
|
|
};
|
|
|
|
}
|