mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
mpd: specify dependency of service on socket
This allows `systemctl --user restart mpd.socket` to work properly.
This commit is contained in:
parent
58268b4d77
commit
0a30138c69
5 changed files with 61 additions and 4 deletions
|
@ -171,10 +171,17 @@ in {
|
|||
];
|
||||
|
||||
systemd.user.services.mpd = {
|
||||
Unit = {
|
||||
After = [ "network.target" "sound.target" ];
|
||||
Description = "Music Player Daemon";
|
||||
};
|
||||
Unit = mkMerge [
|
||||
{
|
||||
Description = "Music Player Daemon";
|
||||
After = [ "network.target" "sound.target" ];
|
||||
}
|
||||
|
||||
(mkIf cfg.network.startWhenNeeded {
|
||||
Requires = [ "mpd.socket" ];
|
||||
After = [ "mpd.socket" ];
|
||||
})
|
||||
];
|
||||
|
||||
Install = mkIf (!cfg.network.startWhenNeeded) {
|
||||
WantedBy = [ "default.target" ];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
mpd-basic-configuration = ./basic-configuration.nix;
|
||||
mpd-before-state-version-22_11 = ./before-state-version-22_11.nix;
|
||||
mpd-start-when-needed = ./start-when-needed.nix;
|
||||
mpd-xdg-music-dir = ./xdg-music-dir.nix;
|
||||
}
|
||||
|
|
29
tests/modules/services/mpd/start-when-needed.nix
Normal file
29
tests/modules/services/mpd/start-when-needed.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
services.mpd = {
|
||||
enable = true;
|
||||
musicDirectory = "/my/music/dir";
|
||||
extraArgs = [ "--verbose" ];
|
||||
network.startWhenNeeded = true;
|
||||
};
|
||||
|
||||
home.stateVersion = "22.11";
|
||||
|
||||
test.stubs.mpd = { };
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/mpd.service)
|
||||
assertFileContent "$serviceFile" ${./start-when-needed.service}
|
||||
|
||||
socketFile=home-files/.config/systemd/user/mpd.socket
|
||||
assertFileContent "$socketFile" ${./start-when-needed.socket}
|
||||
|
||||
confFile=$(grep -o \
|
||||
'/nix/store/.*-mpd.conf' \
|
||||
$TESTED/home-files/.config/systemd/user/mpd.service)
|
||||
assertFileContent "$confFile" ${./basic-configuration.conf}
|
||||
'';
|
||||
}
|
12
tests/modules/services/mpd/start-when-needed.service
Normal file
12
tests/modules/services/mpd/start-when-needed.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Service]
|
||||
Environment=PATH=/home/hm-user/.nix-profile/bin
|
||||
ExecStart=@mpd@/bin/mpd --no-daemon /nix/store/00000000000000000000000000000000-mpd.conf '--verbose'
|
||||
ExecStartPre=/nix/store/00000000000000000000000000000000-bash/bin/bash -c "/nix/store/00000000000000000000000000000000-coreutils/bin/mkdir -p '/home/hm-user/.local/share/mpd' '/home/hm-user/.local/share/mpd/playlists'"
|
||||
Type=notify
|
||||
|
||||
[Unit]
|
||||
After=network.target
|
||||
After=sound.target
|
||||
After=mpd.socket
|
||||
Description=Music Player Daemon
|
||||
Requires=mpd.socket
|
8
tests/modules/services/mpd/start-when-needed.socket
Normal file
8
tests/modules/services/mpd/start-when-needed.socket
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Install]
|
||||
WantedBy=sockets.target
|
||||
|
||||
[Socket]
|
||||
Backlog=5
|
||||
KeepAlive=true
|
||||
ListenStream=127.0.0.1:6600
|
||||
ListenStream=%t/mpd/socket
|
Loading…
Reference in a new issue