home/mpd: move update-database path unit to separate module
This commit is contained in:
54
home/modules/services/mpd.nix
Normal file
54
home/modules/services/mpd.nix
Normal file
@@ -0,0 +1,54 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.services.mpd;
|
||||
in
|
||||
{
|
||||
options.services.mpd.autoUpdateDatabase = lib.mkEnableOption "watchdog that updates the mpd database upon file changes";
|
||||
|
||||
config = lib.mkIf cfg.autoUpdateDatabase {
|
||||
systemd.user.paths.mpd-update-database = {
|
||||
Install.WantedBy = [ "paths.target" ];
|
||||
Unit = {
|
||||
Description = "Watchdog that updates the mpd database upon file changes";
|
||||
Documentation = [
|
||||
"man:mpd(1)"
|
||||
"man:mpd.conf(5)"
|
||||
];
|
||||
};
|
||||
Path = {
|
||||
PathChanged = [
|
||||
cfg.musicDirectory
|
||||
cfg.playlistDirectory
|
||||
];
|
||||
Unit = "mpd-update-database.service";
|
||||
TriggerLimitIntervalSec = "1s";
|
||||
TriggerLimitBurst = "1";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.mpd-update-database = {
|
||||
Unit = {
|
||||
Description = "Watchdog that updates the mpd library whenever the files are modified";
|
||||
Documentation = [
|
||||
"man:mpd(1)"
|
||||
"man:mpd.conf(5)"
|
||||
];
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${lib.getExe pkgs.mpc-cli} update --wait";
|
||||
|
||||
PrivateUsers = true;
|
||||
ProtectSystem = true;
|
||||
NoNewPrivileges = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectControlGroups = true;
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_UNIX"
|
||||
];
|
||||
RestrictNamespaces = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user