all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
@ 2018-03-04 20:00 Christopher Baines
  2018-03-17 21:42 ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2018-03-04 20:00 UTC (permalink / raw)
  To: 30702

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

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-03-04 20:00 [bug#30702] [PATCH] services: nginx: Support extra content in the http block Christopher Baines
@ 2018-03-17 21:42 ` Ludovic Courtès
  2018-03-17 23:46   ` Christopher Baines
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ludovic Courtès @ 2018-03-17 21:42 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 30702

Hello,

Christopher Baines <mail@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’.

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-03-17 21:42 ` Ludovic Courtès
@ 2018-03-17 23:46   ` Christopher Baines
  2018-03-18 17:12     ` Ludovic Courtès
  2018-05-18  8:54   ` Christopher Baines
  2018-05-18  9:37   ` [bug#30702] " Christopher Baines
  2 siblings, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2018-03-17 23:46 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30702

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


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

> Hello,
>
> Christopher Baines <mail@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?

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

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-03-17 23:46   ` Christopher Baines
@ 2018-03-18 17:12     ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2018-03-18 17:12 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 30702

Christopher Baines <mail@cbaines.net> skribis:

> Ludovic Courtès <ludo@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’.

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-03-17 21:42 ` Ludovic Courtès
  2018-03-17 23:46   ` Christopher Baines
@ 2018-05-18  8:54   ` Christopher Baines
  2018-05-19 20:36     ` Ludovic Courtès
  2018-05-18  9:37   ` [bug#30702] " Christopher Baines
  2 siblings, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2018-05-18  8:54 UTC (permalink / raw)
  To: 30702

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

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-03-17 21:42 ` Ludovic Courtès
  2018-03-17 23:46   ` Christopher Baines
  2018-05-18  8:54   ` Christopher Baines
@ 2018-05-18  9:37   ` Christopher Baines
  2 siblings, 0 replies; 10+ messages in thread
From: Christopher Baines @ 2018-05-18  9:37 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30702

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


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

> Hello,
>
> Christopher Baines <mail@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.

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

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-05-18  8:54   ` Christopher Baines
@ 2018-05-19 20:36     ` Ludovic Courtès
  2018-06-11 18:09       ` Christopher Baines
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2018-05-19 20:36 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 30702

Hello,

Christopher Baines <mail@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’.

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-05-19 20:36     ` Ludovic Courtès
@ 2018-06-11 18:09       ` Christopher Baines
  2018-06-12  9:09         ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2018-06-11 18:09 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30702

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


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

> Hello,
>
> Christopher Baines <mail@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.

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

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

* [bug#30702] [PATCH] services: nginx: Support extra content in the http block.
  2018-06-11 18:09       ` Christopher Baines
@ 2018-06-12  9:09         ` Ludovic Courtès
  2018-06-12 20:22           ` bug#30702: " Christopher Baines
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2018-06-12  9:09 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 30702

Christopher Baines <mail@cbaines.net> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hello,
>>
>> Christopher Baines <mail@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’.

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

* bug#30702: [PATCH] services: nginx: Support extra content in the http block.
  2018-06-12  9:09         ` Ludovic Courtès
@ 2018-06-12 20:22           ` Christopher Baines
  0 siblings, 0 replies; 10+ messages in thread
From: Christopher Baines @ 2018-06-12 20:22 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30702-done

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


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

> Alright, sounds good then!

Great, I've pushed this patch now :)

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

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

end of thread, other threads:[~2018-06-12 20:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-04 20:00 [bug#30702] [PATCH] services: nginx: Support extra content in the http block Christopher Baines
2018-03-17 21:42 ` Ludovic Courtès
2018-03-17 23:46   ` Christopher Baines
2018-03-18 17:12     ` Ludovic Courtès
2018-05-18  8:54   ` Christopher Baines
2018-05-19 20:36     ` Ludovic Courtès
2018-06-11 18:09       ` Christopher Baines
2018-06-12  9:09         ` Ludovic Courtès
2018-06-12 20:22           ` bug#30702: " Christopher Baines
2018-05-18  9:37   ` [bug#30702] " Christopher Baines

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.