aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorW. Kosior <koszko@koszko.org>2024-05-27 00:52:23 +0200
committerW. Kosior <koszko@koszko.org>2024-09-04 21:02:11 +0200
commit002c21f6c89ee3492683ae76a643faa07f1719d0 (patch)
tree390aa805c30d6770cf832bb9ab7cf26223dd1b81 /gnu/services
parent3cedc097896aaaaaec06244e6b906994774db110 (diff)
downloadguix-002c21f6c89ee3492683ae76a643faa07f1719d0.tar.gz
guix-002c21f6c89ee3492683ae76a643faa07f1719d0.zip
gnu: mcron: Add traditional cron service.
TODO: write good changelog entry Change-Id: Ib1e8f1afcbaae302eac51883e3b02a1d2c32a89e
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/mcron.scm54
1 files changed, 53 insertions, 1 deletions
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 0e0d07d252..a2bc1a5553 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 setuid)
#: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:
;;;
@@ -214,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 (file-like->setuid-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 setuid-program-service-type
+ cron-daemon-setuid-programs)))
+ (default-value (cron-daemon-configuration))))
+
;;; mcron.scm ends here