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>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#71676] [PATCH v3] services: nginx-upstream-configuration: Allow file-like objects
Date: Sun,  6 Oct 2024 17:22:57 +0200	[thread overview]
Message-ID: <734857b0ef0cc747f01f5cd45f6776fce89a9e64.1728228177.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.
v3: Rebase on latest master.

 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 52e36e4354..b45b7c2c93 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -32229,7 +32229,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 cc6f4e6d9b..39c0035405 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -703,8 +703,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.46.0




  parent reply	other threads:[~2024-10-06 15:24 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 ` [bug#71676] [PATCH v2] " Tomas Volf
2024-10-06 15:22 ` Tomas Volf [this message]
2024-11-20 22:41   ` bug#71676: [PATCH v3] " 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='734857b0ef0cc747f01f5cd45f6776fce89a9e64.1728228177.git.~@wolfsden.cz' \
    --to=~@wolfsden.cz \
    --cc=71676@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --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.