Subject: [bug#30702] [PATCH] services: nginx: Support extra content in the http block.

From: [email-masked] (Ludovic Courtès)
Date: Sun, 18 Mar 2018 18:12:42 +0100

Christopher Baines <[email-masked]> skribis:

> Ludovic Courtès <[email-masked]> 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’.