commit 4c1e53e287157bbb50eaa7d2e6ed2374294f75b1
parent 76edf9c94b4e15f0f204bb922d9e7d08e07b85bc
Author: breadcat <breadcat@users.noreply.github.com>
Date: Thu, 28 May 2026 16:57:15 +0100
Convert remaining cron jobs into systemd timers and fix environment in places where missing
Diffstat:
7 files changed, 106 insertions(+), 38 deletions(-)
diff --git a/machines/artemis.nix b/machines/artemis.nix
@@ -43,17 +43,6 @@ let machine = "artemis"; in {
boot.initrd = { availableKernelModules = [ "xhci_pci" "virtio_pci" "virtio_scsi" "usbhid" ]; };
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
- # Cron jobs
- services.cron = {
- enable = true;
- systemCronJobs = [
- "*/10 * * * * ${vars.user.username} blog-status"
- "*/10 * * * * ${vars.user.username} magnets"
- "*/10 * * * * ${vars.user.username} stagit-generate"
- "55 23 * * SUN ${vars.user.username} blog-duolingo"
- ];
- };
-
system.stateVersion = "25.05"; # Did you read the comment?
}
\ No newline at end of file
diff --git a/scripts/blog-duolingo.nix b/scripts/blog-duolingo.nix
@@ -25,5 +25,24 @@ let
lastmod "$post_file"
'';
in {
- environment.systemPackages = [blog-duolingo];
+ environment.systemPackages = [ blog-duolingo ];
+
+ systemd.services.blog-duolingo = {
+ description = "Fetch and log Duolingo ranks to blog";
+ serviceConfig = {
+ Type = "oneshot";
+ User = vars.user.username;
+ ExecStart = "${blog-duolingo}/bin/blog-duolingo";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
+ };
+ };
+
+ systemd.timers.blog-duolingo = {
+ description = "Run blog-duolingo every Sunday at 23:55";
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ OnCalendar = "Sun *-*-* 23:55:00";
+ Persistent = true;
+ };
+ };
}
diff --git a/scripts/blog-status.nix b/scripts/blog-status.nix
@@ -2,26 +2,45 @@
let
blog-status = pkgs.writeShellScriptBin "blog-status" ''
- # variables
- status_uptime=$(($(cut -f1 -d. </proc/uptime) / 86400))
- # process
- {
- printf -- "---\\ntitle: Status\\nlayout: single\\n---\\n\\n"
- printf "*Generated on %(%Y-%m-%d at %H:%M)T*\\n\\n" -1
- printf "* Uptime: %s Day%s\\n" "$status_uptime" "$(if (("$status_uptime" > 1)); then echo s; fi)"
- printf "* CPU Load: %s\\n" "$(cut -d" " -f1-3 </proc/loadavg)"
- printf "* Users: %s\\n" "$(who | wc -l)"
- printf "* RAM Usage: %s%%\\n" "$(printf "%.2f" "$(free | awk '/Mem/ {print $3/$2 * 100.0}')")"
- printf "* Root Storage: %s\\n" "$(df / | awk 'END{print $5}')"
- printf "* Tank Storage: %s\\n" "$(df | awk -v tank="/tank" '$0 ~ tank {print $5}')"
- printf "* Torrent Ratio: %s\\n" "$(echo "scale=3; $(awk '/upload/ {print $2}' "$HOME/docker/transmission/stats.json") / $(awk '/download/ {print $2}' "$HOME/docker/transmission/stats.json" | sed 's/,//g')" | ${pkgs.bc}/bin/bc)"
- printf "* NAS Storage: %s\\n" "$(git --git-dir="$HOME/vault/src/logger/.git" show | awk 'END{print $3" "$4}')"
- printf "* [Containers](https://github.com/breadcat/nix-configs/blob/main/common/docker.nix): %s\\n" "$(docker ps -q | wc -l)/$(docker ps -aq | wc -l)"
- printf "* Packages: %s\\n" "$(${pkgs.fastfetch}/bin/fastfetch | awk -F": " '/Packages/ {print $2}')"
- printf "* Monthly Data: %s\\n" "$(vnstat -m --oneline | cut -f11 -d\;)"
- printf "\\nHardware specifications themselves are covered on the [hardware page](/hardware/#server).\\n"
- } >"$HOME/vault/src/blog.${vars.user.domain}/content/status.md"
+ # variables
+ status_uptime=$(($(cut -f1 -d. </proc/uptime) / 86400))
+ # process
+ {
+ printf -- "---\\ntitle: Status\\nlayout: single\\n---\\n\\n"
+ printf "*Generated on %(%Y-%m-%d at %H:%M)T*\\n\\n" -1
+ printf "* Uptime: %s Day%s\\n" "$status_uptime" "$(if (("$status_uptime" > 1)); then echo s; fi)"
+ printf "* CPU Load: %s\\n" "$(cut -d" " -f1-3 </proc/loadavg)"
+ printf "* Users: %s\\n" "$(who | wc -l)"
+ printf "* RAM Usage: %s%%\\n" "$(printf "%.2f" "$(free | awk '/Mem/ {print $3/$2 * 100.0}')")"
+ printf "* Root Storage: %s\\n" "$(df / | awk 'END{print $5}')"
+ printf "* Tank Storage: %s\\n" "$(df | awk -v tank="/tank" '$0 ~ tank {print $5}')"
+ printf "* Torrent Ratio: %s\\n" "$(echo "scale=3; $(awk '/upload/ {print $2}' "$HOME/docker/transmission/stats.json") / $(awk '/download/ {print $2}' "$HOME/docker/transmission/stats.json" | sed 's/,//g')" | ${pkgs.bc}/bin/bc)"
+ printf "* NAS Storage: %s\\n" "$(git --git-dir="$HOME/vault/src/logger/.git" show | awk 'END{print $3" "$4}')"
+ printf "* [Containers](https://github.com/breadcat/nix-configs/blob/main/common/docker.nix): %s\\n" "$(docker ps -q | wc -l)/$(docker ps -aq | wc -l)"
+ printf "* Packages: %s\\n" "$(${pkgs.fastfetch}/bin/fastfetch | awk -F": " '/Packages/ {print $2}')"
+ printf "* Monthly Data: %s\\n" "$(vnstat -m --oneline | cut -f11 -d\;)"
+ printf "\\nHardware specifications themselves are covered on the [hardware page](/hardware/#server).\\n"
+ } >"$HOME/vault/src/blog.${vars.user.domain}/content/status.md"
'';
in {
- environment.systemPackages = [blog-status];
+ environment.systemPackages = [ blog-status ];
+
+ systemd.services.blog-status = {
+ description = "Generate blog status page";
+ serviceConfig = {
+ Type = "oneshot";
+ User = vars.user.username;
+ ExecStart = "${blog-status}/bin/blog-status";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
+ };
+ };
+
+ systemd.timers.blog-status = {
+ description = "Run blog-status every 10 minutes";
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ OnCalendar = "*:0/10";
+ Persistent = true;
+ };
+ };
}
diff --git a/scripts/magnets.nix b/scripts/magnets.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs, vars, ... }:
let
magnets = pkgs.writeShellScriptBin "magnets" ''
@@ -81,4 +81,23 @@ let
'';
in {
environment.systemPackages = [ magnets ];
+
+ systemd.services.magnets = {
+ description = "Process magnet files via aria2";
+ serviceConfig = {
+ Type = "oneshot";
+ User = vars.user.username;
+ ExecStart = "${magnets}/bin/magnets";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
+ };
+ };
+
+ systemd.timers.magnets = {
+ description = "Run magnets every 10 minutes";
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ OnCalendar = "*:0/10";
+ Persistent = true;
+ };
+ };
}
diff --git a/scripts/restic.nix b/scripts/restic.nix
@@ -30,6 +30,7 @@ in {
Type = "oneshot";
User = vars.user.username;
ExecStart = "${backup-cloud}/bin/backup-cloud";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
};
};
diff --git a/scripts/stagit-generate.nix b/scripts/stagit-generate.nix
@@ -1,4 +1,6 @@
-{ pkgs, ...}: let
+{ pkgs, vars, ... }:
+
+let
css = ''
body,pre{font-family:monospace}
#blob,article img{max-width:100%}
@@ -113,7 +115,26 @@ EOF
fi
echo "Summary: Updated $updated_repos repositories, skipped $skipped_repos repositories"
- '';
+ '';
in {
- environment.systemPackages = [stagit-generate];
-}
-\ No newline at end of file
+ environment.systemPackages = [ stagit-generate ];
+
+ systemd.services.stagit-generate = {
+ description = "Regenerate stagit static pages";
+ serviceConfig = {
+ Type = "oneshot";
+ User = vars.user.username;
+ ExecStart = "${stagit-generate}/bin/stagit-generate";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
+ };
+ };
+
+ systemd.timers.stagit-generate = {
+ description = "Run stagit-generate every 10 minutes";
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ OnCalendar = "*:0/10";
+ Persistent = true;
+ };
+ };
+}
diff --git a/scripts/tank-sort.nix b/scripts/tank-sort.nix
@@ -101,6 +101,7 @@ in {
Type = "oneshot";
User = vars.user.username;
ExecStart = "${tank-sort}/bin/tank-sort";
+ Environment = "PATH=/run/current-system/sw/bin:/run/wrappers/bin";
};
};