home/mpd: move update-database path unit to separate module
This commit is contained in:
@@ -129,6 +129,7 @@
|
|||||||
nix-index-auto-update-database = ./home/modules/programs/nix-index/auto-update-database.nix;
|
nix-index-auto-update-database = ./home/modules/programs/nix-index/auto-update-database.nix;
|
||||||
direnv-auto-prune = ./home/modules/programs/direnv/auto-prune.nix;
|
direnv-auto-prune = ./home/modules/programs/direnv/auto-prune.nix;
|
||||||
newsboat = ./home/modules/programs/newsboat;
|
newsboat = ./home/modules/programs/newsboat;
|
||||||
|
mpd-auto-updater = ./home/modules/services/mpd.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
|
@@ -54,6 +54,7 @@ in {
|
|||||||
./modules/programs/nix-index/auto-update-database.nix
|
./modules/programs/nix-index/auto-update-database.nix
|
||||||
./modules/programs/direnv/auto-prune.nix
|
./modules/programs/direnv/auto-prune.nix
|
||||||
./modules/programs/newsboat
|
./modules/programs/newsboat
|
||||||
|
./modules/services/mpd.nix
|
||||||
] ++ (optionals graphics [
|
] ++ (optionals graphics [
|
||||||
./config/gtk.nix
|
./config/gtk.nix
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@@ -9,6 +9,8 @@ in
|
|||||||
playlistDirectory = "${cfg.musicDirectory}/playlists/MPD";
|
playlistDirectory = "${cfg.musicDirectory}/playlists/MPD";
|
||||||
network.startWhenNeeded = true;
|
network.startWhenNeeded = true;
|
||||||
|
|
||||||
|
autoUpdateDatabase = true;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
pid_file "/run/user/${toString config.home.uid}/mpd/pid"
|
pid_file "/run/user/${toString config.home.uid}/mpd/pid"
|
||||||
|
|
||||||
@@ -95,47 +97,5 @@ in
|
|||||||
RestrictNamespaces = true;
|
RestrictNamespaces = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.paths.mpd-update-library = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Watchdog that updates the mpd library whenever the files are modified";
|
|
||||||
Documentation = [
|
|
||||||
"man:mpd(1)"
|
|
||||||
"man:mpd.conf(5)"
|
|
||||||
];
|
|
||||||
WantedBy = [ "paths.target" ];
|
|
||||||
};
|
|
||||||
Path = {
|
|
||||||
PathChanged = cfg.musicDirectory;
|
|
||||||
Unit = "mpd-update-library.service";
|
|
||||||
TriggerLimitIntervalSec = "1s";
|
|
||||||
TriggerLimitBurst = "1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.user.services.mpd-update-library = {
|
|
||||||
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