Message ID | 20181223154021.14287-1-go.wigust@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [bug#33836,1/2] services: configuration: Add location. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | success | Successfully applied |
Hello, Oleg Pykhalov <go.wigust@gmail.com> skribis: > * gnu/services/configuration.scm (define-configuration): Add location. > * gnu/services/mail.scm (namespace-configuration)[location]: Rename to > 'mailbox-location'. > (uglify-field-name): Handle this. > * doc/guix.texi (Mail Services): Document this. Nice! > --- a/gnu/services/configuration.scm > +++ b/gnu/services/configuration.scm > @@ -22,6 +22,7 @@ > #:use-module (guix packages) > #:use-module (guix records) > #:use-module (guix gexp) > + #:use-module ((guix utils) #:select (source-properties->location)) > #:autoload (texinfo) (texi-fragment->stexi) > #:autoload (texinfo serialize) (stexi->texi) > #:use-module (ice-9 match) > @@ -129,6 +130,10 @@ > #,(id #'stem #'% #'stem) > #,(id #'stem #'make- #'stem) > #,(id #'stem #'stem #'?) > + (location configuration-location > + (default (and=> (current-source-location) > + source-properties->location)) > + (innate)) What about calling the field ‘%location’ instead? That would avoid the collision with the other ‘location’ field and it should be fine because it’s not a field we manually set anyway. Also, instead of ‘configuration-location’, shouldn’t it be (id #'stem #'-location) ? That will avoid ending up with one ‘configuration-location’ binding for each record type. Thanks, Ludo’.
Hi Oleg, A friendly ping! :-) Ludo’. Ludovic Courtès <ludo@gnu.org> skribis: > Hello, > > Oleg Pykhalov <go.wigust@gmail.com> skribis: > >> * gnu/services/configuration.scm (define-configuration): Add location. >> * gnu/services/mail.scm (namespace-configuration)[location]: Rename to >> 'mailbox-location'. >> (uglify-field-name): Handle this. >> * doc/guix.texi (Mail Services): Document this. > > Nice! > >> --- a/gnu/services/configuration.scm >> +++ b/gnu/services/configuration.scm >> @@ -22,6 +22,7 @@ >> #:use-module (guix packages) >> #:use-module (guix records) >> #:use-module (guix gexp) >> + #:use-module ((guix utils) #:select (source-properties->location)) >> #:autoload (texinfo) (texi-fragment->stexi) >> #:autoload (texinfo serialize) (stexi->texi) >> #:use-module (ice-9 match) >> @@ -129,6 +130,10 @@ >> #,(id #'stem #'% #'stem) >> #,(id #'stem #'make- #'stem) >> #,(id #'stem #'stem #'?) >> + (location configuration-location >> + (default (and=> (current-source-location) >> + source-properties->location)) >> + (innate)) > > What about calling the field ‘%location’ instead? That would avoid the > collision with the other ‘location’ field and it should be fine because > it’s not a field we manually set anyway. > > Also, instead of ‘configuration-location’, shouldn’t it be > > (id #'stem #'-location) > > ? That will avoid ending up with one ‘configuration-location’ binding > for each record type. > > Thanks, > Ludo’.
Hello Ludovic, Apologies for a big delay. I applied all your suggestions and improved (I hope) text in error and hint. Oleg Pykhalov (2): services: configuration: Add '%location'. services: zabbix-front-end: Show location in messages. gnu/services/configuration.scm | 5 +++ gnu/services/monitoring.scm | 57 ++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi index e254b3859..a6db2461d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14665,7 +14665,7 @@ different for all namespaces. For example @samp{Public/}. Defaults to @samp{""}. @end deftypevr -@deftypevr {@code{namespace-configuration} parameter} string location +@deftypevr {@code{namespace-configuration} parameter} string mailbox-location Physical location of the mailbox. This is in the same format as mail_location, which is also the default for it. Defaults to @samp{""}. diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 707944cbe..9775f91ff 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -22,6 +22,7 @@ #:use-module (guix packages) #:use-module (guix records) #:use-module (guix gexp) + #:use-module ((guix utils) #:select (source-properties->location)) #:autoload (texinfo) (texi-fragment->stexi) #:autoload (texinfo serialize) (stexi->texi) #:use-module (ice-9 match) @@ -129,6 +130,10 @@ #,(id #'stem #'% #'stem) #,(id #'stem #'make- #'stem) #,(id #'stem #'stem #'?) + (location configuration-location + (default (and=> (current-source-location) + source-properties->location)) + (innate)) (field field-getter (default def)) ...) (define #,(id #'stem #'stem #'-fields) diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index fcaedd038..a8121e5d1 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -75,9 +75,12 @@ (define (uglify-field-name field-name) (let ((str (symbol->string field-name))) - (string-join (string-split (if (string-suffix? "?" str) - (substring str 0 (1- (string-length str))) - str) + (string-join (string-split (cond + ((string-suffix? "?" str) + (substring str 0 (1- (string-length str)))) + ((string=? str "mailbox-location") + "location") + (else str)) #\-) "_"))) @@ -413,7 +416,7 @@ format.") "Prefix required to access this namespace. This needs to be different for all namespaces. For example @samp{Public/}.") - (location + (mailbox-location (string "") "Physical location of the mailbox. This is in same format as mail_location, which is also the default for it.")