{ pkgs, lib, config, ... }: { imports = [ ./base.nix ]; options.my.units.stream-dl.enable = lib.mkEnableOption "enable"; config = let stream-dl = pkgs.writeScriptBin "stream-dl" (builtins.readFile ../../scripts/stream-dl.sh); in { systemd.user = lib.mkIf config.my.units.stream-dl.enable { services."stream@" = { description = "monitors a stream channel for online streams."; restartIfChanged = true; wantedBy = [ "default.target" ]; path = [ pkgs.nix stream-dl ]; serviceConfig = { Restart = "on-failure"; RestartSec = 30; ExecStart = "${stream-dl}/bin/stream-dl %I"; }; }; timers = let streamTimer = { enable = true; description = "monitors a stream channel for online streams."; wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "5min"; OnUnitActiveSec = "65min"; RandomizedDelaySec = 30; }; }; in { "stream@johnneal911" = streamTimer // { }; "stream@uk2011boy" = streamTimer // { }; "stream@tommy9x6" = streamTimer // { }; "stream@brocollirob" = streamTimer // { }; "stream@tomayto\\x20picarto" = streamTimer // { }; }; }; my.scripts.stream-dl = { enable = lib.mkDefault false; install = true; service = false; name = "stream-dl"; package = stream-dl; }; }; }