2024-11-19 13:54:15 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.mpd;
|
|
|
|
in
|
2022-03-07 16:01:52 +01:00
|
|
|
{
|
2024-11-19 13:54:15 +01:00
|
|
|
services.mpd = {
|
2022-03-07 16:01:52 +01:00
|
|
|
enable = true;
|
2022-11-11 21:23:25 +01:00
|
|
|
musicDirectory = config.xdg.userDirs.music;
|
2024-11-19 13:54:15 +01:00
|
|
|
playlistDirectory = "${cfg.musicDirectory}/playlists/MPD";
|
2024-06-25 19:02:20 +02:00
|
|
|
network.startWhenNeeded = true;
|
|
|
|
|
|
|
|
extraConfig = ''
|
2024-11-19 13:54:15 +01:00
|
|
|
pid_file "/run/user/${toString config.home.uid}/mpd/pid"
|
|
|
|
|
|
|
|
zeroconf_enabled "no"
|
|
|
|
|
|
|
|
replaygain "auto"
|
|
|
|
|
|
|
|
restore_paused "yes"
|
|
|
|
|
|
|
|
auto_update "no"
|
|
|
|
|
|
|
|
audio_output {
|
|
|
|
type "pipewire"
|
|
|
|
name "PipeWire Sound Server"
|
|
|
|
}
|
|
|
|
|
2024-06-25 19:02:20 +02:00
|
|
|
audio_output {
|
|
|
|
type "fifo"
|
|
|
|
name "Visualizer feed"
|
2024-11-19 13:54:15 +01:00
|
|
|
path "/run/user/${toString config.home.uid}/mpd/visualizer.fifo"
|
2024-06-25 19:02:20 +02:00
|
|
|
format "44100:16:2"
|
|
|
|
}
|
|
|
|
|
2024-11-19 13:54:15 +01:00
|
|
|
resampler {
|
|
|
|
plugin "soxr"
|
|
|
|
quality "very high"
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_plugin {
|
|
|
|
name "cue"
|
|
|
|
enabled "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_plugin {
|
|
|
|
name "m3u"
|
|
|
|
enabled "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_plugin {
|
|
|
|
name "extm3u"
|
|
|
|
enabled "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_plugin {
|
|
|
|
name "flac"
|
|
|
|
enabled "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_plugin {
|
|
|
|
name "rss"
|
|
|
|
enabled "true"
|
2024-06-25 19:02:20 +02:00
|
|
|
}
|
|
|
|
'';
|
2022-03-07 16:01:52 +01:00
|
|
|
};
|
2024-08-02 17:45:34 +02:00
|
|
|
|
|
|
|
# TODO: upstream unix socket support to home-manager
|
2024-11-19 13:54:15 +01:00
|
|
|
|
|
|
|
systemd.user.services.mpd = {
|
|
|
|
Unit = {
|
|
|
|
Documentation = [
|
|
|
|
"man:mpd(1)"
|
|
|
|
"man:mpd.conf(5)"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
Service = {
|
|
|
|
WatchdogSec = 120;
|
|
|
|
|
|
|
|
# for io_uring
|
|
|
|
LimitMEMLOCK = "64M";
|
|
|
|
|
|
|
|
# allow MPD to use real-time priority 40
|
|
|
|
LimitRTPRIO = 40;
|
|
|
|
LimitRTTIME = "infinity";
|
|
|
|
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProtectSystem = true;
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_UNIX"
|
|
|
|
];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.paths.mpd-update-library = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Watchdog that updates the mpd library whenever the files are modified";
|
|
|
|
Documentation = [
|
|
|
|
"man:mpd(1)"
|
|
|
|
"man:mpd.conf(5)"
|
|
|
|
];
|
|
|
|
WantedBy = [ "paths.target" ];
|
|
|
|
};
|
|
|
|
Path = {
|
|
|
|
PathChanged = cfg.musicDirectory;
|
|
|
|
Unit = "mpd-update-library.service";
|
|
|
|
TriggerLimitIntervalSec = "1s";
|
|
|
|
TriggerLimitBurst = "1";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.services.mpd-update-library = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Watchdog that updates the mpd library whenever the files are modified";
|
|
|
|
Documentation = [
|
|
|
|
"man:mpd(1)"
|
|
|
|
"man:mpd.conf(5)"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
Service = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${lib.getExe pkgs.mpc-cli} update --wait";
|
|
|
|
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProtectSystem = true;
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_UNIX"
|
|
|
|
];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
};
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
}
|
|
|
|
|