mirror of https://codeberg.org/anemofilia/zero
operating-systems: buer: Setup timer-related shepherd-services
parent
101f5404eb
commit
77d40da76f
|
@ -26,7 +26,6 @@
|
|||
#|D|# #:use-module (gnu services dbus)
|
||||
#:use-module (gnu services desktop)
|
||||
#|G|# #:use-module (gnu services guix)
|
||||
#|M|# #:use-module (gnu services mcron)
|
||||
#|L|# #:use-module (gnu services linux)
|
||||
#|N|# #:use-module (gnu services networking)
|
||||
#|P|# #:use-module (gnu services pm)
|
||||
|
@ -81,7 +80,9 @@
|
|||
#:prefix privileged-programs:)
|
||||
#|R|# #:use-module ((buer rules)
|
||||
#:prefix rules:)
|
||||
#|S|# #:use-module ((buer substitute-keys)
|
||||
#|S|# #:use-module ((buer shepherd-services)
|
||||
#:prefix shepherd-service:)
|
||||
#:use-module ((buer substitute-keys)
|
||||
#:prefix substitute-key:)
|
||||
#|U|# #:use-module ((buer users)
|
||||
#:prefix user:)
|
||||
|
@ -175,7 +176,10 @@
|
|||
(operating-system-default-essential-services this-operating-system)
|
||||
(shepherd-root-service-type
|
||||
_ => (shepherd-configuration
|
||||
(shepherd (@ (shepherd-package) shepherd))))))
|
||||
(shepherd (@ (shepherd-package) shepherd))
|
||||
(services (list shepherd-service:guix-gc
|
||||
shepherd-service:snapshot-@home
|
||||
shepherd-service:timer))))))
|
||||
|
||||
#|System services|#
|
||||
(services
|
||||
|
@ -233,12 +237,6 @@
|
|||
"--gc-keep-derivations=yes"
|
||||
"--gc-keep-outputs=yes"))))
|
||||
|
||||
#|Mcron service|#
|
||||
(service mcron-service-type
|
||||
(mcron-configuration
|
||||
(jobs (list #~(job "* * * * Sun"
|
||||
"guix gc --optimize --free-space=10G")))))
|
||||
|
||||
#|Device management services|#
|
||||
(service udev-service-type
|
||||
(udev-configuration
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
(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)))))
|
||||
(system* btrfs "subvolume" "snapshot" "/home"
|
||||
(string-append "/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))))
|
Loading…
Reference in New Issue