Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minidlna: Allow more configuration options #57036

Merged
merged 1 commit into from Sep 17, 2019

Conversation

ardumont
Copy link
Contributor

@ardumont ardumont commented Mar 7, 2019

Motivation for this change

"As a minidlna user", i'd like to have more setup option choices.


At the moment, we have the choice between:

  • having a subset of options
  • override completely the full configuration ("losing" the existing minimal subset)

This PR allows to:

  • configure some other options
  • configure the ones not yet disclosed in nix (extending the
    existing minimal subset). This matches what is done for example in the sshd service.
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)

  • Built on platform(s)

    • NixOS
    • macOS
    • other Linux distributions (debian with nix)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)

Added test on that service.
I followed the doc about tests [1] though which i think is a better link
https://nixos.org/nixos/manual/index.html#sec-nixos-tests

  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"

I'm still not sure what that does but it seems to have worked:

$ git reset --soft origin/master  # now there is wip
$ nix-shell -p nox --run "nox-review wip"
...
Result in /run/user/1000/nox-review-1xmyktwu
total 0
lrwxrwxrwx 1 tony tony 67 Mar  8 18:36 result -> /nix/store/l7lzfp2i0yizm7grylcrmkikm96hmx82-nixos-system-nixos-test
  • Determined the impact on package closure size (by running nix path-info -S before and after)

Not sure i did this correctly:

$ git checkout master
$ nix-build -A minidlna
$ nix path-info -S ./result
/nix/store/1283pa3i7yyjpz7aana2rncq41qjwkxd-minidlna-1.2.1        141423736
$ git checkout minidlna-update-configuration
$ nix-build -A minidlna
$ nix path-info -S ./result
/nix/store/1283pa3i7yyjpz7aana2rncq41qjwkxd-minidlna-1.2.1        141423736

  • Assured whether relevant documentation is up to date
    ~> every new option opened has the docstring updated as well

  • Fits CONTRIBUTING.md.
    as far as i could tell ;)

  • Tested execution of all binary files (usually in ./result/bin/)

It's a service, i don't know how to test that without actually
installing it... Any pointer on that is very welcome, thanks. (I
searched quite some time at nixpkgs, nixos, and nix manuals without
quite the answer i hoped for)

So, i settled on testing it with my rpi3 (aarch64), so:

  • disabled the mainstream service
  • import this patched version
  • define what i wanted as setup

Excerpt:

  ...
  disabledModules = [ "services/networking/minidlna.nix" ];
  imports = [
    ./override-minidlna.nix  # <- the pr's patch
  ];
  services.minidlna = {
    enable = true;
    mediaDirs = [
      "PV,${path}/family"
      "V,${path}/judo"
      "V,${path}/courses"
    ];
    friendlyName = "rpi3";
    rootContainer = "B";
    extraConfig = ''
      album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
      album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
      album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
      notify_interval=60
    '';
  };

  • built
  • installed
  • runs fine with the new configuration \m/
tony@kids> cat $(systemctl status minidlna.service  | grep minidlna.conf | awk '{print $7}')                                                                                                 ~
port=8200
friendly_name=rpi3
db_dir=/var/cache/minidlna
log_level=warn
inotify=yes
root_container=B
media_dir=PV,/family
media_dir=V,/judo
media_dir=V,/courses

album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
notify_interval=60

Cheers,

@ardumont
Copy link
Contributor Author

ardumont commented Mar 7, 2019

Fixed mixed tab/spaces characters.

@aanderse
Copy link
Member

aanderse commented Mar 9, 2019

@infinisil would be real nice to be able to point someone to an RFC regarding module options and config files right now... 😃

nixos/tests/minidlna.nix Outdated Show resolved Hide resolved
@ardumont ardumont force-pushed the minidlna-update-configuration branch from 47878af to 97fede2 Compare March 9, 2019 08:12
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
notify_interval=60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please correct the invento indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done btw ;)

@ardumont ardumont force-pushed the minidlna-update-configuration branch from 97fede2 to fb51d22 Compare March 9, 2019 16:06
@aanderse
Copy link
Member

