2024-07-13 22:08:21 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2024-07-15 09:27:55 +02:00
|
|
|
pkgs,
|
2024-07-13 22:08:21 +02:00
|
|
|
...
|
2025-07-20 01:23:48 +02:00
|
|
|
}:
|
|
|
|
let
|
2025-03-26 19:37:50 +01:00
|
|
|
cfg = config.modules.services.media.mpd;
|
|
|
|
inherit (config.meta.mainUser) username;
|
|
|
|
inherit (lib.modules) mkIf;
|
|
|
|
inherit (lib.types) str;
|
|
|
|
inherit (lib.options) mkOption mkEnableOption;
|
2025-07-20 01:23:48 +02:00
|
|
|
in
|
|
|
|
{
|
2025-03-26 19:37:50 +01:00
|
|
|
options.modules.services = {
|
|
|
|
media = {
|
|
|
|
mpd = {
|
|
|
|
enable = mkEnableOption "mpd service";
|
|
|
|
musicDirectory = mkOption {
|
|
|
|
description = "music directory for mpd";
|
|
|
|
type = str;
|
|
|
|
default = "/home/${username}/cloud/media/Music";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-13 22:08:21 +02:00
|
|
|
config = mkIf cfg.enable {
|
2025-03-26 19:37:50 +01:00
|
|
|
# command line interface to mpd
|
2025-07-20 01:23:48 +02:00
|
|
|
environment.systemPackages = [ pkgs.mpc ];
|
2025-03-26 19:37:50 +01:00
|
|
|
|
2024-07-13 23:22:14 +02:00
|
|
|
systemd.services.mpd.environment = {
|
|
|
|
# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/609
|
|
|
|
XDG_RUNTIME_DIR = "/run/user/1000";
|
|
|
|
};
|
|
|
|
services.mpd = {
|
|
|
|
enable = true;
|
|
|
|
inherit (cfg) musicDirectory;
|
|
|
|
user = username;
|
2024-07-21 13:18:00 +02:00
|
|
|
startWhenNeeded = true;
|
2024-07-13 23:22:14 +02:00
|
|
|
extraConfig = ''
|
|
|
|
restore_paused "yes"
|
2024-07-21 13:18:00 +02:00
|
|
|
auto_update "yes"
|
2024-07-13 22:08:21 +02:00
|
|
|
|
2024-07-21 13:18:00 +02:00
|
|
|
audio_output {
|
|
|
|
type "pipewire"
|
|
|
|
name "PipeWire Sound Server"
|
|
|
|
}
|
2024-07-13 23:22:14 +02:00
|
|
|
|
2024-07-21 13:18:00 +02:00
|
|
|
audio_output {
|
|
|
|
type "fifo"
|
|
|
|
name "FIFO"
|
|
|
|
path "/tmp/mpd.fifo"
|
|
|
|
format "44100:16:2"
|
|
|
|
}
|
2024-07-13 23:22:14 +02:00
|
|
|
'';
|
|
|
|
};
|
2024-07-13 22:08:21 +02:00
|
|
|
};
|
|
|
|
}
|