summaryrefslogtreecommitdiff
path: root/gnu/services/configuration.scm
Commit message (Collapse)AuthorAge
* services: configuration: Fix interpose implementation.Andrew Tropin2021-11-01
| | | | | | | | * gnu/services/configuration.scm (interpose, serialize-text-config): Fix interpose implementation, move file-like object code to serialize-text-config. Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com>
* home: services: configuration: Support file-like objects.Oleg Pykhalov2021-10-09
| | | | | | | | | | | | | | | | | * gnu/home/services/configuration.scm (interpose): Operate only with file-like objects. (string-or-gexp?): Delete procedure. (serialize-string-or-gexp): Rename to 'serialize-file-like'. (text-config?): Call 'file-like' intead of 'string-or-gexp?'. * guix/scripts/home/import.scm: (generate-bash-module+configuration): Don't call slurp-file-gexp. * gnu/home/services/configuration.scm: Move content ... * gnu/services/configuration.scm: here. * gnu/home/services/shells.scm: Delete (gnu home services configuration). * gnu/home/services/xdg.scm: Same. * gnu/local.mk: Same. * tests/guix-home.sh: Test home-bash-service-type and extension with home-bash-extension.
* services: configuration: Derive the default value from the package variable.Xinglu Chen2021-08-02
| | | | | | | | | | | | If the type of a configuration field is a package, show the name of its package *variable* as the default value. * gnu/services/configuration.scm (generate-documentation){show-default} {package->symbol}: New nested procedures. Use them to format the field entries. Co-authored-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* services: configuration: Uniformize the generated documentation.Xinglu Chen2021-08-02
| | | | | | | | | | | Make the formatting of the generated docs more consistent with the rest of the docs in the “Services” section of the manual. * gnu/services/configuration (generate-documentation): Represent the data type documentation of a field using a DEFTP table rather than DEFTYPEVR elements. Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* services: configuration: Allow specifying prefix for serializer names.Xinglu Chen2021-06-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes two configurations might have the same types for their field values, but the values might be serialized in two completely different ways (e.g. because the two programs have different configuration languages). An example of this would be the ‘serialize-boolean’ procedure in (gnu services mail) and (gnu services getmail). They both serialize a boolean value, but because the Dovecot’s configuration language has a different syntax to the configuration language for Getmail, two different procedures have to be defined. One way to workaround this would be to specify custom serializers for many fields in order to separate the serialization of the values that have the same type but serialize in different ways. This could get very tedious, especially if there are many configurations in the same module. Another way would be to move one of the configurations to its own module, like what was done with (gnu services getmail). However, this would mean that there would be multiple modules containing configurations for related programs, e.g. we have (gnu services mail) and (gnu services getmail), it doesn’t make much sense to keep the Getmail configuration in its own module. This patch will allow one to write something like this: (define-configuration foo-configuration (bar (string "bob") "Option bar.") (prefix bar-)) and the value of the ‘bar’ field would be serialized using a procedure named ‘bar-serialize-string’ instead of just ‘serialize-string’. * gnu/services/configuration.scm (define-maybe-helper): Accept ‘prefix’ argument for using serializer with custom prefix. (define-maybe): Pattern match on ‘prefix’ literal. (define-configuration-helper): Accept ‘prefix’ argument for using serializer with custom prefix. (define-configuration): Pattern match on ‘prefix’ literal. * tests/services/configuration.scm ("serialize-configuration with prefix"): New test. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* services: configuration: Add a define-configuration/no-serialization syntax.Maxim Cournoyer2021-05-17
| | | | | | | | This is added for convenience and for uniformity with the define-maybe/no-serialization syntax introduced in the previous commit. * gnu/services/configuration.scm (define-configuration/no-serialization): New syntax.
* services: configuration: Add a define-maybe/no-serialization syntax.Maxim Cournoyer2021-05-17
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, using define-maybe along define-configuration with the no-serialization syntactic keyword would result in the following warning: warning: possibly unbound variable `VARIABLE-NAME' This change introduces the define-maybe/no-serialization variant that does away with defining a serialization helper procedure, which makes it possible to avoid the above warning. * gnu/services/configuration.scm (define-maybe/no-serialization): New syntax. (define-maybe-helper): New procedure. (define-maybe): Define syntax using the above procedure. * tests/services/configuration.scm (tests): Fix module name. (custom-number-serializer): Do not print to standard output. (maybe-number?, serialize-maybe-number): New procedures defined via the define-maybe macro. (config-with-maybe-number): New configuration. (serialize-number): New procedure. ("maybe value serialization"): New test. (maybe-string?): New procedure defined via the define-maybe/no-serialization macro. (config-with-maybe-string/no-serialization): New configuration. ("maybe value without serialization no procedure bound"): New test.
* services: configuration: Export 'no-serialization' syntactic keyword.Ludovic Courtès2021-05-08
| | | | | | This is a followup to 3f9a12dc082b20426fc740416601b69ea1897193. * gnu/services/configuration.scm (no-serialization): New variable.
* services: configuration: Fix %location accessor name.Maxim Cournoyer2021-05-08
| | | | | | | | | | | | | The non-hygienic binding of the source location accessor was set to '-location'; in modules where multiple configurations were defined, it would cause compilation warnings such as: gnu/services/mail.scm:175:0: warning: shadows previous definition of `%-location-procedure' at gnu/services/mail.scm:165:0 * gnu/services/configuration.scm (define-configuration-helper) <id>: Add a missing #'stem argument to use the configuration name as a prefix to the location accessor identifier.
* services: configuration: Allow specifying a custom serializer.Xinglu Chen2021-05-08
| | | | | | | | | | | | | | | | | | In some cases, rather than globally disabling serialization, it may be more appropriate to disable or otherwise alter the serialization procedure of a specific field. In large module, multiple configurations may also exist that would need to alter the default serialization procedure, which is named after the field type. Being able to specify a per-field serialization procedure provides more flexibility. * gnu/services/configuration.scm (define-configuration): Add an optional pattern variable to allow specifying a custom serialization procedure. (define-configuration-helper) <field-serializer>: Use it to transform the syntax. (empty-serializer): New procedure. (serialize-package): Alias to ‘empty-serializer’. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* services: configuration: Allow disabling serialization.Maxim Cournoyer2021-05-08
| | | | | | | | | | | | | | Serialization is not always useful, for example when deriving command line arguments from a configuration. This change provides a way to turn it off, which removes the need to define a bunch of dummy serialization procedures. Credit goes to Andrew Gierth (RhodiumToad) from #guile for providing the solution. Thank you! * gnu/services/configuration.scm (define-configuration-helper): New procedure. (define-configuration) <no-serialization>: New syntactic keyword. Use it in a new pattern. Refactor the macro so that it makes use of the above helper procedure.
* services: configuration: Avoid a compilation warning.Maxim Cournoyer2021-05-08
| | | | | | | This resolves a compilation warning introduced with commit bb716e8d9d. * gnu/services/configuration.scm (configuration->documentation): Use display to print the string instead of format.
* services: configuration: Add a new helper to ease generating documentation.Maxim Cournoyer2021-05-07
| | | | | | | The original (undocumented) procedure to generate the doc has a difficult to grasp interface; add a simpler one on top of it. * gnu/services/configuration.scm (configuration->documentation): New procedure.
* services: configuration: Support fields without default values.Xinglu Chen2021-05-07
| | | | | | | | | | | Not all fields in a configuration have a sensible default value. This changes makes it possible to omit a default value for a configuration field, requiring the user to provide a value. * gnu/services/configuration.scm (configuration-missing-field): New procedure. (define-configuration): Make default value optional. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
* services: configuration: Add '%location'.Oleg Pykhalov2019-03-10
| | | | * gnu/services/configuration.scm (define-configuration): Add '%location'.
* services: messaging: Prosody config supports file-like objects.Clément Lassieur2018-03-03
| | | | | | | | | | | | | | | | | | | | | | | | * doc/guix.texi (Messaging Services): Update accordingly. * gnu/services/configuration.scm (serialize-configuration, serialize-maybe-stem, serialize-package): Return strings or string-valued gexps (these procedures were only used for their side-effects). * gnu/services/messaging.scm (serialize-field, serialize-field-list, enclose-quotes, serialize-raw-content, serialize-ssl-configuration, serialize-virtualhost-configuration-list, serialize-int-component-configuration-list, serialize-ext-component-configuration-list, serialize-virtualhost-configuration, serialize-int-component-configuration, serialize-ext-component-configuration, serialize-prosody-configuration): Return strings or string-valued gexps and stop printing. (prosody-activation): Use SERIALIZE-PROSODY-CONFIGURATION's return value with MIXED-TEXT-FILE instead of using its output with PLAIN-FILE. (serialize-non-negative-integer, serialize-non-negative-integer-list): Convert numbers to strings. (file-object?, serialize-file-object, file-object-list?, serialize-file-object-list): New procedures. (ssl-configuration)[capath, cafile], (prosody-configuration)[plugin-paths, groups-file]: Replace FILE-NAME with FILE-OBJECT. * guix/gexp.scm (file-like?): New exported procedure.
* services: configuration: Show default values of list types.Clément Lassieur2017-11-28
| | | | | | | * doc/guix.texi (Messaging Services): Regenerate it. * gnu/services/configuration.scm (show-default?): Check VAL rather than DEFAULT. * gnu/services/messaging.scm (show-default?): Check VAL rather than DEFAULT. (prosody-configuration)[modules-enabled]: Remove default value from docstring.
* services: configuration: Rewrite id procedure.Mathieu Othacehe2017-03-24
| | | | | | | * gnu/services/configuration.scm (id): Replace it using the more concise version found in messaging.scm. Signed-off-by: Clément Lassieur <clement@lassieur.org>
* services: Factorize define-maybe macro.Mathieu Othacehe2017-03-24
| | | | | | | | | | | * gnu/services/configuration.scm (id): New procedure extracted from define-configuration. (define-maybe): New exported procedure, moved from messaging.scm. * gnu/services/messaging.scm (define-maybe): Remove it. (id): Move declaration inside define-all-configurations which is now the only caller procedure. Signed-off-by: Clément Lassieur <clement@lassieur.org>
* services: Move configuration functions that shouldn't be factorized.Clément Lassieur2017-03-12
| | | | | | | | | | | | | | * gnu/services/configuration.scm (serialize-field, serialize-string) (serialize-space-separated-string-list, space-separated-string-list?) (serialize-file-name, file-name?, serialize-boolean): Move these functions... * gnu/services/cups.scm: ...to this file. * gnu/services/kerberos.scm: ...to this file. Configuration syntaxes are very specific to services. Some services may have the same configuration syntax, but none of them is common enough to be abstracted in configuration.scm. Signed-off-by: Clément Lassieur <clement@lassieur.org>
* gnu: Add Prosody service.Clément Lassieur2017-01-08
| | | | | | | | | * gnu/services/messaging.scm: New file. * gnu/services/configuration.scm: New exported procedures. * gnu/local.mk (GNU_SYSTEM_MODULES): Add gnu/services/messaging.scm. * doc/guix.texi (Messaging Services): New section. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* gnu: Add Kerberos client service.John Darrington2016-12-03
| | | | | | | * doc/guix.texi (Kerberos Services)[Krb5 Service]: New subsubheading. * gnu/services/kerberos.scm (krb5-service-type): New variable. * gnu/services/configuration.scm (configuration-field-serializer, configuration-field-getter): Export variables.
* services: Factorize configuration abstraction.Julien Lepiller2016-11-26
* gnu/services/mail.scm and gnu/services/cups.scm (&configuration-error) (configuration-error, configuration-field-error) (configuration-missing-field, configuration-field, serialize-configuration) (validate-configuration, define-configuration, uglify-field-name) (serialize-field, serialize-package, serialize-string) (serialize-space-separated-string-list, space-separated-string-list?) (serialize-file-name, file-name?, serialize-field-name) (generate-documentation): Move duplicate code... * gnu/services/configuration.scm: ...to this new file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add configuration.scm. Signed-off-by: Ludovic Courtès <ludo@gnu.org>