50 lines
1 KiB
Nix
50 lines
1 KiB
Nix
{pkgs, ...}: let
|
|
inherit (pkgs) writeShellScriptBin;
|
|
inherit (builtins) toFile;
|
|
|
|
rcloneConfig = toFile "rclone.conf" ''
|
|
[Music]
|
|
type = webdav
|
|
url = https://storage-webdav.owo.monster/MusicRO/
|
|
vendor = other
|
|
'';
|
|
in {
|
|
environment.systemPackages = with pkgs; [
|
|
rclone
|
|
(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"];
|
|
|
|
path = with pkgs; [bash rclone];
|
|
|
|
script = ''
|
|
set -e
|
|
rclone --config ${rcloneConfig} 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";
|
|
};
|
|
};
|
|
}
|