Skip to content

Instantly share code, notes, and snippets.

@ayyess
Last active February 12, 2018 22:57
Show Gist options
  • Select an option

  • Save ayyess/b610231b623a140e2173f9a30fd1c291 to your computer and use it in GitHub Desktop.

Select an option

Save ayyess/b610231b623a140e2173f9a30fd1c291 to your computer and use it in GitHub Desktop.
# Adapted from Nixpkgs.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.mpd;
nixos = import <nixpkgs/nixos> {};
in
{
meta.maintainers = [ maintainers.rycee ];
options.services.mpd = nixos.options.services.mpd;
config = mkIf cfg.enable {
systemd.user.services.mpd = {
Unit = {
Description = "Music Player Daemon";
After = [ "network.target" "sound.target" ];
};
Install = {
WantedBy = ["default.target"];
};
Service = {
ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon";
Type = "notify";
};
};
home.file.".config/mpd/mpd.conf".text = ''
music_directory "${cfg.musicDirectory}"
playlist_directory "${cfg.playlistDirectory}"
db_file "${cfg.dbFile}"
state_file "${cfg.dataDir}/state"
sticker_file "${cfg.dataDir}/sticker.sql"
log_file "syslog"
${optionalString (cfg.network.listenAddress != "any") ''bind_to_address "${cfg.network.listenAddress}"''}
${optionalString (cfg.network.port != 6600) ''port "${toString cfg.network.port}"''}
${cfg.extraConfig}
'';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment