* [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service
@ 2024-12-13 22:55 Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:55 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès
Hello Guix!
Shepherd 1.0 provides a bunch of new features, but now we need to
bring them to Guix System and Guix Home.
This patch series focusing on log rotation: (1) using the Shepherd's
log rotation service, (2) getting rid of Rottlog usage and deprecating
it, and (3) adding log rotation for Home.
Since ‘log-rotation’ only exists in version 1.0 of the Shepherd,
reconfiguring a system that runs an older version of shepherd will
warn that “some services could not be upgraded and reboot may be
needed”. If the user chooses not to reboot right away, there are
several possibilities:
• If the mcron service was not unloaded and is still running,
it will run rottlog as before, that’s fine.
• If the mcron service was not unloaded, but the user ran
‘herd restart mcron’, the new mcron will not have Rottlog
among its jobs, so log rotation will no longer happen until
reboot.
• If the mcron service was unloaded (because nothing else in
the new system config needed it), then log rotation will no
longer happen until reboot.
To sum up: worst that can happen is that log rotation stops until
the system is rebooted. (Of course everything is fine if the
machine already runs Shepherd 1.0.)
That seems acceptable to me, though I guess we can wait for two
weeks before pushing this so more people have upgraded to 1.0.
Thoughts?
Ludo’.
Ludovic Courtès (10):
gnu: shepherd@1.0: Add dependency on gzip and zstd.
services: Add ‘log-rotation-service-type’.
services: log-cleanup: Rewrite as a Shepherd timer.
services: unattended-upgrade: Rewrite as a Shepherd timer.
services: Switch from mcron + Rottlog to Shepherd’s log rotation.
services: rottlog: Deprecate.
DRAFT news: Add entry for ‘rottlog-service-type’ deprecation.
home: services: Add log rotation service.
home: Define ‘%base-home-services’.
home: Add log rotation to ‘%base-home-services’.
doc/guix.texi | 119 ++++++++++++++++++--
doc/he-config-bare-bones.scm | 27 ++---
etc/news.scm | 19 ++++
gnu/home.scm | 11 +-
gnu/home/services/admin.scm | 31 ++++++
gnu/local.mk | 1 +
gnu/packages/admin.scm | 14 ++-
gnu/services/admin.scm | 199 +++++++++++++++++++++++++---------
gnu/services/audio.scm | 26 +----
gnu/services/base.scm | 10 +-
gnu/services/cuirass.scm | 27 +----
gnu/services/file-sharing.scm | 6 -
gnu/services/linux.scm | 8 +-
gnu/services/networking.scm | 61 ++---------
gnu/services/web.scm | 17 +--
guix/scripts/home/import.scm | 8 +-
tests/home-import.scm | 40 +++----
17 files changed, 383 insertions(+), 241 deletions(-)
create mode 100644 gnu/home/services/admin.scm
base-commit: 0787a180b3ca64d3958438920ca1b58a2a27fba4
--
2.46.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’ Ludovic Courtès
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Sharlatan Hellseher
* gnu/packages/admin.scm (shepherd-1.0)[arguments]: New field.
[inputs]: New field.
Change-Id: If21f876bbf3fba933a8d997a95db91b961adfca3
---
gnu/packages/admin.scm | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index b1889ceea0..045594bdc7 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -424,7 +424,19 @@ (define-public shepherd-1.0
version ".tar.gz"))
(sha256
(base32
- "0z4yxl8g0k3b6k4x7b3ks10x31hs46j5kmw0ah5cr417n0rszrp8"))))))
+ "0z4yxl8g0k3b6k4x7b3ks10x31hs46j5kmw0ah5cr417n0rszrp8"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments shepherd-0.10)
+ ((#:configure-flags flags #~'())
+ #~(list "--localstatedir=/var"
+
+ ;; Gzip and zstd are used by the log rotation service.
+ (string-append "--with-gzip=" #$(this-package-input "gzip")
+ "/bin/gzip")
+ (string-append "--with-zstd=" #$(this-package-input "zstd")
+ "/bin/zstd")))))
+ (inputs (modify-inputs (package-inputs shepherd-0.10)
+ (append gzip zstd)))))
(define-public shepherd shepherd-0.10)
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer Ludovic Courtès
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Ludovic Courtès, Maxim Cournoyer
* gnu/services/admin.scm (%default-log-rotation-calendar-event): New
variable.
(<log-rotation-configuration>): New record type.
(log-rotation-shepherd-services): New procedure.
(log-rotation-service-type): New variable.
Change-Id: I4400035f3b6065ec147ac932110b690120d739c2
---
doc/guix.texi | 73 +++++++++++++++++++++++++++++++-
gnu/services/admin.scm | 95 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 159 insertions(+), 9 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index a2915de954..89a85961ac 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20766,8 +20766,77 @@ Log Rotation
Log files such as those found in @file{/var/log} tend to grow endlessly,
so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
their contents in separate files, possibly compressed. The @code{(gnu
-services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
-log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
+services admin)} module provides an interface to the log rotation
+service provided by the Shepherd (@pxref{Log Rotation,,, shepherd, The
+GNU Shepherd Manual}).
+
+This log rotation service is made available through
+@code{log-rotation-service-type}, which takes a
+@code{log-rotation-configuration} record has its value. By default,
+this provides @code{log-rotation}, a Shepherd ``timed service'' that
+runs periodically---once a week by default. It automatically knows
+about the log files produced by Shepherd services and can be taught
+about external log files. You can inspect the service and see when it's
+going to run the usual way:
+
+@example
+$ sudo herd status log-rotation
+Status of log-rotation:
+ It is running since Mon 09 Dec 2024 03:27:47 PM CET (2 days ago).
+ @dots{}
+
+Upcoming timer alarms:
+ Sun 15 Dec 2024 10:00:00 PM CET (in 4 days)
+ Sun 22 Dec 2024 10:00:00 PM CET (in 11 days)
+ Sun 29 Dec 2024 10:00:00 PM CET (in 18 days)
+@end example
+
+You can also list files subject to rotation with @command{herd files
+log-rotation} and trigger rotation manually with @command{herd trigger
+log-rotation}.
+
+@defvar log-rotation-service-type
+This is the type of the log rotation service. Its associated value must
+be a @code{log-rotation-configuration} record, as discussed below.
+@end defvar
+
+@deftp {Data Type} log-rotation-configuration
+This data type represents the configuration of the log rotation service.
+Its defaults should be good for most use cases.
+
+@table @asis
+@item @code{calendar-event} (default: every Sunday at 10PM)
+This is a gexp containing the @dfn{calendar event} when log rotation
+occurs. @xref{Timers,,, shepherd, The GNU Shepherd Manual}, for more
+information on calendar events.
+
+@item @code{external-log-files} (default: @code{'()})
+This is a list of file names, external log files that should also be
+rotated.
+
+@item @code{compression} (default: @code{'gzip})
+This is the compression method used for rotated log files, one of
+@code{'none}, @code{'gzip}, and @code{'zstd}.
+
+@item @code{expiry} (default: @code{#~(%default-log-expiry)})
+Age in seconds after which a log file is deleted.
+
+@item @code{size-threshold} @
+ (default: @code{#~(%default-rotation-size-threshold)})
+Size in bytes below which a log file is @emph{not} rotated.
+
+@item @code{provision} (default: @code{'(log-rotation)})
+@itemx @code{requirement} (default: @code{'(user-processes)})
+These are the name(s) and dependencies of the log rotation Shepherd
+service.
+@end table
+@end deftp
+
+@subheading Rottlog
+
+An alternative log rotation service relying on GNU@tie{}Rot[t]log, a log
+rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}), is also
+provided.
This service is part of @code{%base-services}, and thus enabled by
default, with the default settings, for commonly encountered log files.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 24ff659a01..5e1c197d78 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
-;;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
;;;
@@ -39,7 +39,18 @@ (define-module (gnu services admin)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (ice-9 vlist)
- #:export (%default-rotations
+ #:export (log-rotation-configuration
+ log-rotation-configuration?
+ log-rotation-configuration-provision
+ log-rotation-configuration-requirement
+ log-rotation-configuration-calendar-event
+ log-rotation-configuration-external-log-files
+ log-rotation-configuration-compression
+ log-rotation-configuration-expiry
+ log-rotation-configuration-size-threshold
+ log-rotation-service-type
+
+ %default-rotations
%rotated-files
log-rotation
@@ -97,14 +108,84 @@ (define-module (gnu services admin)
;;; Commentary:
;;;
-;;; This module implements configuration of rottlog by writing
-;;; /etc/rottlog/{rc,hourly|daily|weekly}. Example usage
-;;;
-;;; (mcron-service)
-;;; (service rottlog-service-type)
+;;; This module provides basic system administration tools: log rotation,
+;;; unattended upgrades, etc.
;;;
;;; Code:
+\f
+;;;
+;;; Shepherd's log rotation service.
+;;;
+
+(define %default-log-rotation-calendar-event
+ ;; Default calendar event when log rotation is triggered.
+ #~(calendar-event #:minutes '(0)
+ #:hours '(22)
+ #:days-of-week '(sunday)))
+
+(define-record-type* <log-rotation-configuration>
+ log-rotation-configuration make-log-rotation-configuration
+ log-rotation-configuration?
+ (provision log-rotation-configuration-provision (default '(log-rotation)))
+ (requirement log-rotation-configuration-requirement
+ (default (if for-home? '() '(user-processes))))
+ (calendar-event log-rotation-configuration-calendar-event
+ (default %default-log-rotation-calendar-event))
+ (external-log-files log-rotation-configuration-external-log-files
+ (default '()))
+ (compression log-rotation-configuration-compression (default 'gzip))
+ (expiry log-rotation-configuration-expiry
+ (default #~(%default-log-expiry)))
+ (size-threshold log-rotation-configuration-size-threshold
+ (default #~(%default-rotation-size-threshold))))
+
+(define (log-rotation-shepherd-services config)
+ (list (shepherd-service
+ (provision (log-rotation-configuration-provision config))
+ (requirement (log-rotation-configuration-requirement config))
+ (modules '((shepherd service timer) ;for 'calendar-event'
+ (shepherd service log-rotation)))
+ (free-form #~(log-rotation-service
+ #$(log-rotation-configuration-calendar-event config)
+ #:provision
+ '#$(log-rotation-configuration-provision config)
+ #:requirement
+ '#$(log-rotation-configuration-requirement config)
+ #:external-log-files
+ '#$(log-rotation-configuration-external-log-files
+ config)
+ #:compression
+ '#$(log-rotation-configuration-compression config)
+ #:expiry
+ #$(log-rotation-configuration-expiry config)
+ #:rotation-size-threshold
+ #$(log-rotation-configuration-size-threshold
+ config))))))
+
+(define log-rotation-service-type
+ (service-type
+ (name 'log-rotation)
+ (description
+ "Periodically rotate log files using the Shepherd's log rotation service.
+Run @command{herd status log-rotation} to view its status, @command{herd files
+log-rotation} to list files subject to log rotation.")
+ (extensions (list (service-extension shepherd-root-service-type
+ log-rotation-shepherd-services)))
+ (compose concatenate)
+ (extend (lambda (config log-files)
+ (log-rotation-configuration
+ (inherit config)
+ (external-log-files
+ (append (log-rotation-configuration-external-log-files config)
+ log-files)))))
+ (default-value (log-rotation-configuration))))
+
+\f
+;;;
+;;; Rottlog + mcron.
+;;;
+
(define-record-type* <log-rotation> log-rotation make-log-rotation
log-rotation?
(files log-rotation-files) ;list of strings
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’ Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 04/10] services: unattended-upgrade: " Ludovic Courtès
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Ludovic Courtès, Maxim Cournoyer
This is a semi-incompatible change: gexps previously provided in the
‘schedule’ field will no longer work.
* gnu/services/admin.scm (log-cleanup-mcron-jobs): Remove.
(log-cleanup-shepherd-services): New procedure.
(log-cleanup-service-type): Extend SHEPHERD-ROOT-SERVICE-TYPE instead of
MCRON-SERVICE-TYPE.
* doc/guix.texi (Log Rotation): Adjust ‘schedule’ documentation
accordingly.
Change-Id: I2a3beb7dffbc9992b714a29423674db9c7dc6cab
---
doc/guix.texi | 5 +++--
gnu/services/admin.scm | 25 +++++++++++++++++++------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 89a85961ac..e7784404d6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20973,8 +20973,9 @@ Log Rotation
default).
@item @code{schedule} (default: @code{"30 12 01,08,15,22 * *"})
-String or gexp denoting the corresponding mcron job schedule
-(@pxref{Scheduled Job Execution}).
+This is the schedule of the log cleanup job written either a string in
+traditional cron syntax or as a gexp representing a Shepherd calendar
+event (@pxref{Timers,,, shepherd, The GNU Shepherd Manual}).
@end table
@end deftp
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 5e1c197d78..aa1f56e90a 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -349,18 +349,31 @@ (define (log-cleanup-program directory expiry)
(length logs) #$directory)
(for-each delete-file logs))))))
-(define (log-cleanup-mcron-jobs configuration)
+(define (log-cleanup-shepherd-services configuration)
(match-record configuration <log-cleanup-configuration>
- (directory expiry schedule)
- (list #~(job #$schedule
- #$(log-cleanup-program directory expiry)))))
+ (directory expiry schedule)
+ (let ((program (log-cleanup-program directory expiry)))
+ (list (shepherd-service
+ (provision '(log-cleanup))
+ (requirement '(user-processes))
+ (modules '((shepherd service timer)))
+ (start #~(make-timer-constructor
+ #$(if (string? schedule)
+ #~(cron-string->calendar-event #$schedule)
+ schedule)
+ (command '(#$program))))
+ (stop #~(make-timer-destructor))
+ (actions (list (shepherd-action
+ (name 'trigger)
+ (documentation "Trigger log cleanup.")
+ (procedure #~trigger-timer)))))))))
(define log-cleanup-service-type
(service-type
(name 'log-cleanup)
(extensions
- (list (service-extension mcron-service-type
- log-cleanup-mcron-jobs)))
+ (list (service-extension shepherd-root-service-type
+ log-cleanup-shepherd-services)))
(description
"Periodically delete old log files.")))
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 04/10] services: unattended-upgrade: Rewrite as a Shepherd timer.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (2 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Ludovic Courtès, Maxim Cournoyer
This is a semi-incompatible change: gexps previously provided in the
‘schedule’ field will no longer work.
* gnu/services/admin.scm (unattended-upgrade-mcron-jobs): Rename to…
(unattended-upgrade-shepherd-services): … this. Return a list of one
Shepherd service. Remove custom logging and time limitation facilities
from ‘code’.
(unattended-upgrade-service-type): Extend ‘shepherd-root-service-type’
instead of ‘mcron-service-type’.
(<unattended-upgrade-configuration>)[services-to-restart]: Change
default.
* doc/guix.texi (Unattended Upgrades): Adjust ‘schedule’ and
‘services-to-restart’ documentation.
Change-Id: I1b239c5946e71cf9e2af9b24fe4b01366b57fb7a
---
doc/guix.texi | 13 ++++----
gnu/services/admin.scm | 69 +++++++++++++++++++++++-------------------
2 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index e7784404d6..658081a9ed 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -23360,9 +23360,9 @@ Unattended Upgrades
@table @asis
@item @code{schedule} (default: @code{"30 01 * * 0"})
-This is the schedule of upgrades, expressed as a gexp containing an
-mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
-mcron, GNU@tie{}mcron}).
+This is the schedule of upgrades, expressed as a string in traditional
+cron syntax or as a gexp evaluating to a Shepherd calendar event
+(@pxref{Timers,,, shepherd, The GNU Shepherd Manual}).
@item @code{channels} (default: @code{#~%default-channels})
This gexp specifies the channels to use for the upgrade
@@ -23411,7 +23411,7 @@ Unattended Upgrades
rebooting. This means that the value for @code{services-to-restart} is
ignored. The updated services will be started after the system reboots.
-@item @code{services-to-restart} (default: @code{'(mcron)})
+@item @code{services-to-restart} (default: @code{'(unattended-upgrade)})
This field specifies the Shepherd services to restart when the upgrade
completes.
@@ -23426,8 +23426,9 @@ Unattended Upgrades
@xref{Services}, for general information about services. Common
services to restart would include @code{ntpd} and @code{ssh-daemon}.
-By default, the @code{mcron} service is restarted. This ensures that
-the latest version of the unattended upgrade job will be used next time.
+By default, the @code{unattended-upgrade} service is restarted. This
+ensures that the latest version of the unattended upgrade job will be
+used next time.
@item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
This is the expiration time in seconds for system generations. System
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index aa1f56e90a..5fb2fcb6e0 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -517,7 +517,7 @@ (define-record-type* <unattended-upgrade-configuration>
(reboot? unattended-upgrade-configuration-reboot?
(default #f))
(services-to-restart unattended-upgrade-configuration-services-to-restart
- (default '(mcron)))
+ (default '(unattended-upgrade)))
(system-expiration unattended-upgrade-system-expiration
(default (* 3 30 24 3600)))
(maximum-duration unattended-upgrade-maximum-duration
@@ -528,7 +528,7 @@ (define-record-type* <unattended-upgrade-configuration>
(define %unattended-upgrade-log-file
"/var/log/unattended-upgrade.log")
-(define (unattended-upgrade-mcron-jobs config)
+(define (unattended-upgrade-shepherd-services config)
(define channels
(scheme-file "channels.scm"
(unattended-upgrade-configuration-channels config)))
@@ -536,6 +536,9 @@ (define (unattended-upgrade-mcron-jobs config)
(define log
(unattended-upgrade-configuration-log-file config))
+ (define schedule
+ (unattended-upgrade-configuration-schedule config))
+
(define services
(unattended-upgrade-configuration-services-to-restart config))
@@ -562,35 +565,17 @@ (define (unattended-upgrade-mcron-jobs config)
#~(begin
(use-modules (guix build utils)
(gnu services herd)
- (srfi srfi-19)
(srfi srfi-34))
- (define log
- (open-file #$log "a0"))
-
- (define (timestamp)
- (date->string (time-utc->date (current-time time-utc))
- "[~4]"))
-
- (define (alarm-handler . _)
- (format #t "~a time is up, aborting upgrade~%"
- (timestamp))
- (exit 1))
+ (setvbuf (current-output-port) 'line)
+ (setvbuf (current-error-port) 'line)
;; 'guix time-machine' needs X.509 certificates to authenticate the
;; Git host.
(setenv "SSL_CERT_DIR"
#$(file-append nss-certs "/etc/ssl/certs"))
- ;; Make sure the upgrade doesn't take too long.
- (sigaction SIGALRM alarm-handler)
- (alarm #$(unattended-upgrade-maximum-duration config))
-
- ;; Redirect stdout/stderr to LOG to save the output of 'guix' below.
- (redirect-port log (current-output-port))
- (redirect-port log (current-error-port))
-
- (format #t "~a starting upgrade...~%" (timestamp))
+ (format #t "starting upgrade...~%")
(guard (c ((invoke-error? c)
(report-invoke-error c)))
(apply invoke #$(file-append guix "/bin/guix")
@@ -609,23 +594,45 @@ (define (unattended-upgrade-mcron-jobs config)
(unless #$reboot?
;; Rebooting effectively restarts services anyway and execution
;; would be halted here if mcron is restarted.
- (format #t "~a restarting services...~%" (timestamp))
+ (format #t "restarting services...~%")
(for-each restart-service '#$services))
- ;; XXX: If 'mcron' has been restarted, this is not reached.
- (format #t "~a upgrade complete~%" (timestamp))
+ ;; XXX: If this service has been restarted, this is not reached.
+ (format #t "upgrade complete~%")
;; Stopping the root shepherd service triggers a reboot.
(when #$reboot?
- (format #t "~a rebooting system~%" (timestamp))
+ (format #t "rebooting system~%")
(force-output) ;ensure the entire log is written.
(stop-service 'root))))))
(define upgrade
(program-file "unattended-upgrade" code))
- (list #~(job #$(unattended-upgrade-configuration-schedule config)
- #$upgrade)))
+ (list (shepherd-service
+ (provision '(unattended-upgrade))
+ (requirement '(user-processes networking))
+ (modules '((shepherd service timer)))
+ (start #~(make-timer-constructor
+ #$(if (string? schedule)
+ #~(cron-string->calendar-event #$schedule)
+ schedule)
+ (command '(#$upgrade))
+
+ #:log-file #$log
+
+ ;; Make sure the upgrade doesn't take too long.
+ #:max-duration
+ #$(unattended-upgrade-maximum-duration config)
+
+ ;; Wait for the previous attempt to terminate before trying
+ ;; again.
+ #:wait-for-termination? #t))
+ (stop #~(make-timer-destructor))
+ (actions (list (shepherd-action
+ (name 'trigger)
+ (documentation "Trigger unattended system upgrade.")
+ (procedure #~trigger-timer)))))))
(define (unattended-upgrade-log-rotations config)
(list (log-rotation
@@ -636,8 +643,8 @@ (define unattended-upgrade-service-type
(service-type
(name 'unattended-upgrade)
(extensions
- (list (service-extension mcron-service-type
- unattended-upgrade-mcron-jobs)
+ (list (service-extension shepherd-root-service-type
+ unattended-upgrade-shepherd-services)
(service-extension rottlog-service-type
unattended-upgrade-log-rotations)))
(description
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (3 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 04/10] services: unattended-upgrade: " Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 06/10] services: rottlog: Deprecate Ludovic Courtès
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Ludovic Courtès, Maxim Cournoyer
* gnu/services/admin.scm (unattended-upgrade-log-rotations): Remove.
(unattended-upgrade-service-type): Remove ‘rottlog-service-type’
extension.
* gnu/services/audio.scm (mpd-log-rotation): Remove.
(mpd-service-type): Remove ‘rottlog-service-type’ extension.
(mympd-log-rotation): Remove.
(mympd-service-type): Remove rottlog-service-type’ extension.
* gnu/services/base.scm (%guix-publish-log-rotations): Remove.
(guix-publish-service-type): Remove ‘rottlog-service-type’ extension.
(%base-services): Instantiate ‘log-rotation-service-type’ instead of
‘rottlog-service-type’.
* gnu/services/cuirass.scm (cuirass-log-rotations): Remove.
(cuirass-service-type): Remove ‘rottlog-service-type’ extension.
(cuirass-remote-worker-log-rotations): Remove.
(cuirass-remote-worker-service-type): Remove ‘rottlog-service-type’
extension.
* gnu/services/file-sharing.scm (%transmission-daemon-log-rotations):
Remove.
(transmission-daemon-service-type): Remove ‘rottlog-service-type’
extension.
* gnu/services/linux.scm (%earlyoom-log-rotation): Remove.
(earlyoom-service-type): Remove ‘rottlog-service-type’ extension.
* gnu/services/networking.scm (%ntp-log-rotation): Remove.
(ntp-service-type): Remove ‘rottlog-service-type’ extension.
(openntpd-service-type): Likewise.
(%connman-log-rotation): Remove.
(connman-service-type): Remove ‘rottlog-service-type’ extension.
(%hostapd-log-rotation): Remove.
(hostapd-service-type): Remove ‘rottlog-service-type’ extension.
(%pagekite-log-rotation): Remove.
(pagekite-service-type): Remove ‘rottlog-service-type’ extension.
(%yggdrasil-log-rotation): Remove.
(yggdrasil-service-type): Remove ‘rottlog-service-type’ extension.
(%ipfs-log-rotation): Remove.
(ipfs-service-type): Remove ‘rottlog-service-type’ extension.
(%keepalived-log-rotation): Remove.
(keepalived-service-type): Remove ‘rottlog-service-type’ extension.
* gnu/services/web.scm (%hpcguix-web-log-rotations): Remove.
(hpcguix-web-service-type): Remove ‘rottlog-service-type’ extension.
(%mumi-log-rotations): Remove.
(mumi-service-type): Remove ‘rottlog-service-type’ extension.
* doc/guix.texi (Log Rotation): Adjust text regarding which one is in
‘%base-services’.
Change-Id: I8802d4c2337a1e08e3c084d6217f76527d7ee1fb
---
doc/guix.texi | 5 +--
gnu/services/admin.scm | 9 +-----
gnu/services/audio.scm | 26 ++-------------
gnu/services/base.scm | 10 +-----
gnu/services/cuirass.scm | 27 +---------------
gnu/services/file-sharing.scm | 6 ----
gnu/services/linux.scm | 8 +----
gnu/services/networking.scm | 61 +++++------------------------------
gnu/services/web.scm | 17 +---------
9 files changed, 18 insertions(+), 151 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 658081a9ed..952248f2a0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20795,6 +20795,9 @@ Log Rotation
log-rotation} and trigger rotation manually with @command{herd trigger
log-rotation}.
+This service is part of @code{%base-services}, and thus enabled by
+default, with the default settings.
+
@defvar log-rotation-service-type
This is the type of the log rotation service. Its associated value must
be a @code{log-rotation-configuration} record, as discussed below.
@@ -20838,8 +20841,6 @@ Log Rotation
rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}), is also
provided.
-This service is part of @code{%base-services}, and thus enabled by
-default, with the default settings, for commonly encountered log files.
The example below shows how to extend it with an additional
@dfn{rotation}, should you need to do that (usually, services that
produce log files already take care of that):
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 5fb2fcb6e0..7f570f67e4 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -634,19 +634,12 @@ (define (unattended-upgrade-shepherd-services config)
(documentation "Trigger unattended system upgrade.")
(procedure #~trigger-timer)))))))
-(define (unattended-upgrade-log-rotations config)
- (list (log-rotation
- (files
- (list (unattended-upgrade-configuration-log-file config))))))
-
(define unattended-upgrade-service-type
(service-type
(name 'unattended-upgrade)
(extensions
(list (service-extension shepherd-root-service-type
- unattended-upgrade-shepherd-services)
- (service-extension rottlog-service-type
- unattended-upgrade-log-rotations)))
+ unattended-upgrade-shepherd-services)))
(description
"Periodically upgrade the system from the current configuration.")
(default-value (unattended-upgrade-configuration))))
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 5d2cd56a17..6515d53dbd 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -579,17 +579,6 @@ (define (mpd-serialize-configuration configuration)
"mpd.conf"
(serialize-configuration configuration mpd-configuration-fields)))
-(define (mpd-log-rotation config)
- (match-record config <mpd-configuration>
- (log-file)
- (if (string=? "syslog" log-file)
- '() ;nothing to do
- (list (log-rotation
- (files (list log-file))
- (post-rotate #~(begin
- (use-modules (gnu services herd))
- (with-shepherd-action 'mpd ('reopen) #f))))))))
-
(define (mpd-shepherd-service config)
(match-record config <mpd-configuration>
(user package shepherd-requirement
@@ -675,8 +664,7 @@ (define mpd-service-type
(extensions
(list (service-extension shepherd-root-service-type
(compose list mpd-shepherd-service))
- (service-extension account-service-type mpd-accounts)
- (service-extension rottlog-service-type mpd-log-rotation)))
+ (service-extension account-service-type mpd-accounts)))
(default-value (mpd-configuration))))
\f
@@ -953,14 +941,6 @@ (define (mympd-accounts config)
user)))
(list user group))))
-(define (mympd-log-rotation config)
- (match-record config <mympd-configuration>
- (log-to)
- (if (maybe-value-set? log-to)
- (list (log-rotation
- (files (list log-to))))
- '())))
-
(define mympd-service-type
(service-type
(name 'mympd)
@@ -970,8 +950,6 @@ (define mympd-service-type
(service-extension account-service-type
mympd-accounts)
(service-extension special-files-service-type
- mympd-serialize-configuration)
- (service-extension rottlog-service-type
- mympd-log-rotation)))
+ mympd-serialize-configuration)))
(description "Run myMPD, a frontend for MPD. (Music Player Daemon)")
(default-value (mympd-configuration))))
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 6473e1a91a..0a2b7e069d 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2297,12 +2297,6 @@ (define %guix-publish-accounts
(home-directory "/var/empty")
(shell (file-append shadow "/sbin/nologin")))))
-(define %guix-publish-log-rotations
- (list (log-rotation
- (files (list "/var/log/guix-publish.log"))
- (options `("rotate 4" ;don't keep too many of them
- ,@%default-log-rotation-options)))))
-
(define (guix-publish-activation config)
(let ((cache (guix-publish-configuration-cache config)))
(if cache
@@ -2324,8 +2318,6 @@ (define guix-publish-service-type
guix-publish-shepherd-service)
(service-extension account-service-type
(const %guix-publish-accounts))
- (service-extension rottlog-service-type
- (const %guix-publish-log-rotations))
(service-extension activation-service-type
guix-publish-activation)))
(default-value (guix-publish-configuration))
@@ -3679,7 +3671,7 @@ (define %base-services
(service guix-service-type)
(service nscd-service-type)
- (service rottlog-service-type)
+ (service log-rotation-service-type)
;; Periodically delete old build logs.
(service log-cleanup-service-type
diff --git a/gnu/services/cuirass.scm b/gnu/services/cuirass.scm
index cc5cd62672..6643fd2f35 100644
--- a/gnu/services/cuirass.scm
+++ b/gnu/services/cuirass.scm
@@ -331,20 +331,6 @@ (define (cuirass-activation config)
(when #$remote-cache
(chown #$remote-cache uid gid)))))))
-(define (cuirass-log-rotations config)
- "Return the list of log rotations that corresponds to CONFIG."
- (list (log-rotation
- (files (append (list (cuirass-configuration-log-file config)
- (cuirass-configuration-web-log-file config))
- (let ((server
- (cuirass-configuration-remote-server config)))
- (if server
- (list (cuirass-remote-server-log-file server))
- '()))))
- (frequency 'weekly)
- (options `("rotate 40" ;worth keeping
- ,@%default-log-rotation-options)))))
-
(define cuirass-service-type
(service-type
(name 'cuirass)
@@ -352,7 +338,6 @@ (define cuirass-service-type
(list
(service-extension profile-service-type ;for 'info cuirass'
(compose list cuirass-configuration-cuirass))
- (service-extension rottlog-service-type cuirass-log-rotations)
(service-extension activation-service-type cuirass-activation)
(service-extension shepherd-root-service-type cuirass-shepherd-service)
(service-extension account-service-type cuirass-account)
@@ -445,14 +430,6 @@ (define (cuirass-remote-worker-shepherd-service config)
#:log-file #$log-file))
(stop #~(make-kill-destructor))))))
-(define (cuirass-remote-worker-log-rotations config)
- "Return the list of log rotations that corresponds to CONFIG."
- (list (log-rotation
- (files (list (cuirass-remote-worker-log-file config)))
- (frequency 'weekly)
- (options `("rotate 4" ;don't keep too many of them
- ,@%default-log-rotation-options)))))
-
(define cuirass-remote-worker-service-type
(service-type
(name 'cuirass-remote-worker)
@@ -460,8 +437,6 @@ (define cuirass-remote-worker-service-type
(list (service-extension shepherd-root-service-type
cuirass-remote-worker-shepherd-service)
(service-extension account-service-type
- (const %cuirass-remote-worker-accounts))
- (service-extension rottlog-service-type
- cuirass-remote-worker-log-rotations)))
+ (const %cuirass-remote-worker-accounts))))
(description
"Run the Cuirass remote build worker service.")))
diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm
index 75e99f20b7..6b25cd420f 100644
--- a/gnu/services/file-sharing.scm
+++ b/gnu/services/file-sharing.scm
@@ -701,10 +701,6 @@ (define %transmission-daemon-accounts
(shell (file-append shadow "/sbin/nologin"))
(system? #t))))
-(define %transmission-daemon-log-rotations
- (list (log-rotation
- (files (list %transmission-daemon-log-file)))))
-
(define (transmission-daemon-computed-settings-file config)
"Return a @code{computed-file} object that, when unquoted in a G-expression,
produces a Transmission settings file (@file{settings.json}) matching CONFIG."
@@ -785,8 +781,6 @@ (define transmission-daemon-service-type
transmission-daemon-shepherd-service)
(service-extension account-service-type
(const %transmission-daemon-accounts))
- (service-extension rottlog-service-type
- (const %transmission-daemon-log-rotations))
(service-extension activation-service-type
transmission-daemon-activation)))
(default-value (transmission-daemon-configuration))
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index 9955a11e64..e683da6bac 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -181,19 +181,13 @@ (define (earlyoom-shepherd-service config)
#:log-file "/var/log/earlyoom.log"))
(stop #~(make-kill-destructor))))
-(define %earlyoom-log-rotation
- (list (log-rotation
- (files '("/var/log/earlyoom.log")))))
-
(define earlyoom-service-type
(service-type
(name 'earlyoom)
(default-value (earlyoom-configuration))
(extensions
(list (service-extension shepherd-root-service-type
- (compose list earlyoom-shepherd-service))
- (service-extension rottlog-service-type
- (const %earlyoom-log-rotation))))
+ (compose list earlyoom-shepherd-service))))
(description "Run @command{earlyoom}, a daemon that quickly responds to
@acronym{OOM, out-of-memory} conditions by terminating relevant processes.")))
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 76563be14f..44e93ebddf 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -496,11 +496,6 @@ (define dhcpd-service-type
;;; NTP.
;;;
-
-(define %ntp-log-rotation
- (list (log-rotation
- (files '("/var/log/ntpd.log")))))
-
(define ntp-server-types (make-enumeration
'(pool
server
@@ -634,9 +629,7 @@ (define ntp-service-type
(service-extension account-service-type
(const %ntp-accounts))
(service-extension activation-service-type
- ntp-service-activation)
- (service-extension rottlog-service-type
- (const %ntp-log-rotation))))
+ ntp-service-activation)))
(description
"Run the @command{ntpd}, the Network Time Protocol (NTP)
daemon of the @uref{http://www.ntp.org, Network Time Foundation}. The daemon
@@ -745,9 +738,7 @@ (define openntpd-service-type
(service-extension profile-service-type
(compose list openntpd-configuration-openntpd))
(service-extension activation-service-type
- openntpd-service-activation)
- (service-extension rottlog-service-type
- (const %ntp-log-rotation))))
+ openntpd-service-activation)))
(default-value (openntpd-configuration))
(description
"Run the @command{ntpd}, the Network Time Protocol (NTP)
@@ -1699,10 +1690,6 @@ (define (connman-shepherd-service config)
#:log-file "/var/log/connman.log"))
(stop #~(make-kill-destructor)))))))
-(define %connman-log-rotation
- (list (log-rotation
- (files '("/var/log/connman.log")))))
-
(define connman-service-type
(let ((connman-package (compose list connman-configuration-connman)))
(service-type (name 'connman)
@@ -1717,9 +1704,7 @@ (define connman-service-type
connman-activation)
;; Add connman to the system profile.
(service-extension profile-service-type
- connman-package)
- (service-extension rottlog-service-type
- (const %connman-log-rotation))))
+ connman-package)))
(default-value (connman-configuration))
(description
"Run @url{https://01.org/connman,Connman},
@@ -1960,18 +1945,12 @@ (define* (hostapd-shepherd-services config #:key (requirement '()))
#:log-file "/var/log/hostapd.log"))
(stop #~(make-kill-destructor)))))
-(define %hostapd-log-rotation
- (list (log-rotation
- (files '("/var/log/hostapd.log")))))
-
(define hostapd-service-type
(service-type
(name 'hostapd)
(extensions
(list (service-extension shepherd-root-service-type
- hostapd-shepherd-services)
- (service-extension rottlog-service-type
- (const %hostapd-log-rotation))))
+ hostapd-shepherd-services)))
(description
"Run the @uref{https://w1.fi/hostapd/, hostapd} daemon for Wi-Fi access
points and authentication servers.")))
@@ -2271,10 +2250,6 @@ (define (pagekite-shepherd-service config)
;; SIGTERM doesn't always work for some reason.
(stop #~(make-kill-destructor SIGINT))))))
-(define %pagekite-log-rotation
- (list (log-rotation
- (files '("/var/log/pagekite.log")))))
-
(define %pagekite-accounts
(list (user-group (name "pagekite") (system? #t))
(user-account
@@ -2293,9 +2268,7 @@ (define pagekite-service-type
(list (service-extension shepherd-root-service-type
(compose list pagekite-shepherd-service))
(service-extension account-service-type
- (const %pagekite-accounts))
- (service-extension rottlog-service-type
- (const %pagekite-log-rotation))))
+ (const %pagekite-accounts))))
(description
"Run @url{https://pagekite.net/,PageKite}, a tunneling solution to make
local servers publicly accessible on the web, even behind NATs and firewalls.")))
@@ -2386,10 +2359,6 @@ (define (yggdrasil-shepherd-service config)
#:group "yggdrasil"))
(stop #~(make-kill-destructor)))))
-(define %yggdrasil-log-rotation
- (list (log-rotation
- (files '("/var/log/yggdrasil.log")))))
-
(define %yggdrasil-accounts
(list (user-group (name "yggdrasil") (system? #t))))
@@ -2405,9 +2374,7 @@ (define yggdrasil-service-type
(service-extension account-service-type
(const %yggdrasil-accounts))
(service-extension profile-service-type
- (compose list yggdrasil-configuration-package))
- (service-extension rottlog-service-type
- (const %yggdrasil-log-rotation))))))
+ (compose list yggdrasil-configuration-package))))))
\f
;;;
@@ -2477,10 +2444,6 @@ (define (ipfs-shepherd-service config)
#:environment-variables #$%ipfs-environment))
(stop #~(make-kill-destructor)))))
-(define %ipfs-log-rotation
- (list (log-rotation
- (files '("/var/log/ipfs.log")))))
-
(define (%ipfs-activation config)
"Return an activation gexp for IPFS with CONFIG"
(define (exec-command . args)
@@ -2536,9 +2499,7 @@ (define ipfs-service-type
(service-extension activation-service-type
%ipfs-activation)
(service-extension shepherd-root-service-type
- ipfs-shepherd-service)
- (service-extension rottlog-service-type
- (const %ipfs-log-rotation))))
+ ipfs-shepherd-service)))
(default-value (ipfs-configuration))
(description
"Run @command{ipfs daemon}, the reference implementation
@@ -2574,16 +2535,10 @@ (define (keepalived-shepherd-service config)
(respawn? #f)
(stop #~(make-kill-destructor))))))
-(define %keepalived-log-rotation
- (list (log-rotation
- (files '("/var/log/keepalived.log")))))
-
(define keepalived-service-type
(service-type (name 'keepalived)
(extensions (list (service-extension shepherd-root-service-type
- keepalived-shepherd-service)
- (service-extension rottlog-service-type
- (const %keepalived-log-rotation))))
+ keepalived-shepherd-service)))
(description
"Run @uref{https://www.keepalived.org/, Keepalived}
routing software.")))
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 3997fe2ab8..c6b2b7fc23 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -1245,11 +1245,6 @@ (define %hpcguix-web-activation
(define %hpcguix-web-log-file
"/var/log/hpcguix-web.log")
-(define %hpcguix-web-log-rotations
- (list (log-rotation
- (files (list %hpcguix-web-log-file))
- (frequency 'weekly))))
-
(define (hpcguix-web-shepherd-service config)
(let* ((specs (hpcguix-web-configuration-specs config))
(config-file (and specs (scheme-file "hpcguix-web.scm" specs)))
@@ -1287,8 +1282,6 @@ (define hpcguix-web-service-type
(const %hpcguix-web-accounts))
(service-extension activation-service-type
(const %hpcguix-web-activation))
- (service-extension rottlog-service-type
- (const %hpcguix-web-log-rotations))
(service-extension shepherd-root-service-type
(compose list hpcguix-web-shepherd-service))))
(default-value (hpcguix-web-configuration))))
@@ -2084,12 +2077,6 @@ (define (mumi-shepherd-services config)
#:log-file #$%mumi-mailer-log))
(stop #~(make-kill-destructor)))))))
-(define %mumi-log-rotations
- (list (log-rotation
- (files (list %mumi-log
- %mumi-mailer-log
- %mumi-worker-log)))))
-
(define mumi-service-type
(service-type
(name 'mumi)
@@ -2099,9 +2086,7 @@ (define mumi-service-type
(service-extension account-service-type
(const %mumi-accounts))
(service-extension shepherd-root-service-type
- mumi-shepherd-services)
- (service-extension rottlog-service-type
- (const %mumi-log-rotations))))
+ mumi-shepherd-services)))
(description
"Run Mumi, a Web interface to the Debbugs bug-tracking server.")
(default-value
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 06/10] services: rottlog: Deprecate.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (4 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Ludovic Courtès, Maxim Cournoyer
* gnu/services/admin.scm (rottlog-service-type): Deprecate.
* doc/guix.texi (Log Rotation): Add deprecation warning.
Change-Id: I661666ff3de64a69ff4f4982d7f432fd575c36df
---
doc/guix.texi | 7 +++++++
gnu/services/admin.scm | 5 ++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 952248f2a0..1df1ccc649 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20841,6 +20841,13 @@ Log Rotation
rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}), is also
provided.
+@quotation Warning
+The Rottlog service presented here is deprecated in favor of
+@code{log-rotation-service-type} (see above). The
+@code{rottlog-service-type} variable and related tools will be removed
+after 2025-05-15.
+@end quotation
+
The example below shows how to extend it with an additional
@dfn{rotation}, should you need to do that (usually, services that
produce log files already take care of that):
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 7f570f67e4..5d585959a0 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -32,6 +32,7 @@ (define-module (gnu services admin)
#:use-module (gnu system accounts)
#:use-module ((gnu system shadow) #:select (account-service-type))
#:use-module ((guix store) #:select (%store-prefix))
+ #:use-module (guix deprecation)
#:use-module (guix gexp)
#:use-module (guix modules)
#:use-module (guix packages)
@@ -298,7 +299,9 @@ (define (rottlog-jobs-or-default config)
(or (rottlog-configuration-jobs config)
(default-jobs (rottlog-configuration-rottlog config))))
-(define rottlog-service-type
+;; TODO: Deprecated; remove sometime after 2025-05-15.
+(define-deprecated rottlog-service-type
+ log-rotation-service-type
(service-type
(name 'rottlog)
(description
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (5 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 06/10] services: rottlog: Deprecate Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 08/10] home: services: Add log rotation service Ludovic Courtès
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès, Florian Pelz, Julien Lepiller
* etc/news.scm: Add entry.
Change-Id: I46ccddf4216b4c46ec417692c832b2e37a3669a0
---
etc/news.scm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/etc/news.scm b/etc/news.scm
index 0628b0fdb4..101f390ed2 100644
--- a/etc/news.scm
+++ b/etc/news.scm
@@ -34,6 +34,25 @@
(channel-news
(version 0)
+
+ (entry (commit "FIXME")
+ (title
+ (en "Rottlog service replaced by new log rotation service"))
+ (body
+ (en "A noticeable change was made that impacts all Guix System users:
+the Rottlog service was replaced by the new log rotation service.
+Additionally, @code{rottlog-service-type} is now deprecated in favor of
+@code{log-rotation-service-type} and will be removed in six months, in
+accordance with the project's deprecation policy.
+
+The new @code{log-rotation-service-type} builds upon the log rotation service
+provided by version 1.0 of the Shepherd. It is more flexible and easier to
+use. Run @command{info \"(guix) Log Rotation\"}, for more info.
+
+Because the new log rotation service depends on Shepherd 1.0 functionality,
+you will need to reboot after reconfiguring if you are not running Shepherd
+1.0 yet.")))
+
(entry (commit "ccf72d5074b0c5ba793e686cbb1d6eaad39824bf")
(title
(de "Neues Format @samp{appimage} für den Befehl @command{guix pack}")
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 08/10] home: services: Add log rotation service.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (6 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’ Ludovic Courtès
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès
* gnu/home/services/admin.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* doc/guix.texi (Shepherd Home Service): Document it.
Change-Id: I37ac171147c236b05d6d3b226e9072ab7524dfe9
---
doc/guix.texi | 15 +++++++++++++++
gnu/home/services/admin.scm | 31 +++++++++++++++++++++++++++++++
gnu/local.mk | 1 +
3 files changed, 47 insertions(+)
create mode 100644 gnu/home/services/admin.scm
diff --git a/doc/guix.texi b/doc/guix.texi
index 1df1ccc649..788a9b4957 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20803,6 +20803,7 @@ Log Rotation
be a @code{log-rotation-configuration} record, as discussed below.
@end defvar
+@anchor{log-rotation-configuration}
@deftp {Data Type} log-rotation-configuration
This data type represents the configuration of the log rotation service.
Its defaults should be good for most use cases.
@@ -46587,6 +46588,20 @@ Shepherd Home Service
@end table
@end deftp
+@cindex log rotation, for user services
+The Shepherd also comes with a @dfn{log rotation service}, which
+compresses and then deletes old log files produced by services and
+daemons that it runs. This service is made available through
+@code{home-log-rotation-service-type} as described below.
+
+@defvar home-log-rotation-service-type
+This is the service type for the user Shepherd log rotation service
+(@pxref{Log Rotation Service,,, shepherd, The GNU Shepherd Manual}).
+Its value must be a @code{log-rotation-configuration} record, exactly as
+for its system-wide counterpart. @xref{log-rotation-configuration}, for
+its reference.
+@end defvar
+
@node Secure Shell
@subsection Secure Shell
diff --git a/gnu/home/services/admin.scm b/gnu/home/services/admin.scm
new file mode 100644
index 0000000000..1cd398cc51
--- /dev/null
+++ b/gnu/home/services/admin.scm
@@ -0,0 +1,31 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home services admin)
+ #:use-module (gnu home services)
+ #:use-module (gnu services)
+ #:use-module (gnu services admin)
+ ;; For the 'home-shepherd-service-type' mapping.
+ #:use-module (gnu home services shepherd)
+ #:export (home-log-rotation-service-type)
+ #:re-export (log-rotation-configuration))
+
+(define home-log-rotation-service-type
+ (service-type
+ (inherit (system->home-service-type log-rotation-service-type))
+ (default-value (for-home (log-rotation-configuration)))))
diff --git a/gnu/local.mk b/gnu/local.mk
index 39b142af5a..d96fa61dc4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -100,6 +100,7 @@ GNU_SYSTEM_MODULES = \
%D%/compression.scm \
%D%/home.scm \
%D%/home/services.scm \
+ %D%/home/services/admin.scm \
%D%/home/services/desktop.scm \
%D%/home/services/dict.scm \
%D%/home/services/dotfiles.scm \
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (7 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 08/10] home: services: Add log rotation service Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
2024-12-13 23:20 ` [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès
* gnu/home.scm (%base-home-services): New variable.
(<home-environment>)[services]: Change default to ‘%base-home-services’.
* guix/scripts/home/import.scm (manifest+configuration-files->code): Use
‘%base-home-services’ by default.
* tests/home-import.scm (match-home-environment-no-services)
(match-home-environment-transformations)
(match-home-environment-no-services-nor-packages)
(match-home-environment-bash-service)
(match-home-environment-bash-service-with-alias): Adjust accordingly.
* doc/he-config-bare-bones.scm: Use ‘%base-home-services’.
* doc/guix.texi (Declaring the Home Environment): Add index entry for
‘%base-home-services’.
Change-Id: Id95ede62b97a976aad138bfc4b63fc0bdf37c7de
---
doc/guix.texi | 1 +
doc/he-config-bare-bones.scm | 27 ++++++++++++------------
gnu/home.scm | 11 ++++++++--
guix/scripts/home/import.scm | 8 +++++---
tests/home-import.scm | 40 +++++++++++++++++++-----------------
5 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 788a9b4957..adcae42523 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -45563,6 +45563,7 @@ Declaring the Home Environment
@end quotation
@findex home-environment
+@vindex %base-home-services
@lisp
@include he-config-bare-bones.scm
@end lisp
diff --git a/doc/he-config-bare-bones.scm b/doc/he-config-bare-bones.scm
index f948d85277..844d666110 100644
--- a/doc/he-config-bare-bones.scm
+++ b/doc/he-config-bare-bones.scm
@@ -7,19 +7,20 @@
(home-environment
- (packages (list htop))
- (services
- (list
- (service home-bash-service-type
- (home-bash-configuration
- (guix-defaults? #t)
- (bash-profile (list (plain-file "bash-profile" "\
+ (packages (list htop))
+ (services
+ (append (list
+ (service home-bash-service-type
+ (home-bash-configuration
+ (guix-defaults? #t)
+ (bash-profile (list (plain-file "bash-profile" "\
export HISTFILE=$XDG_CACHE_HOME/.bash_history")))))
- (simple-service 'test-config
- home-xdg-configuration-files-service-type
- (list `("test.conf"
- ,(plain-file "tmp-file.txt"
- "the content of
- ~/.config/test.conf")))))))
+ (simple-service 'test-config
+ home-xdg-configuration-files-service-type
+ (list `("test.conf"
+ ,(plain-file "tmp-file.txt"
+ "the content of
+ ~/.config/test.conf")))))
+ %base-home-services)))
diff --git a/gnu/home.scm b/gnu/home.scm
index b390c8d534..042d2e67de 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -23,6 +23,7 @@ (define-module (gnu home)
#:use-module (gnu home services shells)
#:use-module (gnu home services xdg)
#:use-module (gnu home services fontutils)
+ #:use-module (gnu home services admin)
#:use-module (gnu services)
#:use-module (guix records)
#:use-module (guix diagnostics)
@@ -43,7 +44,9 @@ (define-module (gnu home)
home-environment-with-provenance
- home-generation-base))
+ home-generation-base
+
+ %base-home-services))
;;; Comment:
;;;
@@ -67,7 +70,7 @@ (define-record-type* <home-environment> home-environment
this-home-environment)))
(services home-environment-user-services
- (default '())
+ (default %base-home-services)
(sanitize validate-service-list))
(location home-environment-location ; <location>
@@ -75,6 +78,10 @@ (define-record-type* <home-environment> home-environment
source-properties->location))
(innate)))
+(define %base-home-services
+ ;; Non-essential but useful services to have by default.
+ '())
+
(define (home-environment-default-essential-services he)
"Return the list of essential services for home environment."
(list
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index fd263c0699..15b4bc9798 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
-;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021-2022, 2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Arjan Adriaanse <arjan@adriaan.se>
;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
;;;
@@ -160,7 +160,8 @@ (define (manifest+configuration-files->code manifest
(home-environment
(packages ,packages)
- (services (list ,@services)))))))
+ (services (append (list ,@services)
+ %base-home-services)))))))
(('begin ('specifications->manifest packages))
(match (configurations+modules configuration-directory)
(((services . modules) ...)
@@ -183,7 +184,8 @@ (define (manifest+configuration-files->code manifest
,(comment (G_ "\
;; Below is the list of Home services. To search for available
;; services, run 'guix home search KEYWORD' in a terminal.\n"))
- (services (list ,@services)))))))))
+ (services (append (list ,@services)
+ %base-home-services)))))))))
(define* (import-manifest
manifest destination-directory
diff --git a/tests/home-import.scm b/tests/home-import.scm
index 04b7b76156..57a3d62a72 100644
--- a/tests/home-import.scm
+++ b/tests/home-import.scm
@@ -115,7 +115,7 @@ (define-home-environment-matcher match-home-environment-no-services
('specifications->packages
('list "guile@2.0.9" "gcc:lib" "glibc@2.19")))
('services
- ('list)))))
+ ('append ('list) '%base-home-services)))))
(define-home-environment-matcher match-home-environment-transformations
('begin
@@ -131,7 +131,7 @@ (define-home-environment-matcher match-home-environment-transformations
('list (transform ('specification->package "guile@2.0.9"))
('list ('specification->package "gcc") "lib")
('specification->package "glibc@2.19")))
- ('services ('list)))))
+ ('services ('append ('list) '%base-home-services)))))
(define-home-environment-matcher match-home-environment-no-services-nor-packages
('begin
@@ -143,7 +143,7 @@ (define-home-environment-matcher match-home-environment-no-services-nor-packages
('packages
('specifications->packages ('list)))
('services
- ('list)))))
+ ('append ('list) '%base-home-services)))))
(define-home-environment-matcher match-home-environment-bash-service
('begin
@@ -157,13 +157,14 @@ (define-home-environment-matcher match-home-environment-bash-service
('packages
('specifications->packages ('list)))
('services
- ('list ('service
- 'home-bash-service-type
- ('home-bash-configuration
- ('aliases ('quote ()))
- ('bashrc
- ('list ('local-file "/tmp/guix-config/.bashrc"
- "bashrc"))))))))))
+ (append ('list ('service
+ 'home-bash-service-type
+ ('home-bash-configuration
+ ('aliases ('quote ()))
+ ('bashrc
+ ('list ('local-file "/tmp/guix-config/.bashrc"
+ "bashrc"))))))
+ '%base-home-services)))))
(define-home-environment-matcher match-home-environment-bash-service-with-alias
('begin
@@ -177,15 +178,16 @@ (define-home-environment-matcher match-home-environment-bash-service-with-alias
('packages
('specifications->packages ('list)))
('services
- ('list ('service
- 'home-bash-service-type
- ('home-bash-configuration
- ('aliases
- ('quote (("grep" . "grep --exclude-from=\"$HOME/.grep-exclude\"")
- ("ls" . "ls -p"))))
- ('bashrc
- ('list ('local-file "/tmp/guix-config/.bashrc"
- "bashrc"))))))))))
+ ('append ('list ('service
+ 'home-bash-service-type
+ ('home-bash-configuration
+ ('aliases
+ ('quote (("grep" . "grep --exclude-from=\"$HOME/.grep-exclude\"")
+ ("ls" . "ls -p"))))
+ ('bashrc
+ ('list ('local-file "/tmp/guix-config/.bashrc"
+ "bashrc"))))))
+ '%base-home-services)))))
(test-assert "manifest->code: No services"
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’.
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (8 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’ Ludovic Courtès
@ 2024-12-13 22:58 ` Ludovic Courtès
2024-12-13 23:20 ` [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 22:58 UTC (permalink / raw)
To: 74860; +Cc: Ludovic Courtès
* gnu/home.scm (%base-home-services): Add instance of
‘home-log-rotation-service-type’.
* doc/guix.texi (Shepherd Home Service): Document it.
Change-Id: I00a98da100e3a07fe409f3c44d8ab88e743a8e3e
---
doc/guix.texi | 2 ++
gnu/home.scm | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index adcae42523..ddb38a8040 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -46601,6 +46601,8 @@ Shepherd Home Service
Its value must be a @code{log-rotation-configuration} record, exactly as
for its system-wide counterpart. @xref{log-rotation-configuration}, for
its reference.
+
+This service is part of @code{%base-home-services}.
@end defvar
@node Secure Shell
diff --git a/gnu/home.scm b/gnu/home.scm
index 042d2e67de..3b479f64f9 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -80,7 +80,7 @@ (define-record-type* <home-environment> home-environment
(define %base-home-services
;; Non-essential but useful services to have by default.
- '())
+ (list (service home-log-rotation-service-type)))
(define (home-environment-default-essential-services he)
"Return the list of essential services for home environment."
--
2.46.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
` (9 preceding siblings ...)
2024-12-13 22:58 ` [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
@ 2024-12-13 23:20 ` Ludovic Courtès
10 siblings, 0 replies; 12+ messages in thread
From: Ludovic Courtès @ 2024-12-13 23:20 UTC (permalink / raw)
To: 74860
Cc: paren, Janneke Nieuwenhuizen, Tanguy Le Carrour, Maxim Cournoyer,
Andrew Tropin
I should point out that I’d particular like feedback on these:
> home: Define ‘%base-home-services’.
> home: Add log rotation to ‘%base-home-services’.
Adding ‘%base-home-services’ is a simple change but it has long-term
implications.
Ludo’.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-12-13 23:22 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 22:55 [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 01/10] gnu: shepherd@1.0: Add dependency on gzip and zstd Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 02/10] services: Add ‘log-rotation-service-type’ Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 03/10] services: log-cleanup: Rewrite as a Shepherd timer Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 04/10] services: unattended-upgrade: " Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 05/10] services: Switch from mcron + Rottlog to Shepherd’s log rotation Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 06/10] services: rottlog: Deprecate Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 07/10] DRAFT news: Add entry for ‘rottlog-service-type’ deprecation Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 08/10] home: services: Add log rotation service Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 09/10] home: Define ‘%base-home-services’ Ludovic Courtès
2024-12-13 22:58 ` [bug#74860] [PATCH 10/10] home: Add log rotation to ‘%base-home-services’ Ludovic Courtès
2024-12-13 23:20 ` [bug#74860] [PATCH 00/10] Using the Shepherd's log rotation service Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).