mpd: use XDG music dir if XDG user dirs are enabled

If the user has enabled the XDG user directories module then we can
use the XDG music directory in the MPD module. Otherwise we'll leave
the option undefined so that the user is forced to define the
directory to use.

This applies to state version 22.11 and above.

Fixes #3225
This commit is contained in:
Robert Helgesson 2022-09-15 22:19:00 +02:00
parent b0247ceedc
commit 5427f3d1f0
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
10 changed files with 98 additions and 6 deletions

View file

@ -1,4 +1,4 @@
music_directory "/home/hm-user/music"
music_directory "/my/music/dir"
playlist_directory "/home/hm-user/.local/share/mpd/playlists"
db_file "/home/hm-user/.local/share/mpd/tag_cache"

View file

@ -3,7 +3,12 @@
with lib;
{
services.mpd.enable = true;
services.mpd = {
enable = true;
musicDirectory = "/my/music/dir";
};
home.stateVersion = "22.11";
test.stubs.mpd = { };

View file

@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
with lib;
{
services.mpd.enable = true;
home.stateVersion = "18.09";
test.stubs.mpd = { };
nmt.script = ''
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/mpd.service)
assertFileContent "$serviceFile" ${./basic-configuration.service}
confFile=$(grep -o \
'/nix/store/.*-mpd.conf' \
$TESTED/home-files/.config/systemd/user/mpd.service)
assertFileContains \
"$confFile" \
'music_directory "/home/hm-user/music"'
'';
}

View file

@ -1 +1,5 @@
{ mpd-basic-configuration = ./basic-configuration.nix; }
{
mpd-basic-configuration = ./basic-configuration.nix;
mpd-before-state-version-22_11 = ./before-state-version-22_11.nix;
mpd-xdg-music-dir = ./xdg-music-dir.nix;
}

View file

@ -0,0 +1,11 @@
music_directory "/home/hm-user/Music"
playlist_directory "/home/hm-user/.local/share/mpd/playlists"
db_file "/home/hm-user/.local/share/mpd/tag_cache"
state_file "/home/hm-user/.local/share/mpd/state"
sticker_file "/home/hm-user/.local/share/mpd/sticker.sql"
bind_to_address "127.0.0.1"

View file

@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
with lib;
{
services.mpd.enable = true;
xdg.userDirs.enable = true;
home.stateVersion = "22.11";
test.stubs.mpd = { };
nmt.script = ''
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/mpd.service)
assertFileContent "$serviceFile" ${./basic-configuration.service}
confFile=$(grep -o \
'/nix/store/.*-mpd.conf' \
$TESTED/home-files/.config/systemd/user/mpd.service)
assertFileContent "$confFile" ${./xdg-music-dir.conf}
'';
}

View file

@ -7,6 +7,8 @@
multimediaKeys = true;
};
services.mpd.musicDirectory = "/home/hm-user/music";
test.stubs.mpdris2 = { };
nmt.script = ''

View file

@ -10,6 +10,8 @@
};
};
services.mpd.musicDirectory = "/home/hm-user/music";
test.stubs.mpdris2 = { };
nmt.script = ''