nixos-config/machines/chungus/media-curl.nix
Ingolf Wagner 7a6510a4e6
nix fmt
2024-08-29 08:26:04 +07:00

70 lines
1.2 KiB
Nix

{
config,
pkgs,
lib,
...
}:
with lib;
let
configuration = {
#Chaospott37C3Tickets = rec {
# url = "https://md.chaospott.de/171s8-_cQCyX_tUca_Jxqw/download";
# target = "/media/curl/37C3";
# options = [
# "-o $( date +%H:%M:%S )-TicketPlaning.md"
# ];
#};
StableConfussion = {
url = "http://stable-confusion.r/outputs/";
target = "/media/curl/stable-confusion";
options = [
"--mirror"
"--quiet"
];
command = "wget";
};
};
downloadScript =
name:
{
url,
options,
target,
command ? "curl",
}:
pkgs.writers.writeDash "curl-script-${name}" ''
mkdir -p "${target}"
cd "${target}"
${command} ${concatStringsSep " " options} "${url}"
'';
in
{
systemd.services.curl-download = {
after = [ "network.target" ];
path = [
pkgs.curl
pkgs.wget
];
serviceConfig = {
User = "media";
Group = "media";
};
script = (concatStringsSep "\n" (mapAttrsToList downloadScript configuration));
};
systemd.timers.curl-download = {
enable = true;
wantedBy = [ "multi-user.target" ];
timerConfig = {
OnCalendar = "hourly";
Persistent = "true";
};
};
}