git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/minidlna: Allow more configuration options

This commits allows the user to configure: - more minidlna options - the ones not yet disclosed in nix (extending the existing minimal subset)

commit35fe50352fa4ea295fda43e429b4581533e48af4 authorAntoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com> dateThu 7 Mar 2019, 11:29 (8 years ago) parent446dd25
3 files changed+105−2
nixos/modules/services/networking/minidlna.nix+65−2 nixos/tests/all-tests.nix+1 nixos/tests/minidlna.nix+39
nixos/modules/services/networking/minidlna.nix+65−2
@@ -36,6 +36,37 @@ in
3636 '';
3737 };
3838
39+ services.minidlna.friendlyName = mkOption {
40+ type = types.str;
41+ default = "${config.networking.hostName} MiniDLNA";
42+ defaultText = "$HOSTNAME MiniDLNA";
43+ example = "rpi3";
44+ description =
45+ ''
46+ Name that the DLNA server presents to clients.
47+ '';
48+ };
49+
50+ services.minidlna.rootContainer = mkOption {
51+ type = types.str;
52+ default = ".";
53+ example = "B";
54+ description =
55+ ''
56+ Use a different container as the root of the directory tree presented
57+ to clients. The possible values are:
58+ - "." - standard container
59+ - "B" - "Browse Directory"
60+ - "M" - "Music"
61+ - "P" - "Pictures"
62+ - "V" - "Video"
63+ - Or, you can specify the ObjectID of your desired root container
64+ (eg. 1$F for Music/Playlists)
65+ If you specify "B" and the client device is audio-only then
66+ "Music/Folders" will be used as root.
67+ '';
68+ };
69+
3970 services.minidlna.loglevel = mkOption {
4071 type = types.str;
4172 default = "warn";
@@ -66,7 +97,37 @@ in
6697
6798 services.minidlna.config = mkOption {
6899 type = types.lines;
69− description = "The contents of MiniDLNA's configuration file.";
100+ description =
101+ ''
102+ The contents of MiniDLNA's configuration file.
103+ When the service is activated, a basic template is generated
104+ from the current options opened here.
105+ '';
106+ };
107+
108+ services.minidlna.extraConfig = mkOption {
109+ type = types.lines;
110+ default = "";
111+ example = ''
112+ # Not exhaustive example
113+ # Support for streaming .jpg and .mp3 files to a TiVo supporting HMO.
114+ enable_tivo=no
115+ # SSDP notify interval, in seconds.
116+ notify_interval=10
117+ # maximum number of simultaneous connections
118+ # note: many clients open several simultaneous connections while
119+ # streaming
120+ max_connections=50
121+ # set this to yes to allow symlinks that point outside user-defined
122+ # media_dirs.
123+ wide_links=yes
124+ '';
125+ description =
126+ ''
127+ Extra minidlna options not yet opened for configuration here
128+ (strict_dlna, model_number, model_name, etc...). This is appended
129+ to the current service already provided.
130+ '';
70131 };
71132 };
72133
@@ -75,13 +136,15 @@ in
75136 services.minidlna.config =
76137 ''
77138 port=${toString port}
78− friendly_name=${config.networking.hostName} MiniDLNA
139+ friendly_name=${cfg.friendlyName}
79140 db_dir=/var/cache/minidlna
80141 log_level=${cfg.loglevel}
81142 inotify=yes
143+ root_container=${cfg.rootContainer}
82144 ${concatMapStrings (dir: ''
83145 media_dir=${dir}
84146 '') cfg.mediaDirs}
147+ ${cfg.extraConfig}
85148 '';
86149
87150 users.users.minidlna = {
nixos/tests/all-tests.nix+1
@@ -162,6 +162,7 @@ in
162162 metabase = handleTest ./metabase.nix {};
163163 miniflux = handleTest ./miniflux.nix {};
164164 minio = handleTest ./minio.nix {};
165+ minidlna = handleTest ./minidlna.nix {};
165166 misc = handleTest ./misc.nix {};
166167 mongodb = handleTest ./mongodb.nix {};
167168 moodle = handleTest ./moodle.nix {};
nixos/tests/minidlna.nixnew file+39
@@ -0,0 +1,39 @@
1+import ./make-test.nix ({ pkgs, ... }: {
2+ name = "minidlna";
3+
4+ nodes = {
5+ server =
6+ { ... }:
7+ {
8+ imports = [ ../modules/profiles/minimal.nix ];
9+ networking.firewall.allowedTCPPorts = [ 8200 ];
10+ services.minidlna = {
11+ enable = true;
12+ loglevel = "error";
13+ mediaDirs = [
14+ "PV,/tmp/stuff"
15+ ];
16+ friendlyName = "rpi3";
17+ rootContainer = "B";
18+ extraConfig =
19+ ''
20+ album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
21+ album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
22+ album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
23+ notify_interval=60
24+ '';
25+ };
26+ };
27+ client = { ... }: { };
28+ };
29+
30+ testScript =
31+ ''
32+ startAll;
33+ $server->succeed("mkdir -p /tmp/stuff && chown minidlna: /tmp/stuff");
34+ $server->waitForUnit("minidlna");
35+ $server->waitForOpenPort("8200");
36+ $server->succeed("curl --fail http://localhost:8200/");
37+ $client->succeed("curl --fail http://server:8200/");
38+ '';
39+})