diff options
Diffstat (limited to 'gnu/services/mcron.scm')
-rw-r--r-- | gnu/services/mcron.scm | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index e907d364da..b56e1e18c2 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -20,8 +20,12 @@ (define-module (gnu services mcron) #:use-module (gnu services) + #:use-module ((gnu services configuration) #:select + (define-configuration/no-serialization)) #:use-module (gnu services shepherd) + #:use-module (gnu system privilege) #:use-module (gnu packages guile-xyz) + #:use-module ((guix packages) #:select (package?)) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) @@ -37,7 +41,12 @@ mcron-configuration-date-format mcron-configuration-home-service? - mcron-service-type)) + mcron-service-type + + cron-daemon-configuration + cron-daemon-configuration-cron + cron-daemon-configuration- + cron-daemon-service-type)) ;;; Commentary: ;;; @@ -182,9 +191,12 @@ files." ;; set a sane value for 'PATH'. #:environment-variables (cons* "GUILE_AUTO_COMPILE=0" - "PATH=/run/current-system/profile/bin" - (remove (cut string-prefix? "PATH=" <>) - (environ))) + #$(if home-service? + '(environ) + '(cons* + "PATH=/run/current-system/profile/bin" + (remove (cut string-prefix? "PATH=" <>) + (environ))))) #:log-file #$log-file)) (stop #~(make-kill-destructor)) @@ -211,4 +223,47 @@ files." jobs))))) (default-value (mcron-configuration)))) ;empty job list + + +(define-configuration/no-serialization cron-daemon-configuration + (cron + (package mcron) + "The cron package to use.") + (monitor-etc? + (boolean #f) + "Whether to check /etc/crontab for updates.")) + +(define (cron-daemon-shepherd-services config) + (list (shepherd-service + (provision '(cron-daemon)) + (start #~(make-forkexec-constructor + '(#$(file-append (cron-daemon-configuration-cron config) + "/sbin/cron") + #$@(if (cron-daemon-configuration-monitor-etc? config) + '() + '("--noetc"))) + #:pid-file "/var/run/cron.pid")) + (stop #~(make-kill-destructor))))) + +(define cron-daemon-activation + (const #~(mkdir-p "/var/cron/tabs"))) + +(define (cron-daemon-setuid-programs config) + (list (privileged-program + (program (file-append (cron-daemon-configuration-cron config) + "/sbin/crontab-access"))))) + +(define cron-daemon-service-type + (service-type (name 'cron-daemon) + (description + "Run the traditional cron daemon.") + (extensions + (list (service-extension shepherd-root-service-type + cron-daemon-shepherd-services) + (service-extension activation-service-type + cron-daemon-activation) + (service-extension privileged-program-service-type + cron-daemon-setuid-programs))) + (default-value (cron-daemon-configuration)))) + ;;; mcron.scm ends here |