aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/audio/mpd.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/audio/mpd.nix')
-rw-r--r--nixpkgs/nixos/modules/services/audio/mpd.nix45
1 files changed, 44 insertions, 1 deletions
diff --git a/nixpkgs/nixos/modules/services/audio/mpd.nix b/nixpkgs/nixos/modules/services/audio/mpd.nix
index f4eb4a265a4..ba20b1b98d9 100644
--- a/nixpkgs/nixos/modules/services/audio/mpd.nix
+++ b/nixpkgs/nixos/modules/services/audio/mpd.nix
@@ -11,6 +11,10 @@ let
cfg = config.services.mpd;
mpdConf = pkgs.writeText "mpd.conf" ''
+ # This file was automatically generated by NixOS. Edit mpd's configuration
+ # via NixOS' configuration.nix, as this file will be rewritten upon mpd's
+ # restart.
+
music_directory "${cfg.musicDirectory}"
playlist_directory "${cfg.playlistDirectory}"
${lib.optionalString (cfg.dbFile != null) ''
@@ -21,6 +25,12 @@ let
${optionalString (cfg.network.listenAddress != "any") ''bind_to_address "${cfg.network.listenAddress}"''}
${optionalString (cfg.network.port != 6600) ''port "${toString cfg.network.port}"''}
+ ${optionalString (cfg.fluidsynth) ''
+ decoder {
+ plugin "fluidsynth"
+ soundfont "${pkgs.soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2"
+ }
+ ''}
${cfg.extraConfig}
'';
@@ -133,6 +143,26 @@ in {
parameter is omitted from the configuration.
'';
};
+
+ credentialsFile = mkOption {
+ type = types.path;
+ description = ''
+ Path to a file to be merged with the settings during the service startup.
+ Useful to merge a file which is better kept out of the Nix store
+ because it contains sensible data like MPD's password. Example may look like this:
+ <literal>password "myMpdPassword@read,add,control,admin"</literal>
+ '';
+ default = "/dev/null";
+ example = "/var/lib/secrets/mpd.conf";
+ };
+
+ fluidsynth = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ If set, add fluidsynth soundfont and configure the plugin.
+ '';
+ };
};
};
@@ -167,7 +197,12 @@ in {
serviceConfig = {
User = "${cfg.user}";
- ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${mpdConf}";
+ ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon /etc/mpd.conf";
+ ExecStartPre = pkgs.writeScript "mpd-start-pre" ''
+ #!${pkgs.runtimeShell}
+ set -euo pipefail
+ cat ${mpdConf} ${cfg.credentialsFile} > /etc/mpd.conf
+ '';
Type = "notify";
LimitRTPRIO = 50;
LimitRTTIME = "infinity";
@@ -181,6 +216,14 @@ in {
Restart = "always";
};
};
+ environment.etc."mpd.conf" = {
+ mode = "0640";
+ group = cfg.group;
+ user = cfg.user;
+ # To be modified by the service' ExecStartPre
+ text = ''
+ '';
+ };
users.users = optionalAttrs (cfg.user == name) {
${name} = {