From 7747a416feae7139c2b2661ffeb37f2eb03eb2f9 Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Sun, 6 Oct 2019 15:31:23 +0200 Subject: [PATCH 2/2] services: Make it possible to include dynamic modules in nginx. * gnu/services/web.scm (): Add load-modules field. (nginx-configuration-load-modules): New field accessor. (emit-load-module): New procedure. (default-nginx-config): Add support for the load-modules field. * doc/guix.texi (NGINX): Document it. --- doc/guix.texi | 4 ++++ gnu/services/web.scm | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 42d2d77ae6..5c39e26155 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19718,6 +19718,10 @@ use the size of the processors cache line. @item @code{server-names-hash-bucket-max-size} (default: @code{#f}) Maximum bucket size for the server names hash tables. +@item @code{load-modules} (default: @code{'()}) +List of nginx dynamic modules to load. Should be a list of strings or +string valued G-expressions. + @item @code{extra-content} (default: @code{""}) Extra content for the @code{http} block. Should be string or a string valued G-expression. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 899be1c168..a68f0235b7 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2018 Pierre-Antoine Rouby ;;; Copyright © 2017, 2018, 2019 Christopher Baines ;;; Copyright © 2018 Marius Bakke +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -95,6 +96,7 @@ nginx-configuration-upstream-blocks nginx-configuration-server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-max-size + nginx-configuration-load-modules nginx-configuration-extra-content nginx-configuration-file @@ -522,6 +524,7 @@ (default #f)) (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size (default #f)) + (load-modules nginx-configuration-load-modules (default '())) (extra-content nginx-configuration-extra-content (default "")) (file nginx-configuration-file ;#f | string | file-like @@ -542,6 +545,9 @@ of index files." ((? string? str) (list str " "))) names)) +(define (emit-load-module module) + (list "load_module " module ";\n")) + (define emit-nginx-location-config (match-lambda (($ uri body) @@ -615,12 +621,14 @@ of index files." server-blocks upstream-blocks server-names-hash-bucket-size server-names-hash-bucket-max-size + load-modules extra-content) (apply mixed-text-file "nginx.conf" (flatten "user nginx nginx;\n" "pid " run-directory "/pid;\n" "error_log " log-directory "/error.log info;\n" + (map emit-load-module load-modules) "http {\n" " client_body_temp_path " run-directory "/client_body_temp;\n" " proxy_temp_path " run-directory "/proxy_temp;\n" -- 2.23.0