guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#71676] [PATCH v3] services: nginx-upstream-configuration: Allow fil


From: Tomas Volf
Subject: [bug#71676] [PATCH v3] services: nginx-upstream-configuration: Allow file-like objects
Date: Sun, 6 Oct 2024 17:22:57 +0200

* 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]