@ardumont how do you feel about something like this? master...aanderse:minidlna
See https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md by @infinisil for reference.

@ardumont
Copy link
Contributor Author

@ardumont how do you feel about something like this?
master...aanderse:minidlna See
https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md
by @infinisil for reference.

That sounds about right and way more sustainable in the long run indeed.

Thanks for the pointer, I understand the current limitations. I'm not
sure i understood all the points described in the document referred to
though (i'd need another pass ;).

In any case, one remark in the current context, the mediaDirs option
could be dropped altogether. That'd simplify a lot the derivation
(well the let configFile definition at least).

To demonstrate that this specific option can be repeated, i suppose
adding 2 media dirs in the literal examples would help.

I imagine you kept it for backward compabibility ;)

@aanderse
Copy link
Member

I specifically kept mediaDirs because the service won't effectively operate without specifying media directories. Generally speaking any option for which there cannot be a default value and the user must specify for the service to run probably deserves a NixOS option with documentation.

I like to see the new config option as something which usually shouldn't be required to get a service up and running in a usable state.

The loglevel was kept for backwards compatibility, though. In a release or two it should probably be removed.

@ardumont
Copy link
Contributor Author

Right, that sounds like sane choices indeed.

@aanderse
Copy link
Member

@infinisil do you feel like reviewing master...aanderse:minidlna as an alternative to the code in this PR? I'd like to hear your thoughts on the proposed code because the goal of this code is to spread the word of your new RFC 😄

Bonus points if you write something really cool to replace my horrible toKeyValue implementation 😉

};

services.minidlna.extraConfig = mkOption {
type = types.str;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types.lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be fine with types.lines as well, fixing.

@@ -36,6 +36,36 @@ in
'';
};

services.minidlna.friendlyName = mkOption {
type = types.str;
default = "${config.networking.hostName} MiniDLNA";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need a defaultText field as well containing something like

defaultText = "$HOSTNAME MiniDLNA"

otherwise the manual would have to be rebuilt for each host.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

''
Use a different container as the root of the directory tree presented
to clients. The possible values are:
,* "." - standard container
Copy link
Member

@rycee rycee Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this list be formatted OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, i pasted as is from minidlna's documentation.
Will simplify this.

@matthewbauer
Copy link
Member

@GrahamcOfBorg test minidlna

@aanderse
Copy link
Member

aanderse commented Aug 5, 2019

ping (triage)

@ardumont
Copy link
Contributor Author

ardumont commented Aug 5, 2019

ping (triage)

pong?

;)

@bjornfor
Copy link
Contributor

@ardumont: Can you squash fixup commit(s?) and prefix commits with "nixos/minidlna:"?

@ardumont
Copy link
Contributor Author

@ardumont: Can you squash fixup commit(s?) and prefix commits with "nixos/minidlna:"?

done

- "P" - "Pictures"
- "V" - "Video"
- Or, you can specify the ObjectID of your desired root container
(eg. 1$F for Music/Playlists)ss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the trailing 'ss' supposed to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like typos indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

{ ... }:
{
imports = [ ../modules/profiles/minimal.nix ];
networking.firewall.allowedTCPPorts = [ 8200 ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the module could use an "openFirewall" option?

According to https://help.ubuntu.com/community/MiniDLNA, we might want to open UDP port 1900 too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, i use it solely with the tcp port 8200 and it run fine so far ;)
Also, I checked my configuration, and indeed i opened that port myself.

Then again, that was the current behavior so i kept it.
The proposed patch is about allowing more configuration, not behavior change.

Also, i don't really know what's preventing this to be merged already so i'd rather not change the scope just yet ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough. (Although it wouldn't be behavioural change since openFirewall options (should) default to false in nixpgks.)

This commits allows the user to configure:
- more minidlna options
- the ones not yet disclosed in nix (extending the existing minimal subset)
@bjornfor bjornfor merged commit 35fe503 into NixOS:master Sep 17, 2019
@ardumont ardumont deleted the minidlna-update-configuration branch September 18, 2019 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants