Simon Tournier wrote 1 years ago
(address . guix-patches@gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
Hi,
In some cases, people have a template configuration, and then another
configuration with some specific ’log-rotation’ files. Then, they want to
custom-merge these configurations. Therefore, they need to access field
values of <rottlog-configuration>.
For one trivial example: replace ’log-rotation’ of syslog defined with
%rotated-files by some others – do not ask why. :-)
Toggle snippet (34 lines)
(use-modules (gnu services base)
(gnu services admin)
(srfi srfi-1))
(define config-template (rottlog-configuration))
(define some-logs
(list (log-rotation
(files '("/var/log/foo"
"/var/log/bar"
"/var/log/baz"))
(frequency 'weekly)
(options `("rotate 16"
"sharedscripts"
,@%default-log-rotation-options)))
(log-rotation
(files '("/var/log/some-evil.log"))
(options `("rotate 4"
,@%default-log-rotation-options)))))
(define other-config (rottlog-configuration
(rotations some-logs)))
(define my-config
(rottlog-configuration
(inherit config-template)
(rotations (filter
(lambda (log)
(not (lset= eq? (log-rotation-files log) %rotated-files)))
(append-map rottlog-configuration-rotations
(list other-config
config-template))))))
Without this patch, it needs to rely on ’@@’ which is not nice.
Toggle snippet (4 lines)
(define rottlog-configuration-rotations
(@@ (gnu services admin) rottlog-rotations))
Therefore, let export them! To stay consistent with the schema for naming,
the accessors are renamed rottlog-configuration-
Cheers,
simon
Simon Tournier (1):
services: admin: Export rottlog-configuration accessors.
gnu/services/admin.scm | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
base-commit: 202c97c4ce2e948266b8b6ee4d80631adbfba92b
--
2.38.1