(define-module (buer shepherd-services) #:use-module (guix gexp) #:use-module (gnu services shepherd) #:use-module (shepherd service timer) #:export (guix-gc snapshot-@home timer)) (define timer-trigger-action (shepherd-action (name 'trigger) (procedure #~trigger-timer) (documentation "Trigger the action associated with @var{timer} as if it had reached its next calendar event."))) (define guix-gc (shepherd-service (provision '(guix-gc)) (modules '((shepherd service timer))) (start #~(make-timer-constructor (calendar-event #:days-of-month '(1 15)) (command '("guix" "gc" "--optimize" "--free-space=10G")))) (stop #~(make-timer-destructor)) (actions (list timer-trigger-action)))) (define snapshot-@home (shepherd-service (provision '(snapshot-@home)) (modules '((shepherd service timer))) (start #~(make-timer-constructor (calendar-event #:days-of-month '(1 15)) (lambda () (let ((btrfs "/run/current-system/profile/bin/btrfs") (date (strftime "%Y-%m-%d" (localtime (current-time))))) (spawn-shell-command (string-append btrfs " subvolume snapshot" " /home /snapshots/home/" date)))))) (stop #~(make-timer-destructor)) (actions (list timer-trigger-action)))) (define timer (shepherd-service (provision '(timer)) (modules '((shepherd service timer))) (free-form #~(timer-service))))