{ config, pkgs, lib, ... }: with lib; let configuration = { Chaospott37C3Tickets = { url = "https://md.chaospott.de/171s8-_cQCyX_tUca_Jxqw/download"; target = "/media/curl/37C3"; output = "$( date +%H:%M:%S )-TicketPlaning.md"; }; }; downloadScript = name: { url , target , output }: pkgs.writers.writeDash "curl-script-${name}" '' mkdir -p "${target}" curl "${url}" -o "${target}/${output}" ''; in { systemd.services.curl-download = { after = [ "network.target" ]; path = [ pkgs.curl ]; 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"; }; }; }