nixfiles/hosts/hetzner-arm/containers/music/profiles/musicSync.nix

56 lines
1.1 KiB
Nix
Raw Normal View History

2024-03-09 22:18:26 +00:00
{
self,
pkgs,
...
}: let
2023-09-18 03:56:58 +01:00
inherit (pkgs) writeShellScriptBin;
inherit (builtins) toFile;
2024-03-09 22:18:26 +00:00
backupSchedules = import "${self}/data/backupSchedules.nix";
2023-09-18 03:56:58 +01:00
rcloneConfig = toFile "rclone.conf" ''
[Music]
type = webdav
url = https://storage-webdav.owo.monster/MusicRO/
vendor = other
'';
in {
environment.systemPackages = with pkgs; [
rclone
2023-09-18 03:56:58 +01:00
(writeShellScriptBin "rclone-music" ''
rclone --config ${rcloneConfig} "$@"
'')
];
systemd.tmpfiles.rules = [
"d /Music - mpd mpd"
];
systemd.services.music-sync = {
wantedBy = ["multi-user.target"];
after = ["network.target"];
partOf = ["mpd.service"];
2023-09-18 03:56:58 +01:00
path = with pkgs; [bash rclone];
script = ''
set -e
2023-09-18 03:56:58 +01:00
rclone --config ${rcloneConfig} sync Music: /Music
chown -R mpd:mpd /Music
'';
};
systemd.timers.music-sync = {
wantedBy = ["timers.target"];
partOf = ["music-sync.service"];
2024-03-09 22:18:26 +00:00
timerConfig = backupSchedules.music;
};
systemd.services.mpd = {
after = ["music-copy.service"];
serviceConfig = {
ReadOnlyPaths = "/Music";
};
};
}