all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: 71676@debbugs.gnu.org
Cc: "Tomas Volf" <~@wolfsden.cz>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#71676] [PATCH v2] services: nginx-upstream-configuration: Allow file-like objects
Date: Thu, 20 Jun 2024 22:23:04 +0200	[thread overview]
Message-ID: <dfac4975cfbf673abbccc2efe3c948574fc70982.1718914984.git.~@wolfsden.cz> (raw)
In-Reply-To: <a74a949e28dc0f0a546ce35fefb4492e25435c01.1718888643.git.~@wolfsden.cz>

* gnu/services/web.scm (emit-nginx-upstream-config): Support file-like
objects.
* doc/guix.texi (Web Services)[nginx-upstream-configuration]: Document it.

Change-Id: I49996e358174dc77b31e3c91b908a6a72f3eb705
---
v2: Keep support for plain string or file-like object.  I did not realize
    that flatten also accepts non-lists and wraps them in a list.

 doc/guix.texi        | 11 ++++++++++-
 gnu/services/web.scm |  6 ++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 55710dc968..f6f2788ed2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -32095,7 +32095,16 @@ Web Services
 explicitly.

 @item @code{extra-content}
-A string or list of strings to add to the upstream block.
+Additional content to be appended to the upstream block.  Can be a
+string or file-like object or list of thereof.  In case of list, each
+item is prefixed with indentation and suffixed with a new line.  Nested
+lists are flattened.
+
+@lisp
+(extra-content "include /etc/nginx/custom-config.conf;")
+(extra-content `("include /etc/nginx/custom-config.conf;"
+                 ("include " ,%custom-config.conf ";")))
+@end lisp

 @end table
 @end deftp
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 340988fdd8..8d81c926e8 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -701,8 +701,10 @@ (define (emit-nginx-upstream-config upstream)
          (cons
           "\n"
           (map (lambda (line)
-                 (simple-format #f "      ~A\n" line))
-               (flatten extra-content)))
+                 `("      " ,line "\n"))
+               (if (list? extra-content)
+                   extra-content
+                   (list extra-content))))
          '()))
    "    }\n"))

--
2.45.1




  reply	other threads:[~2024-06-20 20:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 13:04 [bug#71676] [PATCH] services: nginx-upstream-configuration: Allow file-like objects Tomas Volf
2024-06-20 20:23 ` Tomas Volf [this message]
2024-10-06 15:22 ` [bug#71676] [PATCH v3] " Tomas Volf
2024-11-20 22:41   ` bug#71676: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='dfac4975cfbf673abbccc2efe3c948574fc70982.1718914984.git.~@wolfsden.cz' \
    --to=~@wolfsden.cz \
    --cc=71676@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=pelzflorian@pelzflorian.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.