unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#33836] [PATCH 0/2] location in define-configuration
@ 2018-12-22 20:38 Oleg Pykhalov
  2018-12-22 20:42 ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  0 siblings, 1 reply; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-22 20:38 UTC (permalink / raw)
  To: 33836

This patch series follow up Ludovic's suggestions in #33549 bug report to
implement a ‘location’ record field for ‘define-configuration’ procedure.

Oleg Pykhalov (2):
  services: configuration: Add location.
  services: zabbix-front-end: Show location in messages.

 gnu/services/configuration.scm |  5 +++++
 gnu/services/monitoring.scm    | 26 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add location.
  2018-12-22 20:38 [bug#33836] [PATCH 0/2] location in define-configuration Oleg Pykhalov
@ 2018-12-22 20:42 ` Oleg Pykhalov
  2018-12-22 20:42   ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
  2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  0 siblings, 2 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-22 20:42 UTC (permalink / raw)
  To: 33836

* gnu/services/configuration.scm (define-configuration): Add location.
---
 gnu/services/configuration.scm | 5 +++++
 1 file changed, 5 insertions(+)

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)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages.
  2018-12-22 20:42 ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
@ 2018-12-22 20:42   ` Oleg Pykhalov
  2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  1 sibling, 0 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-22 20:42 UTC (permalink / raw)
  To: 33836

* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
 gnu/services/monitoring.scm | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f11..90eda6561 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -29,6 +29,7 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (guix utils)
   #:use-module ((guix ui) #:select (display-hint))
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
@@ -512,7 +513,7 @@ create it manually.")
 (define zabbix-front-end-config
   (match-lambda
     (($ <zabbix-front-end-configuration>
-        _ db-host db-port db-name db-user db-password db-secret-file
+        location _ db-host db-port db-name db-user db-password db-secret-file
         zabbix-host zabbix-port)
      (mixed-text-file "zabbix.conf.php"
                       "\
@@ -527,18 +528,25 @@ $DB['DATABASE'] = '" db-name "';
 $DB['USER']     = '" db-user "';
 $DB['PASSWORD'] = '" (if (string-null? db-password)
                          (if (string-null? db-secret-file)
-                             (raise (condition
-                                     (&message
-                                      (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
+                             (raise (make-compound-condition
+                                     (condition
+                                      (&message
+                                       (message "\
+you must provide either 'db-secret-file' or 'db-password'")))
+                                     (condition
+                                      (&error-location (location location)))))
                              (string-trim-both
                               (with-input-from-file db-secret-file
                                 read-string)))
                          (begin
-                           (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
-                           db-password)) "';
+                           (display-hint (format #f
+                                                 "~{~a: ~}Consider using
+@code{db-secret-file} instead of @code{db-password} and unset
+@code{db-password} for security in @code{zabbix-front-end-configuration}."
+                                                 (list (location-file location)
+                                                       (location-line location)
+                                                       (location-column location))))
+db-password)) "';
 
 // Schema name. Used for IBM DB2 and PostgreSQL.
 $DB['SCHEMA'] = '';
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add location.
  2018-12-22 20:42 ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  2018-12-22 20:42   ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
@ 2018-12-23 14:21   ` Oleg Pykhalov
  2018-12-23 15:36     ` [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages Oleg Pykhalov
  2018-12-23 15:40     ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  1 sibling, 2 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-23 14:21 UTC (permalink / raw)
  To: 33836

[-- Attachment #1: Type: text/plain, Size: 2501 bytes --]

Oleg Pykhalov <go.wigust@gmail.com> writes:

> * gnu/services/configuration.scm (define-configuration): Add location.
> ---
>  gnu/services/configuration.scm | 5 +++++
>  1 file changed, 5 insertions(+)

[…]

After ‘make clean-go’, the ‘make’ command outputs in Guix Git repo:
--8<---------------cut here---------------start------------->8---
Backtrace:
In ice-9/boot-9.scm:
  2994:20 19 (_)
   2312:4 18 (save-module-excursion #<procedure a94f060 at ice-9/boo?>)
  3014:26 17 (_)
In unknown file:
          16 (primitive-load-path "gnu/tests/mail" #<procedure 129f2?>)
In ice-9/eval.scm:
   626:19 15 (_ #<directory (gnu tests mail) 16e440a0>)
   293:34 14 (_ #<directory (gnu tests mail) 16e440a0>)
    163:9 13 (_ #<directory (gnu tests mail) 16e440a0>)
    159:9 12 (_ #<directory (gnu tests mail) 16e440a0>)
   293:34 11 (_ #<directory (gnu tests mail) 16e440a0>)
   214:21 10 (_ #(#(#(#(#(#<directory (gnu tests mail?> ?) ?) ?) ?) ?))
   217:50  9 (lp (#<procedure 1103f620 at ice-9/eval.scm:182:7 (e?> ?))
   217:50  8 (lp (#<procedure 1103f600 at ice-9/eval.scm:182:7 (e?> ?))
   217:50  7 (lp (#<procedure 1103f420 at ice-9/eval.scm:292:11 (?> ?))
   217:50  6 (lp (#<procedure 1103f3e0 at ice-9/eval.scm:182:7 (e?> ?))
   217:50  5 (lp (#<procedure 1103f3c0 at ice-9/eval.scm:182:7 (e?> ?))
   217:50  4 (lp (#<procedure 1103f180 at ice-9/eval.scm:292:11 (?> ?))
   217:33  3 (lp (#<procedure 1103f160 at ice-9/eval.scm:182:7 (e?> ?))
    155:9  2 (_ #(#(#(#(#(#<directory (gnu tests mail?> ?) ?) ?) ?) ?))
    619:8  1 (_ #(#(#(#(#(#(#<directory (gnu tests?> ?) ?) ?) ?) ?) ?))
In ice-9/boot-9.scm:
   260:13  0 (for-each #<procedure 11123520 at ice-9/eval.scm:333:1?> ?)

ice-9/boot-9.scm:260:13: In procedure for-each:
Throw to key `srfi-34' with args `(#<condition %compound [message: "Invalid value for field location: #f"] 1106b3e0>)'.

Some deprecated features have been used.  Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information.  Set it to "no" to suppress
this message.
make[2]: *** [Makefile:5576: make-go] Error 1
make[2]: Leaving directory '/home/natsu/src/guix'
make[1]: *** [Makefile:4657: all-recursive] Error 1
make[1]: Leaving directory '/home/natsu/src/guix'
make: *** [Makefile:3273: all] Error 2
--8<---------------cut here---------------end--------------->8---

Also my GuixSD fails to build.  Will try to fix ‘gnu/services/mail.scm’.

Oleg.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages.
  2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
@ 2018-12-23 15:36     ` Oleg Pykhalov
  2018-12-26 17:31       ` Ludovic Courtès
  2018-12-23 15:40     ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  1 sibling, 1 reply; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-23 15:36 UTC (permalink / raw)
  To: 33836

* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
 gnu/services/monitoring.scm | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f11..90eda6561 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -29,6 +29,7 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
+  #:use-module (guix utils)
   #:use-module ((guix ui) #:select (display-hint))
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
@@ -512,7 +513,7 @@ create it manually.")
 (define zabbix-front-end-config
   (match-lambda
     (($ <zabbix-front-end-configuration>
-        _ db-host db-port db-name db-user db-password db-secret-file
+        location _ db-host db-port db-name db-user db-password db-secret-file
         zabbix-host zabbix-port)
      (mixed-text-file "zabbix.conf.php"
                       "\
@@ -527,18 +528,25 @@ $DB['DATABASE'] = '" db-name "';
 $DB['USER']     = '" db-user "';
 $DB['PASSWORD'] = '" (if (string-null? db-password)
                          (if (string-null? db-secret-file)
-                             (raise (condition
-                                     (&message
-                                      (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
+                             (raise (make-compound-condition
+                                     (condition
+                                      (&message
+                                       (message "\
+you must provide either 'db-secret-file' or 'db-password'")))
+                                     (condition
+                                      (&error-location (location location)))))
                              (string-trim-both
                               (with-input-from-file db-secret-file
                                 read-string)))
                          (begin
-                           (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
-                           db-password)) "';
+                           (display-hint (format #f
+                                                 "~{~a: ~}Consider using
+@code{db-secret-file} instead of @code{db-password} and unset
+@code{db-password} for security in @code{zabbix-front-end-configuration}."
+                                                 (list (location-file location)
+                                                       (location-line location)
+                                                       (location-column location))))
+db-password)) "';
 
 // Schema name. Used for IBM DB2 and PostgreSQL.
 $DB['SCHEMA'] = '';
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add location.
  2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
  2018-12-23 15:36     ` [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages Oleg Pykhalov
@ 2018-12-23 15:40     ` Oleg Pykhalov
  2018-12-26 17:30       ` Ludovic Courtès
  1 sibling, 1 reply; 13+ messages in thread
From: Oleg Pykhalov @ 2018-12-23 15:40 UTC (permalink / raw)
  To: 33836

* 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.
---
 doc/guix.texi                  |  2 +-
 gnu/services/configuration.scm |  5 +++++
 gnu/services/mail.scm          | 11 +++++++----
 3 files changed, 13 insertions(+), 5 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.")
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add location.
  2018-12-23 15:40     ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
@ 2018-12-26 17:30       ` Ludovic Courtès
  2019-02-15 22:24         ` Ludovic Courtès
  0 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2018-12-26 17:30 UTC (permalink / raw)
  To: Oleg Pykhalov; +Cc: 33836

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’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages.
  2018-12-23 15:36     ` [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages Oleg Pykhalov
@ 2018-12-26 17:31       ` Ludovic Courtès
  0 siblings, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2018-12-26 17:31 UTC (permalink / raw)
  To: Oleg Pykhalov; +Cc: 33836

Oleg Pykhalov <go.wigust@gmail.com> skribis:

> * gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
> messages.

[...]

>  (define zabbix-front-end-config
>    (match-lambda
>      (($ <zabbix-front-end-configuration>
> -        _ db-host db-port db-name db-user db-password db-secret-file
> +        location _ db-host db-port db-name db-user db-password db-secret-file
>          zabbix-host zabbix-port)

Could you instead use ‘match-record’ here?  That way you could avoid
maching the ‘location’ field altogether.

Are there other users of ‘define-configuration’ that match raw records?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add location.
  2018-12-26 17:30       ` Ludovic Courtès
@ 2019-02-15 22:24         ` Ludovic Courtès
  2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
  0 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2019-02-15 22:24 UTC (permalink / raw)
  To: Oleg Pykhalov; +Cc: 33836

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’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 0/2] Apply suggestions.
  2019-02-15 22:24         ` Ludovic Courtès
@ 2019-02-28 22:39           ` Oleg Pykhalov
  2019-02-28 22:40             ` [bug#33836] [PATCH 1/2] services: configuration: Add '%location' Oleg Pykhalov
                               ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2019-02-28 22:39 UTC (permalink / raw)
  To: 33836

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(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 1/2] services: configuration: Add '%location'.
  2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
@ 2019-02-28 22:40             ` Oleg Pykhalov
  2019-02-28 22:40             ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
  2019-03-10 17:21             ` [bug#33836] [PATCH 0/2] Apply suggestions Ludovic Courtès
  2 siblings, 0 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2019-02-28 22:40 UTC (permalink / raw)
  To: 33836

* gnu/services/configuration.scm (define-configuration): Add '%location'.
---
 gnu/services/configuration.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 707944cbe0..90f12a8d39 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 #,(id #'stem #'-location)
+                            (default (and=> (current-source-location)
+                                            source-properties->location))
+                            (innate))
                  (field field-getter (default def))
                  ...)
                (define #,(id #'stem #'stem #'-fields)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages.
  2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
  2019-02-28 22:40             ` [bug#33836] [PATCH 1/2] services: configuration: Add '%location' Oleg Pykhalov
@ 2019-02-28 22:40             ` Oleg Pykhalov
  2019-03-10 17:21             ` [bug#33836] [PATCH 0/2] Apply suggestions Ludovic Courtès
  2 siblings, 0 replies; 13+ messages in thread
From: Oleg Pykhalov @ 2019-02-28 22:40 UTC (permalink / raw)
  To: 33836

* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
 gnu/services/monitoring.scm | 57 +++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f110..101222bf2e 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
 ;;; Copyright © 2018 Gábor Boskovits <boskovits@gmail.com>
-;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,7 +29,8 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
-  #:use-module ((guix ui) #:select (display-hint))
+  #:use-module (guix utils)
+  #:use-module ((guix ui) #:select (display-hint G_))
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
   #:use-module (srfi srfi-26)
@@ -509,13 +510,12 @@ create it manually.")
    (number 10051)
    "Zabbix server port."))
 
-(define zabbix-front-end-config
-  (match-lambda
-    (($ <zabbix-front-end-configuration>
-        _ db-host db-port db-name db-user db-password db-secret-file
-        zabbix-host zabbix-port)
-     (mixed-text-file "zabbix.conf.php"
-                      "\
+(define (zabbix-front-end-config config)
+  (match-record config <zabbix-front-end-configuration>
+    (%location db-host db-port db-name db-user db-password db-secret-file
+               zabbix-host zabbix-port)
+    (mixed-text-file "zabbix.conf.php"
+                     "\
 <?php
 // Zabbix GUI configuration file.
 global $DB;
@@ -525,20 +525,29 @@ $DB['SERVER']   = '" db-host "';
 $DB['PORT']     = '" (number->string db-port) "';
 $DB['DATABASE'] = '" db-name "';
 $DB['USER']     = '" db-user "';
-$DB['PASSWORD'] = '" (if (string-null? db-password)
-                         (if (string-null? db-secret-file)
-                             (raise (condition
-                                     (&message
-                                      (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
-                             (string-trim-both
-                              (with-input-from-file db-secret-file
-                                read-string)))
-                         (begin
-                           (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
-                           db-password)) "';
+$DB['PASSWORD'] = '" (let ((file (location-file %location))
+                           (line (location-line %location))
+                           (column (location-column %location)))
+                       (if (string-null? db-password)
+                           (if (string-null? db-secret-file)
+                               (raise (make-compound-condition
+                                       (condition
+                                        (&message
+                                         (message
+                                          (format #f "no '~A' or '~A' field in your '~A' record"
+                                                  'db-secret-file 'db-password
+                                                  'zabbix-front-end-configuration))))
+                                       (condition
+                                        (&error-location
+                                         (location %location)))))
+                               (string-trim-both
+                                (with-input-from-file db-secret-file
+                                  read-string)))
+                           (begin
+                             (display-hint (format #f (G_ "~a:~a:~a: ~a:
+Consider using @code{db-secret-file} instead of @code{db-password} for better
+security.") file line column 'zabbix-front-end-configuration))
+                             db-password))) "';
 
 // Schema name. Used for IBM DB2 and PostgreSQL.
 $DB['SCHEMA'] = '';
@@ -548,7 +557,7 @@ $ZBX_SERVER_PORT = '" (number->string zabbix-port) "';
 $ZBX_SERVER_NAME = '';
 
 $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
-"))))
+")))
 
 (define %maintenance.inc.php
   ;; Empty php file to allow us move zabbix-frontend configs to ‘/etc/zabbix’
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#33836] [PATCH 0/2] Apply suggestions.
  2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
  2019-02-28 22:40             ` [bug#33836] [PATCH 1/2] services: configuration: Add '%location' Oleg Pykhalov
  2019-02-28 22:40             ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
@ 2019-03-10 17:21             ` Ludovic Courtès
  2 siblings, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2019-03-10 17:21 UTC (permalink / raw)
  To: Oleg Pykhalov; +Cc: 33836

Hi Oleg,

Oleg Pykhalov <go.wigust@gmail.com> skribis:

> 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.

LGTM, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-03-10 17:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-22 20:38 [bug#33836] [PATCH 0/2] location in define-configuration Oleg Pykhalov
2018-12-22 20:42 ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-22 20:42   ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-23 15:36     ` [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages Oleg Pykhalov
2018-12-26 17:31       ` Ludovic Courtès
2018-12-23 15:40     ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-26 17:30       ` Ludovic Courtès
2019-02-15 22:24         ` Ludovic Courtès
2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
2019-02-28 22:40             ` [bug#33836] [PATCH 1/2] services: configuration: Add '%location' Oleg Pykhalov
2019-02-28 22:40             ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
2019-03-10 17:21             ` [bug#33836] [PATCH 0/2] Apply suggestions 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).