2022-12-24 17:16:39 +00:00
|
|
|
{pkgs, ...}: {
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /Music - mpd mpd"
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.services.music-sync = {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
after = ["network.target"];
|
|
|
|
partOf = ["mpd.service"];
|
|
|
|
|
|
|
|
path = with pkgs; [bash rclone mount umount];
|
|
|
|
script = let
|
|
|
|
rclone_config = pkgs.writeText "rclone.conf" ''
|
|
|
|
[Music]
|
|
|
|
type = webdav
|
2023-01-07 11:59:13 +00:00
|
|
|
url = https://storage-webdav.owo.monster/MusicRO/
|
2023-07-21 13:16:25 +01:00
|
|
|
vendor = other
|
2022-12-24 17:16:39 +00:00
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
set -e
|
|
|
|
rclone --config ${rclone_config} sync Music: /Music
|
|
|
|
chown -R mpd:mpd /Music
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.timers.music-sync = {
|
|
|
|
wantedBy = ["timers.target"];
|
|
|
|
partOf = ["music-sync.service"];
|
|
|
|
timerConfig.OnCalendar = "hourly";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.mpd = {
|
|
|
|
after = ["music-copy.service"];
|
|
|
|
serviceConfig = {
|
|
|
|
ReadOnlyPaths = "/Music";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|