services: nginx: Print extra-content before the server-blocks.

The configuration file is processed sequentially, which meant that there was
no way to set for example log format shared between the server-blocks, because
the final configuration file would have this order:

  ...
  http {
    ...
    server {
    }
    ...
    $extra-content
  }

Moving the extra-content before the serialization of server-blocks resolves
this.

* gnu/services/web.scm (default-nginx-config): Move extra-content before
server-blocks.

Change-Id: Ie8286a533dfed575abc58a0f4800706b3ad6adc2
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Tomas Volf 2024-10-06 17:40:14 +02:00 committed by Ludovic Courtès
parent b5e7f2a65a
commit 123dcaefe9
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -771,10 +771,7 @@ (define (default-nginx-config config)
(number->string server-names-hash-bucket-max-size) (number->string server-names-hash-bucket-max-size)
";\n") ";\n")
"") "")
"\n" (match extra-content
(map emit-nginx-upstream-config upstream-blocks)
(map emit-nginx-server-config server-blocks)
(match extra-content
((? list? extra-content) ((? list? extra-content)
(map (lambda (line) (map (lambda (line)
`(" " ,line "\n")) `(" " ,line "\n"))
@ -782,7 +779,10 @@ (define (default-nginx-config config)
;; XXX: For compatibility strings and gexp's are inserted ;; XXX: For compatibility strings and gexp's are inserted
;; directly. ;; directly.
(_ extra-content)) (_ extra-content))
"\n}\n")))) "\n"
(map emit-nginx-upstream-config upstream-blocks)
(map emit-nginx-server-config server-blocks)
"}\n"))))
(define %nginx-accounts (define %nginx-accounts
(list (user-group (name "nginx") (system? #t)) (list (user-group (name "nginx") (system? #t))