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:
parent
b0247ceedc
commit
5427f3d1f0
10 changed files with 98 additions and 6 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = { };
|
||||
|
||||
|
|
|
|||
24
tests/modules/services/mpd/before-state-version-22_11.nix
Normal file
24
tests/modules/services/mpd/before-state-version-22_11.nix
Normal 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"'
|
||||
'';
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
11
tests/modules/services/mpd/xdg-music-dir.conf
Normal file
11
tests/modules/services/mpd/xdg-music-dir.conf
Normal 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"
|
||||
|
||||
|
||||
|
||||
22
tests/modules/services/mpd/xdg-music-dir.nix
Normal file
22
tests/modules/services/mpd/xdg-music-dir.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
multimediaKeys = true;
|
||||
};
|
||||
|
||||
services.mpd.musicDirectory = "/home/hm-user/music";
|
||||
|
||||
test.stubs.mpdris2 = { };
|
||||
|
||||
nmt.script = ''
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
};
|
||||
};
|
||||
|
||||
services.mpd.musicDirectory = "/home/hm-user/music";
|
||||
|
||||
test.stubs.mpdris2 = { };
|
||||
|
||||
nmt.script = ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue