guix-patches
[Top][All Lists]
Advanced

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

[bug#71586] [PATCH v3] services: web: Improve nginx formatting for extra


From: Richard Sent
Subject: [bug#71586] [PATCH v3] services: web: Improve nginx formatting for extra-content
Date: Thu, 20 Jun 2024 12:42:03 -0400

When extra-content is a list, add 4 space indentation and a newline to every
line. If it's a string, continue inserting it directly. This makes the list
serialization behavior more consistent with other services.

* gnu/services/web (default-nginx-config): Support lists.
* doc/guix.texi (Web Services) [nginx-configuration]: Document it.

Change-Id: Iec8614ba3cfc37292a566197e8d39b352b04846a
---
 doc/guix.texi        | 13 +++++++++++--
 gnu/services/web.scm |  9 ++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0102fd0fad..48fc457627 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -31907,8 +31907,17 @@ Web Services
 @end lisp
 
 @item @code{extra-content} (default: @code{""})
-Extra content for the @code{http} block.  Should be string or a string
-valued G-expression.
+Additional content to be appended to the @code{http} block.  Can either
+be a value that can be lowered into a string or a list of such values.
+In the former case, it is inserted directly.  In the latter, it is
+prefixed with indentation and suffixed with a newline.  Nested lists are
+flattened into one line.
+
+@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 406117c457..ee3499e5cd 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -771,7 +771,14 @@ (define (default-nginx-config config)
            "\n"
            (map emit-nginx-upstream-config upstream-blocks)
            (map emit-nginx-server-config server-blocks)
-           extra-content
+           (match extra-content
+             ((? list? extra-content)
+              (map (lambda (line)
+                     `("    " ,line "\n"))
+                   extra-content))
+             ;; XXX: For compatibility strings and gexp's are inserted
+             ;; directly.
+             (_ extra-content))
            "\n}\n"))))
 
 (define %nginx-accounts

base-commit: e32e3d0a03dc17c4c54a91aad053c9036998b601
-- 
2.45.1






reply via email to

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