diff options
author | Kenny Ballou <kb@devnulllabs.io> | 2024-01-21 18:06:40 -0700 |
---|---|---|
committer | Kenny Ballou <kb@devnulllabs.io> | 2024-01-21 20:08:26 -0700 |
commit | 6dcb2c53a2c8a2b94654755a4162a17c212f6df1 (patch) | |
tree | b1b19a728b8e5ea4ee51fc5e65272c652a36230b | |
parent | a8c88648271f83441f4339692e4309583391c99b (diff) | |
download | dotfiles-6dcb2c53a2c8a2b94654755a4162a17c212f6df1.tar.gz dotfiles-6dcb2c53a2c8a2b94654755a4162a17c212f6df1.tar.xz |
services: mcron: add test mcron service
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
-rw-r--r-- | kbg/services/mcron/snitch.scm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kbg/services/mcron/snitch.scm b/kbg/services/mcron/snitch.scm new file mode 100644 index 00000000..7ffac402 --- /dev/null +++ b/kbg/services/mcron/snitch.scm @@ -0,0 +1,56 @@ +(define-module (kbg services mcron snitch) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (kbg) + #:use-module (guix) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (gnu) + #:use-module (gnu home) + #:use-module (gnu home services) + #:use-module (gnu home services mcron) + #:use-module (gnu services) + #:use-module (gnu services configuration) + #:use-module (gnu packages games) + #:export (snitch-mcron-service-type + snitch-mcron-configuration + snitch-mcron-configuration? + snitch-mcron-configuration-package + snitch-mcron-configuration-schedule)) + +(define (string-or-gexp? obj) + (or (string? obj) (gexp? obj))) + +(define string-list? + (match-lambda + (((? string?) ...) #t) + (_ #f))) + +(define-configuration/no-serialization snitch-mcron-configuration + (package + (file-like cowsay) + "The cowsay package to use.") + (schedule + (string-or-gexp "*/2 * * * *") + "String or G-exp denoting mcron schedule for periodic snitching...")) + +(define (snitch-job configuration) + (match-record configuration <snitch-mcron-configuration> + (package schedule) + (let ((snitch (program-file + "snitch" + #~(begin + (execl #$(file-append package "/bin/cowsay") + "cowsay" + "-f" #$(file-append package "/share/cowsay/cows/dragon.cow")' + "The system is down."))))) + (list #~(job #$schedule #$snitch))))) + +(define snitch-mcron-service-type + (service-type + (name 'snitch-mcron-service) + (extensions + (list (service-extension home-mcron-service-type + snitch-job))) + (description "Test mcron jobs to test mcron") + (default-value (snitch-mcron-configuration)))) |