GNU bug report logs - #30702
[PATCH] services: nginx: Support extra content in the http block.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sun, 4 Mar 2018 20:01:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

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 30702 in the body.
You can then email your comments to 30702 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#30702; Package guix-patches. (Sun, 04 Mar 2018 20:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 04 Mar 2018 20:01:02 GMT) Full text and rfc822 format available.

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

From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: nginx: Support extra content in the http block.
Date: Sun,  4 Mar 2018 20:00:14 +0000
This helpful when adding content to the nginx configuration file, which isn't
supported by the record type used for the configuration.  For example, like
adding proxy_cache_path configuration.

* gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
  (nginx-configuration-extra-content): New field accessor.
  (default-nginx-config): Add support for the extra-content field.
* doc/guix.texi (NGINX): Document the new extra-content field.
---
 doc/guix.texi        | 4 ++++
 gnu/services/web.scm | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 057272df4..151bc7ddd 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15431,6 +15431,10 @@ use the size of the processors cache line.
 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
 Maximum bucket size for the server names hash tables.
 
+@item @code{extra-content} (default: @code{'()})
+Extra content for the @code{http} block.  Should be a list of strings or
+G-expressions.
+
 @end table
 @end deffn
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index beda481b0..1f58c9b86 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -73,6 +73,7 @@
             nginx-configuration-upstream-blocks
             nginx-configuration-server-names-hash-bucket-size
             nginx-configuration-server-names-hash-bucket-max-size
+            nginx-configuration-extra-content
             nginx-configuration-file
 
             <nginx-server-configuration>
@@ -423,6 +424,8 @@
                                  (default #f))
   (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size
                                      (default #f))
+  (extra-content nginx-configuration-extra-content
+                 (default '()))
   (file          nginx-configuration-file         ;#f | string | file-like
                  (default #f)))
 
@@ -513,7 +516,8 @@ of index files."
                 (nginx log-directory run-directory
                  server-blocks upstream-blocks
                  server-names-hash-bucket-size
-                 server-names-hash-bucket-max-size)
+                 server-names-hash-bucket-max-size
+                 extra-content)
    (apply mixed-text-file "nginx.conf"
           (flatten
            "user nginx nginx;\n"
@@ -542,7 +546,8 @@ of index files."
            "\n"
            (map emit-nginx-upstream-config upstream-blocks)
            (map emit-nginx-server-config server-blocks)
-           "}\n"
+           extra-content
+           "\n}\n"
            "events {}\n"))))
 
 (define %nginx-accounts
-- 
2.16.0





Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Sat, 17 Mar 2018 21:43:01 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Christopher Baines <mail <at> cbaines.net>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Sat, 17 Mar 2018 22:42:09 +0100
Hello,

Christopher Baines <mail <at> cbaines.net> skribis:

> This helpful when adding content to the nginx configuration file, which isn't
> supported by the record type used for the configuration.  For example, like
> adding proxy_cache_path configuration.
>
> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>   (nginx-configuration-extra-content): New field accessor.
>   (default-nginx-config): Add support for the extra-content field.
> * doc/guix.texi (NGINX): Document the new extra-content field.
> ---
>  doc/guix.texi        | 4 ++++
>  gnu/services/web.scm | 9 +++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 057272df4..151bc7ddd 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -15431,6 +15431,10 @@ use the size of the processors cache line.
>  @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
>  Maximum bucket size for the server names hash tables.
>  
> +@item @code{extra-content} (default: @code{'()})
> +Extra content for the @code{http} block.  Should be a list of strings or
> +G-expressions.

I find it surprising that it’s a list rather than a string or
string-valued gexp.  Thoughts?

Otherwise I think it’s very useful!

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Sat, 17 Mar 2018 23:47:02 GMT) Full text and rfc822 format available.

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

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Sat, 17 Mar 2018 23:46:49 +0000
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hello,
>
> Christopher Baines <mail <at> cbaines.net> skribis:
>
>> This helpful when adding content to the nginx configuration file, which isn't
>> supported by the record type used for the configuration.  For example, like
>> adding proxy_cache_path configuration.
>>
>> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>>   (nginx-configuration-extra-content): New field accessor.
>>   (default-nginx-config): Add support for the extra-content field.
>> * doc/guix.texi (NGINX): Document the new extra-content field.
>> ---
>>  doc/guix.texi        | 4 ++++
>>  gnu/services/web.scm | 9 +++++++--
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 057272df4..151bc7ddd 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -15431,6 +15431,10 @@ use the size of the processors cache line.
>>  @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
>>  Maximum bucket size for the server names hash tables.
>>
>> +@item @code{extra-content} (default: @code{'()})
>> +Extra content for the @code{http} block.  Should be a list of strings or
>> +G-expressions.
>
> I find it surprising that it’s a list rather than a string or
> string-valued gexp.  Thoughts?

Lists are used as the type for other fields in related records. I chose
a list as it's easy to add things to, but thinking about it, that's
probably true for strings and gexps as well.

Saying it can be either a string or a gexp might be a little tricky, as
string operations wouldn't work on the gexp. My familiarity with
string-valued gexps is a little limited though, I've only just started
using file-append more, as I think that's how it works. How would you go
about adding say a string to a gexp?
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Sun, 18 Mar 2018 17:13:01 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Christopher Baines <mail <at> cbaines.net>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Sun, 18 Mar 2018 18:12:42 +0100
Christopher Baines <mail <at> cbaines.net> skribis:

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

[...]

>>> +@item @code{extra-content} (default: @code{'()})
>>> +Extra content for the @code{http} block.  Should be a list of strings or
>>> +G-expressions.
>>
>> I find it surprising that it’s a list rather than a string or
>> string-valued gexp.  Thoughts?
>
> Lists are used as the type for other fields in related records. I chose
> a list as it's easy to add things to, but thinking about it, that's
> probably true for strings and gexps as well.
>
> Saying it can be either a string or a gexp might be a little tricky, as
> string operations wouldn't work on the gexp. My familiarity with
> string-valued gexps is a little limited though, I've only just started
> using file-append more, as I think that's how it works. How would you go
> about adding say a string to a gexp?

You’d have to produce build-side code that will concatenate the strings:

  ;; Add extra content to CONFIG.
  (let ((original (nginx-extra-content config)))
    (nginx-configuration
      (inherit config)
      (extra-content #~(string-append #$original "\nextra extra stuff"))))

HTH!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Fri, 18 May 2018 08:55:02 GMT) Full text and rfc822 format available.

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

From: Christopher Baines <mail <at> cbaines.net>
To: 30702 <at> debbugs.gnu.org
Subject: [PATCH] services: nginx: Support extra content in the http block.
Date: Fri, 18 May 2018 09:54:22 +0100
This helpful when adding content to the nginx configuration file, which isn't
supported by the record type used for the configuration.  For example, like
adding proxy_cache_path configuration.

* gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
  (nginx-configuration-extra-content): New field accessor.
  (default-nginx-config): Add support for the extra-content field.
* doc/guix.texi (NGINX): Document the new extra-content field.
---
 doc/guix.texi        | 4 ++++
 gnu/services/web.scm | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a12210db8..eaaf0e684 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15786,6 +15786,10 @@ use the size of the processors cache line.
 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
 Maximum bucket size for the server names hash tables.
 
+@item @code{extra-content} (default: @code{""})
+Extra content for the @code{http} block.  Should be string or a string
+valued G-expression.
+
 @end table
 @end deffn
 
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index b336a8dd3..8f55dae5e 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -73,6 +73,7 @@
             nginx-configuration-upstream-blocks
             nginx-configuration-server-names-hash-bucket-size
             nginx-configuration-server-names-hash-bucket-max-size
+            nginx-configuration-extra-content
             nginx-configuration-file
 
             <nginx-server-configuration>
@@ -423,6 +424,8 @@
                                  (default #f))
   (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size
                                      (default #f))
+  (extra-content nginx-configuration-extra-content
+                 (default ""))
   (file          nginx-configuration-file         ;#f | string | file-like
                  (default #f)))
 
@@ -513,7 +516,8 @@ of index files."
                 (nginx log-directory run-directory
                  server-blocks upstream-blocks
                  server-names-hash-bucket-size
-                 server-names-hash-bucket-max-size)
+                 server-names-hash-bucket-max-size
+                 extra-content)
    (apply mixed-text-file "nginx.conf"
           (flatten
            "user nginx nginx;\n"
@@ -542,7 +546,8 @@ of index files."
            "\n"
            (map emit-nginx-upstream-config upstream-blocks)
            (map emit-nginx-server-config server-blocks)
-           "}\n"
+           extra-content
+           "\n}\n"
            "events {}\n"))))
 
 (define %nginx-accounts
-- 
2.17.0





Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Fri, 18 May 2018 09:38:01 GMT) Full text and rfc822 format available.

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

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Fri, 18 May 2018 10:37:34 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hello,
>
> Christopher Baines <mail <at> cbaines.net> skribis:
>
>> This helpful when adding content to the nginx configuration file, which isn't
>> supported by the record type used for the configuration.  For example, like
>> adding proxy_cache_path configuration.
>>
>> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>>   (nginx-configuration-extra-content): New field accessor.
>>   (default-nginx-config): Add support for the extra-content field.
>> * doc/guix.texi (NGINX): Document the new extra-content field.
>> ---
>>  doc/guix.texi        | 4 ++++
>>  gnu/services/web.scm | 9 +++++++--
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 057272df4..151bc7ddd 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -15431,6 +15431,10 @@ use the size of the processors cache line.
>>  @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
>>  Maximum bucket size for the server names hash tables.
>>
>> +@item @code{extra-content} (default: @code{'()})
>> +Extra content for the @code{http} block.  Should be a list of strings or
>> +G-expressions.
>
> I find it surprising that it’s a list rather than a string or
> string-valued gexp.  Thoughts?

I've now got around to trying this out, and sent a patch that uses a
string, rather than a list.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Sat, 19 May 2018 20:37:01 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Christopher Baines <mail <at> cbaines.net>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Sat, 19 May 2018 22:36:26 +0200
Hello,

Christopher Baines <mail <at> cbaines.net> skribis:

> This helpful when adding content to the nginx configuration file, which isn't
> supported by the record type used for the configuration.  For example, like
> adding proxy_cache_path configuration.
>
> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>   (nginx-configuration-extra-content): New field accessor.
>   (default-nginx-config): Add support for the extra-content field.
> * doc/guix.texi (NGINX): Document the new extra-content field.

[...]

> +@item @code{extra-content} (default: @code{""})
> +Extra content for the @code{http} block.  Should be string or a string
> +valued G-expression.

[...]

>     (apply mixed-text-file "nginx.conf"
>            (flatten
>             "user nginx nginx;\n"
> @@ -542,7 +546,8 @@ of index files."
>             "\n"
>             (map emit-nginx-upstream-config upstream-blocks)
>             (map emit-nginx-server-config server-blocks)
> -           "}\n"
> +           extra-content
> +           "\n}\n"
>             "events {}\n"))))

That doesn’t work if ‘extra-content’ is something like:

  #~(string-append "foo" bar)

does it?

My understanding of the doc above was that it intends to allow this.
But maybe it doesn’t matter after all?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Mon, 11 Jun 2018 18:10:01 GMT) Full text and rfc822 format available.

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

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Mon, 11 Jun 2018 19:09:39 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hello,
>
> Christopher Baines <mail <at> cbaines.net> skribis:
>
>> This helpful when adding content to the nginx configuration file, which isn't
>> supported by the record type used for the configuration.  For example, like
>> adding proxy_cache_path configuration.
>>
>> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>>   (nginx-configuration-extra-content): New field accessor.
>>   (default-nginx-config): Add support for the extra-content field.
>> * doc/guix.texi (NGINX): Document the new extra-content field.
>
> [...]
>
>> +@item @code{extra-content} (default: @code{""})
>> +Extra content for the @code{http} block.  Should be string or a string
>> +valued G-expression.
>
> [...]
>
>>     (apply mixed-text-file "nginx.conf"
>>            (flatten
>>             "user nginx nginx;\n"
>> @@ -542,7 +546,8 @@ of index files."
>>             "\n"
>>             (map emit-nginx-upstream-config upstream-blocks)
>>             (map emit-nginx-server-config server-blocks)
>> -           "}\n"
>> +           extra-content
>> +           "\n}\n"
>>             "events {}\n"))))
>
> That doesn’t work if ‘extra-content’ is something like:
>
>   #~(string-append "foo" bar)
>
> does it?
>
> My understanding of the doc above was that it intends to allow this.
> But maybe it doesn’t matter after all?

So... I've finally got back around to looking at this, and as far as I
can see, it does work. extra-content is passed as one of the arguments
to mixed-text-file, which accepts G-exp things.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30702; Package guix-patches. (Tue, 12 Jun 2018 09:11:02 GMT) Full text and rfc822 format available.

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

From: ludo <at> gnu.org (Ludovic Courtès)
To: Christopher Baines <mail <at> cbaines.net>
Cc: 30702 <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Tue, 12 Jun 2018 11:09:55 +0200
Christopher Baines <mail <at> cbaines.net> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> Hello,
>>
>> Christopher Baines <mail <at> cbaines.net> skribis:
>>
>>> This helpful when adding content to the nginx configuration file, which isn't
>>> supported by the record type used for the configuration.  For example, like
>>> adding proxy_cache_path configuration.
>>>
>>> * gnu/packages/web.scm (<nginx-configuration>): Add new extra-content field.
>>>   (nginx-configuration-extra-content): New field accessor.
>>>   (default-nginx-config): Add support for the extra-content field.
>>> * doc/guix.texi (NGINX): Document the new extra-content field.
>>
>> [...]
>>
>>> +@item @code{extra-content} (default: @code{""})
>>> +Extra content for the @code{http} block.  Should be string or a string
>>> +valued G-expression.
>>
>> [...]
>>
>>>     (apply mixed-text-file "nginx.conf"
>>>            (flatten
>>>             "user nginx nginx;\n"
>>> @@ -542,7 +546,8 @@ of index files."
>>>             "\n"
>>>             (map emit-nginx-upstream-config upstream-blocks)
>>>             (map emit-nginx-server-config server-blocks)
>>> -           "}\n"
>>> +           extra-content
>>> +           "\n}\n"
>>>             "events {}\n"))))
>>
>> That doesn’t work if ‘extra-content’ is something like:
>>
>>   #~(string-append "foo" bar)
>>
>> does it?
>>
>> My understanding of the doc above was that it intends to allow this.
>> But maybe it doesn’t matter after all?
>
> So... I've finally got back around to looking at this, and as far as I
> can see, it does work. extra-content is passed as one of the arguments
> to mixed-text-file, which accepts G-exp things.

Alright, sounds good then!

Thanks,
Ludo’.




Reply sent to Christopher Baines <mail <at> cbaines.net>:
You have taken responsibility. (Tue, 12 Jun 2018 20:23:01 GMT) Full text and rfc822 format available.

Notification sent to Christopher Baines <mail <at> cbaines.net>:
bug acknowledged by developer. (Tue, 12 Jun 2018 20:23:02 GMT) Full text and rfc822 format available.

Message #34 received at 30702-done <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 30702-done <at> debbugs.gnu.org
Subject: Re: [bug#30702] [PATCH] services: nginx: Support extra content in the
 http block.
Date: Tue, 12 Jun 2018 21:22:01 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Alright, sounds good then!

Great, I've pushed this patch now :)
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 11 Jul 2018 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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