mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
mpd: systemd socket activation
This commit is contained in:
parent
99fbae0ec5
commit
c8746fb588
1 changed files with 27 additions and 3 deletions
|
@ -97,6 +97,13 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
network = {
|
network = {
|
||||||
|
startWhenNeeded = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enable systemd socket activation.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
listenAddress = mkOption {
|
listenAddress = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
@ -143,7 +150,7 @@ in {
|
||||||
Description = "Music Player Daemon";
|
Description = "Music Player Daemon";
|
||||||
};
|
};
|
||||||
|
|
||||||
Install = {
|
Install = mkIf (!cfg.network.startWhenNeeded) {
|
||||||
WantedBy = [ "default.target" ];
|
WantedBy = [ "default.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,6 +161,23 @@ in {
|
||||||
ExecStartPre = ''${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p '${cfg.dataDir}' '${cfg.playlistDirectory}'"'';
|
ExecStartPre = ''${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p '${cfg.dataDir}' '${cfg.playlistDirectory}'"'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.user.sockets.mpd = mkIf cfg.network.startWhenNeeded {
|
||||||
|
Socket = {
|
||||||
|
ListenStream = let
|
||||||
|
listen =
|
||||||
|
if cfg.network.listenAddress == "any"
|
||||||
|
then toString cfg.network.port
|
||||||
|
else "${cfg.network.listenAddress}:${toString cfg.network.port}";
|
||||||
|
in [ listen "%t/mpd/socket" ];
|
||||||
|
|
||||||
|
Backlog = 5;
|
||||||
|
KeepAlive = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sockets.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue