mpd: systemd socket activation
This commit is contained in:
parent
99fbae0ec5
commit
c8746fb588
|
@ -50,7 +50,7 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
musicDirectory = mkOption {
|
||||
musicDirectory = mkOption {
|
||||
type = with types; either path str;
|
||||
default = "${config.home.homeDirectory}/music";
|
||||
defaultText = "$HOME/music";
|
||||
|
@ -96,7 +96,14 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
network = {
|
||||
network = {
|
||||
startWhenNeeded = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable systemd socket activation.
|
||||
'';
|
||||
};
|
||||
|
||||
listenAddress = mkOption {
|
||||
type = types.str;
|
||||
|
@ -143,7 +150,7 @@ in {
|
|||
Description = "Music Player Daemon";
|
||||
};
|
||||
|
||||
Install = {
|
||||
Install = mkIf (!cfg.network.startWhenNeeded) {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
|
||||
|
@ -154,6 +161,23 @@ in {
|
|||
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