39 lines
868 B
Nix
39 lines
868 B
Nix
{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
|
|
url = https://storage-webdav.owo.monster/MusicRO/
|
|
vendor = nextcloud
|
|
'';
|
|
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";
|
|
};
|
|
};
|
|
}
|