-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
services.mpd: allow configuring playlist directory #28252
Conversation
@casey, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rickynils, @bjornfor and @shlevy to be potential reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, my issues with the path type and defaultText apply to the whole module. That's probably the reason you implemented it like this.
Do you want to fix the whole module? :)
@@ -62,6 +60,14 @@ in { | |||
''; | |||
}; | |||
|
|||
playlistDirectory = mkOption { | |||
type = types.path; | |||
default = "${cfg.dataDir}/playlists"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that if the user changes dataDir
, the nixos manual will get rebuilt.
You should add defaultText = ''''${dataDir}/playlists'';
to fix this.
@@ -62,6 +60,14 @@ in { | |||
''; | |||
}; | |||
|
|||
playlistDirectory = mkOption { | |||
type = types.path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paths in Nix refer to files on the evaluating machine that will be put in the Nix store. This is not applicable here. The path to the directory is just a string. Please use types.str
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think path
is okay, it's just a string that begins with a slash: https://github.com/NixOS/nixpkgs-channels/blob/nixos-unstable/lib/types.nix#L167 It's a little unfortunate that the name is overloaded (I too tend to think of store paths in this context).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is types.path
here different from a nix path literal? A path literal being /this/is/a/path/literal
, as opposed to "/this/is/just/a/string"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is, there should be no difference as far as types.path
is concerned. The check would accept both.
@@ -153,7 +159,6 @@ in { | |||
|
|||
preStart = '' | |||
mkdir -p "${cfg.dataDir}" && chown -R ${cfg.user}:${cfg.group} "${cfg.dataDir}" | |||
mkdir -p "${playlistDir}" && chown -R ${cfg.user}:${cfg.group} "${playlistDir}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if mpd creates the playlist directory if it doesn't exist yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it doesn't, I'll re-add that line.
@casey default values are evaluated & the result converted to a string for rendering, the purpose of |
@joachifm So for the String literal, doesn't change if default changes: Use the default directly, not actually sure if this is possible: Pull the dataDir default to somewhere else in the program, then use it:
|
Or you could do what @fpletz suggests and use quoting to make the default text literally render as Doing let
dataDirDefault = "/var/lib/mpd";
in ... and using |
@joachifm Ahh, okay, gotcha, I was confused. I didn't get that |
Modify the mpd service to allow configuring the playlist directory separately.
Tested on NixOS with sandboxing.
The removed line in
preStart
will be a no-op for existing systems. Since they won't have the newplaylistDirectory
, and the oldplaylistDirectory
is underneath the olddataDir
.I removed that line since it seemed inappropriate to modify user and owner in the
playlistDirectory
, which might be outside of mpd's data directory.