me
/
guix
Archived
1
0
Fork 0

services: replace bare serializers with (serializer ...)

* gnu/home/services/shells.scm
(home-zsh-configuration)[environment-variables]: Use (serializer ...).
(home-bash-configuration)[aliases, environment-variables]: Likewise.
(home-fish-configuration)[abbreviations, aliases]
[environment-variables]: Likewise.
* gnu/services/audio.scm (mpd-configuration)[music-dir, playlist-dir]
[endpoints, address, inputs, archive-plugins, input-cache-size]
[decoders, filters, playlist-plugins]: Likewise.
* gnu/services/linux.scm (fstrim-configuration)[extra-arguments]:
Likewise.
* gnu/services/security.scm (fail2ban-jail-configuration)[backend]
[log-encoding, extra-content]: Likewise.
* tests/services/configuration.scm: Update tests.
("serialize-configuration [deprecated]"): New test.

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
master
Bruno Victal 2023-03-26 19:41:30 +01:00 committed by Liliana Marie Prikler
parent 6f48efa9b8
commit 0fbb356714
No known key found for this signature in database
GPG Key ID: 442A84B8C70E2F87
5 changed files with 46 additions and 35 deletions

View File

@ -133,7 +133,7 @@ Shell startup process will continue with
(environment-variables
(alist '())
"Association list of environment variables to set for the Zsh session."
serialize-posix-env-vars)
(serializer serialize-posix-env-vars))
(zshenv
(text-config '())
"List of file-like objects, which will be added to @file{.zshenv}.
@ -334,7 +334,7 @@ source ~/.profile
rules for the @code{home-environment-variables-service-type} apply
here (@pxref{Essential Home Services}). The contents of this field will be
added after the contents of the @code{bash-profile} field."
serialize-posix-env-vars)
(serializer serialize-posix-env-vars))
(aliases
(alist '())
"Association list of aliases to set for the Bash session. The aliases will be
@ -351,7 +351,7 @@ turns into
@example
alias ls=\"ls -alF\"
@end example"
bash-serialize-aliases)
(serializer bash-serialize-aliases))
(bash-profile
(text-config '())
"List of file-like objects, which will be added to @file{.bash_profile}.
@ -536,19 +536,19 @@ with text blocks from other extensions and the base service."))
(environment-variables
(alist '())
"Association list of environment variables to set in Fish."
serialize-fish-env-vars)
(serializer serialize-fish-env-vars))
(aliases
(alist '())
"Association list of aliases for Fish, both the key and the value
should be a string. An alias is just a simple function that wraps a
command, If you want something more akin to @dfn{aliases} in POSIX
shells, see the @code{abbreviations} field."
serialize-fish-aliases)
(serializer serialize-fish-aliases))
(abbreviations
(alist '())
"Association list of abbreviations for Fish. These are words that,
when typed in the shell, will automatically expand to the full text."
serialize-fish-abbreviations))
(serializer serialize-fish-abbreviations)))
(define (fish-files-service config)
`(("fish/config.fish"

View File

@ -370,7 +370,7 @@ Available values: @code{notice}, @code{info}, @code{verbose},
(music-dir ; TODO: deprecated, remove later
maybe-string
"The directory to scan for music files."
mpd-serialize-deprecated-field)
(serializer mpd-serialize-deprecated-field))
(playlist-directory
maybe-string
@ -379,7 +379,7 @@ Available values: @code{notice}, @code{info}, @code{verbose},
(playlist-dir ; TODO: deprecated, remove later
maybe-string
"The directory to store playlists."
mpd-serialize-deprecated-field)
(serializer mpd-serialize-deprecated-field))
(db-file
maybe-string
@ -405,16 +405,17 @@ IPv6 addresses must be enclosed in square brackets when a different
port is used.
To use a Unix domain socket, an absolute path or a path starting with @code{~}
can be specified here."
(lambda (_ endpoints)
(if (maybe-value-set? endpoints)
(mpd-serialize-list-of-strings "bind_to_address" endpoints)
"")))
(serializer
(lambda (_ endpoints)
(if (maybe-value-set? endpoints)
(mpd-serialize-list-of-strings "bind_to_address" endpoints)
""))))
(address ; TODO: deprecated, remove later
maybe-string
"The address that mpd will bind to.
To use a Unix domain socket, an absolute path can be specified here."
mpd-serialize-deprecated-field)
(serializer mpd-serialize-deprecated-field))
(database
maybe-mpd-plugin
@ -431,29 +432,29 @@ To use a Unix domain socket, an absolute path can be specified here."
(inputs
(list-of-mpd-plugin '())
"List of MPD input plugin configurations."
(lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "input" x)))
(serializer (lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "input" x))))
(archive-plugins
(list-of-mpd-plugin '())
"List of MPD archive plugin configurations."
(lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "archive_plugin" x)))
(serializer (lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "archive_plugin" x))))
(input-cache-size
maybe-string
"MPD input cache size."
(lambda (_ x)
(if (maybe-value-set? x)
#~(string-append "\ninput_cache {\n"
#$(mpd-serialize-string "size" x)
"}\n") "")))
(serializer (lambda (_ x)
(if (maybe-value-set? x)
#~(string-append "\ninput_cache {\n"
#$(mpd-serialize-string "size" x)
"}\n") ""))))
(decoders
(list-of-mpd-plugin '())
"List of MPD decoder plugin configurations."
(lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "decoder" x)))
(serializer (lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "decoder" x))))
(resampler
maybe-mpd-plugin
@ -462,8 +463,8 @@ To use a Unix domain socket, an absolute path can be specified here."
(filters
(list-of-mpd-plugin '())
"List of MPD filter plugin configurations."
(lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "filter" x)))
(serializer (lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "filter" x))))
(outputs
(list-of-mpd-plugin-or-output (list (mpd-output)))
@ -473,8 +474,8 @@ By default this is a single output using pulseaudio.")
(playlist-plugins
(list-of-mpd-plugin '())
"List of MPD playlist plugin configurations."
(lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "playlist_plugin" x)))
(serializer (lambda (_ x)
(mpd-serialize-list-of-mpd-plugin "playlist_plugin" x))))
(extra-options
(alist '())

View File

@ -213,9 +213,10 @@ option in fstab are skipped.")
maybe-list-of-strings
"Extra options to append to @command{fstrim} (run @samp{man fstrim} for
more information)."
(lambda (_ value)
(if (maybe-value-set? value)
value '())))
(serializer
(lambda (_ value)
(if (maybe-value-set? value)
value '()))))
(prefix fstrim-))
(define (serialize-fstrim-configuration config)

View File

@ -200,7 +200,7 @@
"Backend to use to detect changes in the @code{log-path}. The default is
'auto. To consult the defaults of the jail configuration, refer to the
@file{/etc/fail2ban/jail.conf} file of the @code{fail2ban} package."
fail2ban-jail-configuration-serialize-backend)
(serializer fail2ban-jail-configuration-serialize-backend))
(max-retry
maybe-integer
"The number of failures before a host get banned
@ -269,7 +269,7 @@ names matching their filter name.")
maybe-symbol
"The encoding of the log files handled by the jail.
Possible values are: @code{'ascii}, @code{'utf-8} and @code{'auto}."
fail2ban-jail-configuration-serialize-log-encoding)
(serializer fail2ban-jail-configuration-serialize-log-encoding))
(log-path
(list-of-strings '())
"The file names of the log files to be monitored.")
@ -280,7 +280,7 @@ Possible values are: @code{'ascii}, @code{'utf-8} and @code{'auto}."
(text-config '())
"Extra content for the jail configuration, provided as a list of file-like
objects."
serialize-text-config)
(serializer serialize-text-config))
(prefix fail2ban-jail-configuration-))
(define list-of-fail2ban-jail-configurations?

View File

@ -82,6 +82,9 @@
(format #f "~a = ~a;" name value))
(define-configuration serializable-configuration
(port (number 80) "The port number." (serializer custom-number-serializer)))
(define-configuration serializable-configuration-deprecated
(port (number 80) "The port number." custom-number-serializer))
(test-assert "serialize-configuration"
@ -89,8 +92,14 @@
(let ((config (serializable-configuration)))
(serialize-configuration config serializable-configuration-fields))))
(test-assert "serialize-configuration [deprecated]"
(gexp?
(let ((config (serializable-configuration-deprecated)))
(serialize-configuration
config serializable-configuration-deprecated-fields))))
(define-configuration serializable-configuration
(port (number 80) "The port number." custom-number-serializer)
(port (number 80) "The port number." (serializer custom-number-serializer))
(no-serialization))
(test-assert "serialize-configuration with no-serialization"