1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

mpd: specify dependency of service on socket

This allows `systemctl --user restart mpd.socket` to work properly.
This commit is contained in:
novenary 2024-07-02 15:04:26 +03:00 committed by Robert Helgesson
parent 58268b4d77
commit 0a30138c69
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
5 changed files with 61 additions and 4 deletions

View file

@ -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" ];

View file

@ -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;
}

View 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}
'';
}

View 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

View file

@ -0,0 +1,8 @@
[Install]
WantedBy=sockets.target
[Socket]
Backlog=5
KeepAlive=true
ListenStream=127.0.0.1:6600
ListenStream=%t/mpd/socket