GNU bug report logs - #33836
[PATCH 0/2] location in define-configuration

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Sat, 22 Dec 2018 20:40:02 UTC

Severity: normal

Tags: fixed, patch

Done: Oleg Pykhalov <go.wigust <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33836 in the body.
You can then email your comments to 33836 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sat, 22 Dec 2018 20:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 22 Dec 2018 20:40:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 0/2] location in define-configuration
Date: Sat, 22 Dec 2018 23:38:57 +0300
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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sat, 22 Dec 2018 20:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 1/2] services: configuration: Add location.
Date: Sat, 22 Dec 2018 23:42:06 +0300
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sat, 22 Dec 2018 20:43:02 GMT) Full text and rfc822 format available.

Message #11 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 2/2] services: zabbix-front-end: Show location in messages.
Date: Sat, 22 Dec 2018 23:42:07 +0300
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sun, 23 Dec 2018 14:22:02 GMT) Full text and rfc822 format available.

Message #14 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Subject: Re: [bug#33836] [PATCH 1/2] services: configuration: Add location.
Date: Sun, 23 Dec 2018 17:21:04 +0300
[Message part 1 (text/plain, inline)]
Oleg Pykhalov <go.wigust <at> 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.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sun, 23 Dec 2018 15:38:02 GMT) Full text and rfc822 format available.

Message #17 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH] services: zabbix-front-end: Show location in messages.
Date: Sun, 23 Dec 2018 18:36:33 +0300
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sun, 23 Dec 2018 15:41:01 GMT) Full text and rfc822 format available.

Message #20 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 1/2] services: configuration: Add location.
Date: Sun, 23 Dec 2018 18:40:20 +0300
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Wed, 26 Dec 2018 17:31:01 GMT) Full text and rfc822 format available.

Message #23 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 33836 <at> debbugs.gnu.org
Subject: Re: [bug#33836] [PATCH 1/2] services: configuration: Add location.
Date: Wed, 26 Dec 2018 18:30:09 +0100
Hello,

Oleg Pykhalov <go.wigust <at> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Wed, 26 Dec 2018 17:32:02 GMT) Full text and rfc822 format available.

Message #26 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 33836 <at> debbugs.gnu.org
Subject: Re: [bug#33836] [PATCH] services: zabbix-front-end: Show location in
 messages.
Date: Wed, 26 Dec 2018 18:31:33 +0100
Oleg Pykhalov <go.wigust <at> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Fri, 15 Feb 2019 22:25:02 GMT) Full text and rfc822 format available.

Message #29 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 33836 <at> debbugs.gnu.org
Subject: Re: [bug#33836] [PATCH 1/2] services: configuration: Add location.
Date: Fri, 15 Feb 2019 23:24:52 +0100
Hi Oleg,

A friendly ping!  :-)

Ludo’.

Ludovic Courtès <ludo <at> gnu.org> skribis:

> Hello,
>
> Oleg Pykhalov <go.wigust <at> 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’.




Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Thu, 28 Feb 2019 22:41:02 GMT) Full text and rfc822 format available.

Message #32 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 0/2] Apply suggestions.
Date: Fri,  1 Mar 2019 01:39:59 +0300
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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Thu, 28 Feb 2019 22:42:02 GMT) Full text and rfc822 format available.

Message #35 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 1/2] services: configuration: Add '%location'.
Date: Fri,  1 Mar 2019 01:40:00 +0300
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Thu, 28 Feb 2019 22:42:03 GMT) Full text and rfc822 format available.

Message #38 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 33836 <at> debbugs.gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH 2/2] services: zabbix-front-end: Show location in messages.
Date: Fri,  1 Mar 2019 01:40:01 +0300
* 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 <at> member.fsf.org>
 ;;; Copyright © 2018 Gábor Boskovits <boskovits <at> gmail.com>
-;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#33836; Package guix-patches. (Sun, 10 Mar 2019 17:23:01 GMT) Full text and rfc822 format available.

Message #41 received at 33836 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 33836 <at> debbugs.gnu.org
Subject: Re: [bug#33836] [PATCH 0/2] Apply suggestions.
Date: Sun, 10 Mar 2019 18:21:55 +0100
Hi Oleg,

Oleg Pykhalov <go.wigust <at> 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’.




Added tag(s) fixed. Request was from Oleg Pykhalov <go.wigust <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 10 Mar 2019 19:53:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 33836 <at> debbugs.gnu.org and Oleg Pykhalov <go.wigust <at> gmail.com> Request was from Oleg Pykhalov <go.wigust <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 10 Mar 2019 19:53:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Apr 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.