2013-02-16 22:08:53 +00:00
|
|
|
|
# Module for MiniDLNA, a simple DLNA server.
|
2014-04-14 15:26:48 +01:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2013-02-16 22:08:53 +00:00
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
|
with lib;
|
2013-02-16 22:08:53 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
cfg = config.services.minidlna;
|
|
|
|
|
port = 8200;
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
###### interface
|
|
|
|
|
options = {
|
|
|
|
|
services.minidlna.enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Whether to enable MiniDLNA, a simple DLNA server. It serves
|
|
|
|
|
media files such as video and music to DLNA client devices
|
|
|
|
|
such as televisions and media players.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.minidlna.mediaDirs = mkOption {
|
2015-06-15 17:18:46 +01:00
|
|
|
|
type = types.listOf types.str;
|
2013-02-16 22:08:53 +00:00
|
|
|
|
default = [];
|
2013-10-30 14:33:20 +00:00
|
|
|
|
example = [ "/data/media" "V,/home/alice/video" ];
|
2013-02-16 22:08:53 +00:00
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Directories to be scanned for media files. The prefixes
|
|
|
|
|
<literal>A,</literal>, <literal>V,</literal> and
|
|
|
|
|
<literal>P,</literal> restrict a directory to audio, video
|
|
|
|
|
or image files. The directories must be accessible to the
|
|
|
|
|
<literal>minidlna</literal> user account.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-07 10:29:25 +00:00
|
|
|
|
services.minidlna.friendlyName = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "${config.networking.hostName} MiniDLNA";
|
|
|
|
|
defaultText = "$HOSTNAME MiniDLNA";
|
|
|
|
|
example = "rpi3";
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Name that the DLNA server presents to clients.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.minidlna.rootContainer = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = ".";
|
|
|
|
|
example = "B";
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Use a different container as the root of the directory tree presented
|
|
|
|
|
to clients. The possible values are:
|
|
|
|
|
- "." - standard container
|
|
|
|
|
- "B" - "Browse Directory"
|
|
|
|
|
- "M" - "Music"
|
|
|
|
|
- "P" - "Pictures"
|
|
|
|
|
- "V" - "Video"
|
|
|
|
|
- Or, you can specify the ObjectID of your desired root container
|
|
|
|
|
(eg. 1$F for Music/Playlists)
|
|
|
|
|
If you specify "B" and the client device is audio-only then
|
|
|
|
|
"Music/Folders" will be used as root.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-08 00:18:56 +01:00
|
|
|
|
services.minidlna.loglevel = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
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 they should be considered.
|
|
|
|
|
|
|
|
|
|
The possible types are “artwork”, “database”, “general”, “http”,
|
|
|
|
|
“inotify”, “metadata”, “scanner”, “ssdp” and “tivo”.
|
|
|
|
|
|
|
|
|
|
The levels are “off”, “fatal”, “error”, “warn”, “info” and
|
|
|
|
|
“debug”, listed here in order of decreasing importance. “off”
|
|
|
|
|
turns off logging messages entirely, “fatal” logs the most
|
|
|
|
|
critical messages only, and so on down to “debug” that logs every
|
|
|
|
|
single messages.
|
|
|
|
|
|
|
|
|
|
The types are comma-separated, followed by an equal sign (‘=’),
|
|
|
|
|
followed by a level that applies to the preceding types. This can
|
|
|
|
|
be repeated, separating each of these constructs with a comma.
|
|
|
|
|
|
|
|
|
|
Defaults to “general,artwork,database,inotify,scanner,metadata,
|
|
|
|
|
http,ssdp,tivo=warn” which logs every type of message at the
|
|
|
|
|
“warn” level.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-19 13:06:27 +00:00
|
|
|
|
services.minidlna.announceInterval = mkOption {
|
|
|
|
|
type = types.int;
|
|
|
|
|
default = 895;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
The interval between announces (in seconds).
|
|
|
|
|
|
|
|
|
|
By default miniDLNA will announce its presence on the network
|
|
|
|
|
approximately every 15 minutes.
|
|
|
|
|
|
|
|
|
|
Many people prefer shorter announce intervals (e.g. 60 seconds)
|
|
|
|
|
on their home networks, especially when DLNA clients are
|
|
|
|
|
started on demand.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-16 22:08:53 +00:00
|
|
|
|
services.minidlna.config = mkOption {
|
|
|
|
|
type = types.lines;
|
2019-03-07 10:29:25 +00:00
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
The contents of MiniDLNA's configuration file.
|
|
|
|
|
When the service is activated, a basic template is generated
|
|
|
|
|
from the current options opened here.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.minidlna.extraConfig = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
|
|
|
|
example = ''
|
|
|
|
|
# Not exhaustive example
|
|
|
|
|
# Support for streaming .jpg and .mp3 files to a TiVo supporting HMO.
|
|
|
|
|
enable_tivo=no
|
|
|
|
|
# SSDP notify interval, in seconds.
|
|
|
|
|
notify_interval=10
|
|
|
|
|
# maximum number of simultaneous connections
|
|
|
|
|
# note: many clients open several simultaneous connections while
|
|
|
|
|
# streaming
|
|
|
|
|
max_connections=50
|
|
|
|
|
# set this to yes to allow symlinks that point outside user-defined
|
|
|
|
|
# media_dirs.
|
|
|
|
|
wide_links=yes
|
|
|
|
|
'';
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
Extra minidlna options not yet opened for configuration here
|
|
|
|
|
(strict_dlna, model_number, model_name, etc...). This is appended
|
|
|
|
|
to the current service already provided.
|
|
|
|
|
'';
|
2013-02-16 22:08:53 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
services.minidlna.config =
|
|
|
|
|
''
|
|
|
|
|
port=${toString port}
|
2019-03-07 10:29:25 +00:00
|
|
|
|
friendly_name=${cfg.friendlyName}
|
2013-02-16 22:08:53 +00:00
|
|
|
|
db_dir=/var/cache/minidlna
|
2018-04-08 00:18:56 +01:00
|
|
|
|
log_level=${cfg.loglevel}
|
2013-02-16 22:08:53 +00:00
|
|
|
|
inotify=yes
|
2019-03-07 10:29:25 +00:00
|
|
|
|
root_container=${cfg.rootContainer}
|
2013-02-16 22:08:53 +00:00
|
|
|
|
${concatMapStrings (dir: ''
|
|
|
|
|
media_dir=${dir}
|
|
|
|
|
'') cfg.mediaDirs}
|
2020-01-19 13:06:27 +00:00
|
|
|
|
notify_interval=${toString cfg.announceInterval}
|
2019-03-07 10:29:25 +00:00
|
|
|
|
${cfg.extraConfig}
|
2013-02-16 22:08:53 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
|
users.users.minidlna = {
|
2013-08-26 14:20:25 +01:00
|
|
|
|
description = "MiniDLNA daemon user";
|
|
|
|
|
group = "minidlna";
|
|
|
|
|
uid = config.ids.uids.minidlna;
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
|
users.groups.minidlna.gid = config.ids.gids.minidlna;
|
2013-02-16 22:08:53 +00:00
|
|
|
|
|
|
|
|
|
systemd.services.minidlna =
|
|
|
|
|
{ description = "MiniDLNA Server";
|
|
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-09-01 02:07:23 +01:00
|
|
|
|
after = [ "network.target" ];
|
2013-02-16 22:08:53 +00:00
|
|
|
|
|
|
|
|
|
serviceConfig =
|
|
|
|
|
{ User = "minidlna";
|
2016-04-08 21:37:11 +01:00
|
|
|
|
Group = "minidlna";
|
2019-02-24 12:17:37 +00:00
|
|
|
|
CacheDirectory = "minidlna";
|
2016-04-08 21:37:11 +01:00
|
|
|
|
RuntimeDirectory = "minidlna";
|
2013-02-16 22:08:53 +00:00
|
|
|
|
PIDFile = "/run/minidlna/pid";
|
|
|
|
|
ExecStart =
|
2016-04-08 21:37:11 +01:00
|
|
|
|
"${pkgs.minidlna}/sbin/minidlnad -S -P /run/minidlna/pid" +
|
2013-02-16 22:08:53 +00:00
|
|
|
|
" -f ${pkgs.writeText "minidlna.conf" cfg.config}";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|