From 08c597d7e008d8c0087e75dc56c3fd7a754e47bd Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Wed, 6 Dec 2017 19:00:30 +0100 Subject: doc: Fix typo. * doc/guix.texi (Package Management): Fix typo. --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index c14df7fcd..23ccfa2f6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1550,7 +1550,7 @@ features. This chapter describes the main features of Guix, as well as the package management tools it provides. Along with the command-line interface described below (@pxref{Invoking guix package, @code{guix -package}}), you may also use Emacs Interface (@pxref{Top,,, +package}}), you may also use the Emacs-Guix interface (@pxref{Top,,, emacs-guix, The Emacs-Guix Reference Manual}), after installing @code{emacs-guix} package (run @kbd{M-x guix-help} command to start with it): -- cgit v1.3 From c48aa70a9aa68ac6f365663044357be77eb9e36a Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 9 Dec 2017 09:24:07 +0000 Subject: services: web: Remove default certificate and key files for nginx. If nginx is configured with a ssl-certificate file, and ssl-certificate-key, it will fail to start unless these exist. To avoid this happening, change the default to #f. * gnu/services/web.scm () [ssl-certificate,ssl-certificate-key]: Set the defaults to #f. * gnu/tests/web.scm (%nginx-servers): Remove redundant nginx-server-configuration fields. * doc/guix.texi (Web Services): Update examples and documentation. --- doc/guix.texi | 20 ++++---------------- gnu/services/web.scm | 4 ++-- gnu/tests/web.scm | 5 +---- 3 files changed, 7 insertions(+), 22 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 23ccfa2f6..35f895bb4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14813,10 +14813,7 @@ A simple example configuration is given below. (server-blocks (list (nginx-server-configuration (server-name '("www.example.com")) - (root "/srv/http/www.example.com") - (https-port #f) - (ssl-certificate #f) - (ssl-certificate-key #f)))))) + (root "/srv/http/www.example.com")))))) @end example In addition to adding server blocks to the service configuration @@ -14826,9 +14823,6 @@ blocks, as in this example: @example (simple-service 'my-extra-server nginx-service-type (list (nginx-server-configuration - (https-port #f) - (ssl-certificate #f) - (ssl-certificate-key #f) (root "/srv/http/extra-website") (try-files (list "$uri" "$uri/index.html"))))) @end example @@ -14873,10 +14867,7 @@ HTTPS. (server-blocks (list (nginx-server-configuration (server-name '("www.example.com")) - (root "/srv/http/www.example.com") - (https-port #f) - (ssl-certificate #f) - (ssl-certificate-key #f)))))) + (root "/srv/http/www.example.com")))))) @end example @item @code{upstream-blocks} (default: @code{'()}) @@ -14899,9 +14890,6 @@ requests with two servers. (list (nginx-server-configuration (server-name '("www.example.com")) (root "/srv/http/www.example.com") - (https-port #f) - (ssl-certificate #f) - (ssl-certificate-key #f) (locations (list (nginx-location-configuration @@ -14965,11 +14953,11 @@ Nginx will send the list of files in the directory. A list of files whose existence is checked in the specified order. @code{nginx} will use the first file it finds to process the request. -@item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) +@item @code{ssl-certificate} (default: @code{#f}) Where to find the certificate for secure connections. Set it to @code{#f} if you don't have a certificate or you don't want to use HTTPS. -@item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) +@item @code{ssl-certificate-key} (default: @code{#f}) Where to find the private key for secure connections. Set it to @code{#f} if you don't have a key or you don't want to use HTTPS. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 1af32278c..51cd9da1d 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -102,9 +102,9 @@ (try-files nginx-server-configuration-try-files (default '())) (ssl-certificate nginx-server-configuration-ssl-certificate - (default "/etc/nginx/cert.pem")) + (default #f)) (ssl-certificate-key nginx-server-configuration-ssl-certificate-key - (default "/etc/nginx/key.pem")) + (default #f)) (server-tokens? nginx-server-configuration-server-tokens? (default #f))) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index 3fa272c67..de7ab3cd6 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -45,10 +45,7 @@ ;; Server blocks. (list (nginx-server-configuration (root "/srv") - (http-port 8042) - (https-port #f) - (ssl-certificate #f) - (ssl-certificate-key #f)))) + (http-port 8042)))) (define %nginx-os ;; Operating system under test. -- cgit v1.3 From 2881f85220c05809527d2f2a8b8d71b7a67bc604 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 25 Nov 2017 11:57:37 +0000 Subject: services: web: Add support for configuring the nginx server names hash. The nginx service can fail to start if the server names hash bucket size is too small, which can happen on some systems, and when using QEMU, depending on the CPU. * gnu/services/web.scm (): Add server-names-hash-bucket-size and server-names-hash-bucket-max-size. (default-nginx-config): Add support for the new hash bucket size parameters. (nginx-service, nginx-activation): Pass the new hash bucket size parameters through to the default-nginx-config procedure. * doc/guix.texi (Web Services): Document the new hash bucket size parameters. --- doc/guix.texi | 7 +++++++ gnu/services/web.scm | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 35f895bb4..592cae5d5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14913,6 +14913,13 @@ This can be useful if you have an existing configuration file, or it's not possible to do what is required through the other parts of the nginx-configuration record. +@item @code{server-names-hash-bucket-size} (default: @code{#f}) +Bucket size for the server names hash tables, defaults to @code{#f} to +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. + @end table @end deffn diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 51cd9da1d..969208428 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -38,6 +38,8 @@ nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks + nginx-configuration-server-names-hash-bucket-size + nginx-configuration-server-names-hash-bucket-max-size nginx-configuration-file @@ -141,6 +143,10 @@ (default '())) ;list of (upstream-blocks nginx-configuration-upstream-blocks (default '())) ;list of + (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size + (default #f)) + (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size + (default #f)) (file nginx-configuration-file ;#f | string | file-like (default #f))) @@ -225,7 +231,9 @@ of index files." (cons head out))) (fold-right flatten1 '() lst)) -(define (default-nginx-config nginx log-directory run-directory server-list upstream-list) +(define (default-nginx-config nginx log-directory run-directory server-list + upstream-list server-names-hash-bucket-size + server-names-hash-bucket-max-size) (apply mixed-text-file "nginx.conf" (flatten "user nginx nginx;\n" @@ -239,6 +247,18 @@ of index files." " scgi_temp_path " run-directory "/scgi_temp;\n" " access_log " log-directory "/access.log;\n" " include " nginx "/share/nginx/conf/mime.types;\n" + (if server-names-hash-bucket-size + (string-append + " server_names_hash_bucket_size " + (number->string server-names-hash-bucket-size) + ";\n") + "") + (if server-names-hash-bucket-max-size + (string-append + " server_names_hash_bucket_max_size " + (number->string server-names-hash-bucket-max-size) + ";\n") + "") "\n" (map emit-nginx-upstream-config upstream-list) (map emit-nginx-server-config server-list) @@ -258,7 +278,8 @@ of index files." (define nginx-activation (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) #~(begin (use-modules (guix build utils)) @@ -279,13 +300,16 @@ of index files." (system* (string-append #$nginx "/sbin/nginx") "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) "-t"))))) (define nginx-shepherd-service (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) (nginx-action (lambda args @@ -294,7 +318,9 @@ of index files." (system* #$nginx-binary "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) #$@args)))))) ;; TODO: Add 'reload' action. -- cgit v1.3 From 64bae7237c65b32d97e16ff6802124c26867754a Mon Sep 17 00:00:00 2001 From: nee Date: Mon, 9 Oct 2017 23:06:05 +0200 Subject: gnu: services: Add php-fpm. * gnu/services/web.scm (, ): New record types. (php-fpm-configuration?, php-fpm-process-manager-configuration?, php-fpm-service-type, nginx-php-location): New procedures. * doc/guix.texi (Web-Services): Document php-fpm service. * gnu/tests/web.scm: Add php-fpm system test. Signed-off-by: Christopher Baines --- doc/guix.texi | 140 +++++++++++++++++++++++++++++ gnu/services/web.scm | 247 ++++++++++++++++++++++++++++++++++++++++++++++++++- gnu/tests/web.scm | 123 ++++++++++++++++++++++++- 3 files changed, 508 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 592cae5d5..bbeef47ec 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -44,6 +44,7 @@ Copyright @copyright{} 2017 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* Copyright @copyright{} 2017 Arun Isaac +Copyright @copyright{} 2017 nee Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -15081,6 +15082,145 @@ capability also has to be configured on the front-end as well. @end table @end deftp +@cindex php-fpm +PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation +with some additional features useful for sites of any size. + +These features include: +@itemize @bullet +@item Adaptive process spawning +@item Basic statistics (similar to Apache's mod_status) +@item Advanced process management with graceful stop/start +@item Ability to start workers with different uid/gid/chroot/environment +and different php.ini (replaces safe_mode) +@item Stdout & stderr logging +@item Emergency restart in case of accidental opcode cache destruction +@item Accelerated upload support +@item Support for a "slowlog" +@item Enhancements to FastCGI, such as fastcgi_finish_request() - +a special function to finish request & flush all data while continuing to do +something time-consuming (video converting, stats processing, etc.) +@end itemize +... and much more. + +@defvr {Scheme Variable} php-fpm-service-type +A Service type for @code{php-fpm}. +@end defvr + +@deftp {Data Type} php-fpm-configuration +Data Type for php-fpm service configuration. +@table @asis +@item @code{php} (default: @code{php}) +The php package to use. +@item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")}) +The address on which to accept FastCGI requests. Valid syntaxes are: +@table @asis +@item @code{"ip.add.re.ss:port"} +Listen on a TCP socket to a specific address on a specific port. +@item @code{"port"} +Listen on a TCP socket to all addresses on a specific port. +@item @code{"/path/to/unix/socket"} +Listen on a unix socket. +@end table + +@item @code{user} (default: @code{php-fpm}) +User who will own the php worker processes. +@item @code{group} (default: @code{php-fpm}) +Group of the worker processes. +@item @code{socket-user} (default: @code{php-fpm}) +User who can speak to the php-fpm socket. +@item @code{socket-group} (default: @code{php-fpm}) +Group that can speak to the php-fpm socket. +@item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")}) +The process id of the php-fpm process is written to this file +once the service has started. +@item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")}) +Log for the php-fpm master process. +@item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)}) +Detailed settings for the php-fpm process manager. +Must be either: +@table @asis +@item @code{} +@item @code{} +@item @code{} +@end table +@item @code{display-errors} (default @code{#f}) +Determines wether php errors and warning should be sent to clients +and displayed in their browsers. +This is useful for local php development, but a security risk for public sites, +as error messages can reveal passwords and personal data. +@item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")}) +This file will log the @code{stderr} outputs of php worker processes. +Can be set to @code{#f} to disable logging. +@item @code{file} (default @code{#f}) +An optional override of the whole configuration. +You can use the @code{mixed-text-file} function or an absolute filepath for it. +@end table +@end deftp + +@deftp {Data type} php-fpm-dynamic-process-manager-configuration +Data Type for the @code{dynamic} php-fpm process manager. With the +@code{dynamic} process manager, spare worker processes are kept around +based on it's configured limits. +@table @asis +@item @code{max-children} (default: @code{5}) +Maximum of worker processes. +@item @code{start-servers} (default: @code{2}) +How many worker processes should be started on start-up. +@item @code{min-spare-servers} (default: @code{1}) +How many spare worker processes should be kept around at minimum. +@item @code{max-spare-servers} (default: @code{3}) +How many spare worker processes should be kept around at maximum. +@end table +@end deftp + +@deftp {Data type} php-fpm-static-process-manager-configuration +Data Type for the @code{static} php-fpm process manager. With the +@code{static} process manager, an unchanging number of worker processes +are created. +@table @asis +@item @code{max-children} (default: @code{5}) +Maximum of worker processes. +@end table +@end deftp + +@deftp {Data type} php-fpm-on-demand-process-manager-configuration +Data Type for the @code{on-demand} php-fpm process manager. With the +@code{on-demand} process manager, worker processes are only created as +requests arrive. +@table @asis +@item @code{max-children} (default: @code{5}) +Maximum of worker processes. +@item @code{process-idle-timeout} (default: @code{10}) +The time in seconds after which a process with no requests is killed. +@end table +@end deftp + + +@deffn {Scheme Procedure} nginx-php-fpm-location @ + [#:nginx-package nginx] @ + [socket (string-append "/var/run/php" @ + (version-major (package-version php)) @ + "-fpm.sock")] +A helper function to quickly add php to an @code{nginx-server-configuration}. +@end deffn + +A simple services setup for nginx with php can look like this: +@example +(services (cons* (dhcp-client-service) + (service php-fpm-service-type) + (service nginx-service-type + (nginx-server-configuration + (server-name '("example.com")) + (root "/srv/http/") + (locations + (list (nginx-php-location))) + (https-port #f) + (ssl-certificate #f) + (ssl-certificate-key #f))) + %base-services)) +@end example + @node Certificate Services @subsubsection Certificate Services diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 7f338039e..582cf535c 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2016 ng0 ;;; Copyright © 2016, 2017 Julien Lepiller ;;; Copyright © 2017 Christopher Baines +;;; Copyright © 2017 nee ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,8 +27,11 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages web) + #:use-module (gnu packages php) #:use-module (guix records) #:use-module (guix gexp) + #:use-module ((guix utils) #:select (version-major)) + #:use-module ((guix packages) #:select (package-version)) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export ( @@ -78,7 +82,49 @@ fcgiwrap-configuration fcgiwrap-configuration? - fcgiwrap-service-type)) + fcgiwrap-service-type + + + php-fpm-configuration + make-php-fpm-configuration + php-fpm-configuration? + php-fpm-configuration-php + php-fpm-configuration-socket + php-fpm-configuration-user + php-fpm-configuration-group + php-fpm-configuration-socket-user + php-fpm-configuration-socket-group + php-fpm-configuration-pid-file + php-fpm-configuration-log-file + php-fpm-configuration-process-manager + php-fpm-configuration-display-errors + php-fpm-configuration-workers-log-file + php-fpm-configuration-file + + + php-fpm-dynamic-process-manager-configuration + make-php-fpm-dynamic-process-manager-configuration + php-fpm-dynamic-process-manager-configuration? + php-fpm-dynamic-process-manager-configuration-max-children + php-fpm-dynamic-process-manager-configuration-start-servers + php-fpm-dynamic-process-manager-configuration-min-spare-servers + php-fpm-dynamic-process-manager-configuration-max-spare-servers + + + php-fpm-static-process-manager-configuration + make-php-fpm-static-process-manager-configuration + php-fpm-static-process-manager-configuration? + php-fpm-static-process-manager-configuration-max-children + + + php-fpm-on-demand-process-manager-configuration + make-php-fpm-on-demand-process-manager-configuration + php-fpm-on-demand-process-manager-configuration? + php-fpm-on-demand-process-manager-configuration-max-children + php-fpm-on-demand-process-manager-configuration-process-idle-timeout + + php-fpm-service-type + nginx-php-location)) ;;; Commentary: ;;; @@ -397,3 +443,202 @@ of index files." (service-extension account-service-type fcgiwrap-accounts))) (default-value (fcgiwrap-configuration)))) + +(define-record-type* php-fpm-configuration + make-php-fpm-configuration + php-fpm-configuration? + (php php-fpm-configuration-php ; + (default php)) + (socket php-fpm-configuration-socket + (default (string-append "/var/run/php" + (version-major (package-version php)) + "-fpm.sock"))) + (user php-fpm-configuration-user + (default "php-fpm")) + (group php-fpm-configuration-group + (default "php-fpm")) + (socket-user php-fpm-configuration-socket-user + (default "php-fpm")) + (socket-group php-fpm-configuration-socket-group + (default "nginx")) + (pid-file php-fpm-configuration-pid-file + (default (string-append "/var/run/php" + (version-major (package-version php)) + "-fpm.pid"))) + (log-file php-fpm-configuration-log-file + (default (string-append "/var/log/php" + (version-major (package-version php)) + "-fpm.log"))) + (process-manager php-fpm-configuration-process-manager + (default (php-fpm-dynamic-process-manager-configuration))) + (display-errors php-fpm-configuration-display-errors + (default #f)) + (workers-log-file php-fpm-configuration-workers-log-file + (default (string-append "/var/log/php" + (version-major (package-version php)) + "-fpm.www.log"))) + (file php-fpm-configuration-file ;#f | file-like + (default #f))) + +(define-record-type* + php-fpm-dynamic-process-manager-configuration + make-php-fpm-dynamic-process-manager-configuration + php-fpm-dynamic-process-manager-configuration? + (max-children php-fpm-dynamic-process-manager-configuration-max-children + (default 5)) + (start-servers php-fpm-dynamic-process-manager-configuration-start-servers + (default 2)) + (min-spare-servers php-fpm-dynamic-process-manager-configuration-min-spare-servers + (default 1)) + (max-spare-servers php-fpm-dynamic-process-manager-configuration-max-spare-servers + (default 3))) + +(define-record-type* + php-fpm-static-process-manager-configuration + make-php-fpm-static-process-manager-configuration + php-fpm-static-process-manager-configuration? + (max-children php-fpm-static-process-manager-configuration-max-children + (default 5))) + +(define-record-type* + php-fpm-on-demand-process-manager-configuration + make-php-fpm-on-demand-process-manager-configuration + php-fpm-on-demand-process-manager-configuration? + (max-children php-fpm-on-demand-process-manager-configuration-max-children + (default 5)) + (process-idle-timeout php-fpm-on-demand-process-manager-configuration-process-idle-timeout + (default 10))) + +(define php-fpm-accounts + (match-lambda + (($ php socket user group socket-user socket-group _ _ _ _ _ _) + (list + (user-group (name "php-fpm") (system? #t)) + (user-group + (name group) + (system? #t)) + (user-account + (name user) + (group group) + (supplementary-groups '("php-fpm")) + (system? #t) + (comment "php-fpm daemon user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))))) + +(define (default-php-fpm-config socket user group socket-user socket-group + pid-file log-file pm display-errors workers-log-file) + (apply mixed-text-file "php-fpm.conf" + (flatten + "[global]\n" + "pid =" pid-file "\n" + "error_log =" log-file "\n" + "[www]\n" + "user =" user "\n" + "group =" group "\n" + "listen =" socket "\n" + "listen.owner =" socket-user "\n" + "listen.group =" socket-group "\n" + + (match pm + (($ + pm.max-children + pm.start-servers + pm.min-spare-servers + pm.max-spare-servers) + (list + "pm = dynamic\n" + "pm.max_children =" (number->string pm.max-children) "\n" + "pm.start_servers =" (number->string pm.start-servers) "\n" + "pm.min_spare_servers =" (number->string pm.min-spare-servers) "\n" + "pm.max_spare_servers =" (number->string pm.max-spare-servers) "\n")) + + (($ + pm.max-children) + (list + "pm = static\n" + "pm.max_children =" (number->string pm.max-children) "\n")) + + (($ + pm.max-children + pm.process-idle-timeout) + (list + "pm = ondemand\n" + "pm.max_children =" (number->string pm.max-children) "\n" + "pm.process_idle_timeout =" (number->string pm.process-idle-timeout) "s\n"))) + + + "php_flag[display_errors] = " (if display-errors "on" "off") "\n" + + (if workers-log-file + (list "catch_workers_output = yes\n" + "php_admin_value[error_log] =" workers-log-file "\n" + "php_admin_flag[log_errors] = on\n") + (list "catch_workers_output = no\n"))))) + +(define php-fpm-shepherd-service + (match-lambda + (($ php socket user group socket-user socket-group + pid-file log-file pm display-errors workers-log-file file) + (list (shepherd-service + (provision '(php-fpm)) + (documentation "Run the php-fpm daemon.") + (requirement '(networking)) + (start #~(make-forkexec-constructor + '(#$(file-append php "/sbin/php-fpm") + "--fpm-config" + #$(or file + (default-php-fpm-config socket user group + socket-user socket-group pid-file log-file + pm display-errors workers-log-file))) + #:pid-file #$pid-file)) + (stop #~(make-kill-destructor))))))) + +(define php-fpm-activation + (match-lambda + (($ _ _ user _ _ _ _ log-file _ _ workers-log-file _) + #~(begin + (use-modules (guix build utils)) + (let* ((user (getpwnam #$user)) + (touch (lambda (file-name) + (call-with-output-file file-name (const #t)))) + (init-log-file + (lambda (file-name) + (when #$workers-log-file + (when (not (file-exists? file-name)) + (touch file-name)) + (chown file-name (passwd:uid user) (passwd:gid user)) + (chmod file-name #o660))))) + (init-log-file #$log-file) + (init-log-file #$workers-log-file)))))) + + +(define php-fpm-service-type + (service-type + (name 'php-fpm) + (description + "Run @command{php-fpm} to provide a fastcgi socket for calling php through +a webserver.") + (extensions + (list (service-extension shepherd-root-service-type + php-fpm-shepherd-service) + (service-extension activation-service-type + php-fpm-activation) + (service-extension account-service-type + php-fpm-accounts))) + (default-value (php-fpm-configuration)))) + +(define* (nginx-php-location + #:key + (nginx-package nginx) + (socket (string-append "/var/run/php" + (version-major (package-version php)) + "-fpm.sock"))) + "Return a nginx-location-configuration that makes nginx run .php files." + (nginx-location-configuration + (uri "~ \\.php$") + (body (list + "fastcgi_split_path_info ^(.+\\.php)(/.+)$;" + (string-append "fastcgi_pass unix:" socket ";") + "fastcgi_index index.php;" + (list "include " nginx-package "/share/nginx/conf/fastcgi.conf;"))))) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index de7ab3cd6..e975cb830 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Ludovic Courtès +;;; Copyright © 2017 Christopher Baines ;;; ;;; This file is part of GNU Guix. ;;; @@ -27,7 +28,8 @@ #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) - #:export (%test-nginx)) + #:export (%test-nginx + %test-php-fpm)) (define %index.html-contents ;; Contents of the /index.html file served by nginx. @@ -129,3 +131,122 @@ HTTP-PORT." (name "nginx") (description "Connect to a running NGINX server.") (value (run-nginx-test)))) + + +;;; +;;; PHP-FPM +;;; + +(define %make-php-fpm-http-root + ;; Create our server root in /srv. + #~(begin + (mkdir "/srv") + (call-with-output-file "/srv/index.php" + (lambda (port) + (display "\n" port))))) + +(define %php-fpm-nginx-server-blocks + (list (nginx-server-configuration + (root "/srv") + (locations + (list (nginx-php-location))) + (http-port 8042) + (https-port #f) + (ssl-certificate #f) + (ssl-certificate-key #f)))) + +(define %php-fpm-os + ;; Operating system under test. + (simple-operating-system + (dhcp-client-service) + (service php-fpm-service-type) + (service nginx-service-type + (nginx-configuration + (server-blocks %php-fpm-nginx-server-blocks))) + (simple-service 'make-http-root activation-service-type + %make-php-fpm-http-root))) + +(define* (run-php-fpm-test #:optional (http-port 8042)) + "Run tests in %PHP-FPM-OS, which has nginx running and listening on +HTTP-PORT, along with php-fpm." + (define os + (marionette-operating-system + %php-fpm-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (port-forwardings `((8080 . ,http-port))))) + + (define test + (with-imported-modules '((gnu build marionette) + (guix build utils)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (gnu build marionette) + (web uri) + (web client) + (web response)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "php-fpm") + + (test-assert "php-fpm running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (match (start-service 'php-fpm) + (#f #f) + (('service response-parts ...) + (match (assq-ref response-parts 'running) + ((pid) (number? pid)))))) + marionette)) + + (test-eq "nginx running" + 'running! + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'nginx) + 'running!) + marionette)) + + (test-equal "http-get" + 200 + (let-values (((response text) + (http-get "http://localhost:8080/index.php" + #:decode-body? #t))) + (response-code response))) + + (test-equal "php computed result is sent" + "Computed by php:5" + (let-values (((response text) + (http-get "http://localhost:8080/index.php" + #:decode-body? #t))) + (begin + (use-modules (ice-9 regex)) + (let ((matches (string-match "Computed by php:5" text))) + (and matches + (match:substring matches 0)))))) + + (test-end) + + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "php-fpm-test" test)) + +(define %test-php-fpm + (system-test + (name "php-fpm") + (description "Test PHP-FPM through nginx.") + (value (run-php-fpm-test)))) -- cgit v1.3 From 27c50d87f5f66e5c5b7c97f66c901b0864a789f0 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Tue, 12 Dec 2017 22:35:37 +0100 Subject: doc: Fix typo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi: Add missing ‘@*’ to copyright headers. --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index bbeef47ec..92ac45b1c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -43,7 +43,7 @@ Copyright @copyright{} 2017 Maxim Cournoyer@* Copyright @copyright{} 2017 Tobias Geerinckx-Rice@* Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* -Copyright @copyright{} 2017 Arun Isaac +Copyright @copyright{} 2017 Arun Isaac@* Copyright @copyright{} 2017 nee Permission is granted to copy, distribute and/or modify this document -- cgit v1.3 From dfb403b053eb0ea5e7c052855ba419e6a9968442 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Wed, 13 Dec 2017 08:49:05 +0300 Subject: doc: Fix typo. * doc/guix.texi (DNS Services): Fix knot-configuration. --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 92ac45b1c..7625f30fb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -15341,7 +15341,7 @@ and one slave, is: (operating-system ;; ... (services (cons* (service knot-service-type - (knot-confifguration + (knot-configuration (remotes (list plop-master)) (zones (list master-zone slave-zone)))) ;; ... -- cgit v1.3 From 5a72ddf176d53a7f4df922985d9d7fd4cfa160f5 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 12 Dec 2017 16:06:47 +0100 Subject: scripts: system: Add --expression option. * guix/scripts/system.scm (show-help): Add expression option. (%options): Ditto. (guix-system): Allow commands taking a file as an argument to use an expression instead. (process-action): Read operating-system from expression or file. * doc/guix.texi (Invoking guix system): Introduce the expression option. --- doc/guix.texi | 8 ++++++++ guix/scripts/system.scm | 28 ++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 7625f30fb..64f73b38a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18744,6 +18744,14 @@ Build Options}). In addition, @var{options} can contain one of the following: @table @option +@item --expression=@var{expr} +@itemx -e @var{expr} +Consider the operating-system @var{expr} evaluates to. +This is an alternative to specifying a file which evaluates to an +operating system. +This is used to generate the GuixSD installer @pxref{Building the +Installation Image}). + @item --system=@var{system} @itemx -s @var{system} Attempt to build for @var{system} instead of the host system type. diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index cbf7e6cd0..36aed3331 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -857,6 +857,9 @@ Some ACTIONS support additional ARGS.\n")) (show-build-options-help) (display (G_ " -d, --derivation return the derivation of the given system")) + (display (G_ " + -e, --expression=EXPR consider the operating-system EXPR evaluates to + instead of reading FILE, when applicable")) (display (G_ " --on-error=STRATEGY apply STRATEGY when an error occurs while reading FILE")) @@ -895,6 +898,9 @@ Some ACTIONS support additional ARGS.\n")) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix system"))) + (option '(#\e "expression") #t #f + (lambda (opt name arg result) + (alist-cons 'expression arg result))) (option '(#\d "derivation") #f #f (lambda (opt name arg result) (alist-cons 'derivations-only? #t result))) @@ -964,11 +970,19 @@ resulting from command-line parsing." (let* ((file (match args (() #f) ((x . _) x))) + (expr (assoc-ref opts 'expression)) (system (assoc-ref opts 'system)) - (os (if file - (load* file %user-module - #:on-error (assoc-ref opts 'on-error)) - (leave (G_ "no configuration file specified~%")))) + (os (cond + ((and expr file) + (leave + (G_ "both file and expression cannot be specified~%"))) + (expr + (read/eval expr)) + (file + (load* file %user-module + #:on-error (assoc-ref opts 'on-error))) + (else + (leave (G_ "no configuration specified~%"))))) (dry? (assoc-ref opts 'dry-run?)) (bootloader? (assoc-ref opts 'install-bootloader?)) @@ -1079,7 +1093,8 @@ argument list and OPTS is the option alist." ;; Extract the plain arguments from OPTS. (let* ((args (reverse (filter-map (match-pair 'argument) opts))) (count (length args)) - (action (assoc-ref opts 'action))) + (action (assoc-ref opts 'action)) + (expr (assoc-ref opts 'expression))) (define (fail) (leave (G_ "wrong number of arguments for action '~a'~%") action)) @@ -1093,7 +1108,8 @@ argument list and OPTS is the option alist." (case action ((build container vm vm-image disk-image reconfigure) - (unless (= count 1) + (unless (or (= count 1) + (and expr (= count 0))) (fail))) ((init) (unless (= count 2) -- cgit v1.3 From 42cdcdff1945b112452029c6a79445aac15ffd16 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 15 Dec 2017 23:10:54 +0100 Subject: etc: Add snippets. * etc/snippets/scheme-mode/guix-cvs-reference, etc/snippets/scheme-mode/guix-git-reference, etc/snippets/scheme-mode/guix-hg-reference, etc/snippets/scheme-mode/guix-origin, etc/snippets/scheme-mode/guix-package, etc/snippets/scheme-mode/guix-svn-reference, etc/snippets/text-mode/guix-commit-message-add-package, etc/snippets/text-mode/guix-commit-message-update-package: New files. * doc/contributing.texi (The Perfect Setup): Document snippets. --- doc/contributing.texi | 28 ++++++++++++++++++ etc/snippets/scheme-mode/guix-cvs-reference | 8 +++++ etc/snippets/scheme-mode/guix-git-reference | 7 +++++ etc/snippets/scheme-mode/guix-hg-reference | 7 +++++ etc/snippets/scheme-mode/guix-origin | 23 +++++++++++++++ etc/snippets/scheme-mode/guix-package | 34 ++++++++++++++++++++++ etc/snippets/scheme-mode/guix-svn-reference | 7 +++++ .../text-mode/guix-commit-message-add-package | 8 +++++ .../text-mode/guix-commit-message-update-package | 9 ++++++ 9 files changed, 131 insertions(+) create mode 100644 etc/snippets/scheme-mode/guix-cvs-reference create mode 100644 etc/snippets/scheme-mode/guix-git-reference create mode 100644 etc/snippets/scheme-mode/guix-hg-reference create mode 100644 etc/snippets/scheme-mode/guix-origin create mode 100644 etc/snippets/scheme-mode/guix-package create mode 100644 etc/snippets/scheme-mode/guix-svn-reference create mode 100644 etc/snippets/text-mode/guix-commit-message-add-package create mode 100644 etc/snippets/text-mode/guix-commit-message-update-package (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index 1dd3ea8e1..01f8aad9f 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -193,6 +193,34 @@ facilities to directly operate on the syntax tree, such as raising an s-expression or wrapping it, swallowing or rejecting the following s-expression, etc. +@cindex code snippets +@cindex templates +@cindex reducing boilerplate +We also provide templates for common git commit messages and package +definitions in the @file{etc/snippets} directory. These templates can +be used with @url{http://joaotavora.github.io/yasnippet/, YASnippet} to +expand short trigger strings to interactive text snippets. You may want +to add the snippets directory to the @var{yas-snippet-dirs} variable in +Emacs. + +@lisp +;; @r{Assuming the Guix checkout is in ~/src/guix.} +(with-eval-after-load 'yasnippet + (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets")) +@end lisp + +The commit message snippets depend on @url{https://magit.vc/, Magit} to +display staged files. When editing a commit message type @code{add} +followed by @kbd{TAB} to insert a commit message template for adding a +package; type @code{update} followed by @kbd{TAB} to insert a template +for updating a package. + +The main snippet for @code{scheme-mode} is triggered by typing +@code{package...} followed by @kbd{TAB}. This snippet also inserts the +trigger string @code{origin...}, which can be expanded further. The +@code{origin} snippet in turn may insert other trigger strings ending on +@code{...}, which also can be expanded further. + @node Coding Style @section Coding Style diff --git a/etc/snippets/scheme-mode/guix-cvs-reference b/etc/snippets/scheme-mode/guix-cvs-reference new file mode 100644 index 000000000..fbc5034b6 --- /dev/null +++ b/etc/snippets/scheme-mode/guix-cvs-reference @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: guix-cvs-reference +# key: cvs-reference... +# -- +(cvs-reference + (root-directory "${1:root-directory}") + (module "${2:module}") + (revision "${3:revision}")) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-git-reference b/etc/snippets/scheme-mode/guix-git-reference new file mode 100644 index 000000000..29ca6a9c5 --- /dev/null +++ b/etc/snippets/scheme-mode/guix-git-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-git-reference +# key: git-reference... +# -- +(git-reference + (url "$1") + (commit ${2:commit})) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-hg-reference b/etc/snippets/scheme-mode/guix-hg-reference new file mode 100644 index 000000000..95de16daa --- /dev/null +++ b/etc/snippets/scheme-mode/guix-hg-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-hg-reference +# key: hg-reference... +# -- +(hg-reference + (url "$1") + (changeset ${2:changeset})) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-origin b/etc/snippets/scheme-mode/guix-origin new file mode 100644 index 000000000..68d47135d --- /dev/null +++ b/etc/snippets/scheme-mode/guix-origin @@ -0,0 +1,23 @@ +# -*- mode: snippet -*- +# name: guix-origin +# key: origin... +# -- +(origin + (method ${1:$$(yas-choose-value "url-fetch" + "url-fetch/tarbomb" + "url-fetch/zipbomb" + "cvs-fetch" + "git-fetch" + "hg-fetch" + "svn-fetch")}) + (uri ${1:$(cond ((equal yas-text "git-fetch") "git-reference...") + ((equal yas-text "svn-fetch") "svn-reference...") + ((equal yas-text "hg-fetch") "hg-reference...") + ((equal yas-text "cvs-fetch") "cvs-reference...") + (t "(string-append \\"https://\\" version \\".tar.gz\\")"))}$0) + ${1:$(cond ((member yas-text '("git-fetch" "svn-fetch" "hg-fetch" "cvs-fetch")) + "(file-name (string-append name \\"-\\" version \\"-checkout\\"))") + (t ""))} + (sha256 + (base32 + "$2"))) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-package b/etc/snippets/scheme-mode/guix-package new file mode 100644 index 000000000..d392e8209 --- /dev/null +++ b/etc/snippets/scheme-mode/guix-package @@ -0,0 +1,34 @@ +# -*- mode: snippet -*- +# name: guix-package +# key: package... +# -- +(define-public $1 + (package + (name "$1") + (version "$2") + (source origin...$0) + (build-system ${3:$$(yas-choose-value "ant-build-system" + "asdf-build-system" + "cargo-build-system" + "cmake-build-system" + "dub-build-system" + "emacs-build-system" + "font-build-system" + "glib-or-gtk-build-system" + "gnu-build-system" + "go-build-system" + "haskell-build-system" + "meson-build-system" + "minify-build-system" + "ocaml-build-system" + "perl-build-system" + "python-build-system" + "r-build-system" + "ruby-build-system" + "texlive-build-system" + "trivial-build-system" + "waf-build-system")}) + (home-page "$4") + (synopsis "$5") + (description "$6") + (license $7))) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-svn-reference b/etc/snippets/scheme-mode/guix-svn-reference new file mode 100644 index 000000000..7d897dc69 --- /dev/null +++ b/etc/snippets/scheme-mode/guix-svn-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-svn-reference +# key: svn-reference... +# -- +(svn-reference + (url "$1") + (revision ${2:svn-revision})) \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-add-package b/etc/snippets/text-mode/guix-commit-message-add-package new file mode 100644 index 000000000..1aebe8a76 --- /dev/null +++ b/etc/snippets/text-mode/guix-commit-message-add-package @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-add-package +# key: add +# condition: git-commit-mode +# -- +gnu: Add $1. + +* `(car (magit-staged-files))` ($1): New variable. \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-update-package b/etc/snippets/text-mode/guix-commit-message-update-package new file mode 100644 index 000000000..79fcf7c6e --- /dev/null +++ b/etc/snippets/text-mode/guix-commit-message-update-package @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-update-package +# key: update +# condition: git-commit-mode +# -- +gnu: $1: Update to $2. + +* `(car (magit-staged-files))` ($1): Update to $2.$0 +`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file -- cgit v1.3 From dafc3dafeada11e4df043bf751a611b1ac8fc22a Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Wed, 13 Dec 2017 23:42:40 +0100 Subject: guix: offload: Add "status" sub-command. * guix/scripts/offload.scm (check-machine-status): New procedure. (guix-offload): Call it when the argument is "status". * doc/guix.texi (Daemon Offload Setup): Document it. --- doc/guix.texi | 9 +++++++++ guix/scripts/offload.scm | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 64f73b38a..cb6e6b1c6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1066,6 +1066,15 @@ regular expression like this: # guix offload test machines.scm '\.gnu\.org$' @end example +@cindex offload status +To display the current load of all build hosts, run this command on the +main node: + +@example +# guix offload status +@end example + + @node Invoking guix-daemon @section Invoking @command{guix-daemon} diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index ebd0bf783..7e114fa2c 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès +;;; Copyright © 2017 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -629,6 +630,32 @@ machine." (for-each assert-node-can-import nodes names sockets) (for-each assert-node-can-export nodes names sockets)))) +(define (check-machine-status machine-file pred) + "Print the load of each machine matching PRED in MACHINE-FILE." + (define (build-machine=? m1 m2) + (and (string=? (build-machine-name m1) (build-machine-name m2)) + (= (build-machine-port m1) (build-machine-port m2)))) + + ;; A given build machine may appear several times (e.g., once for + ;; "x86_64-linux" and a second time for "i686-linux"); test them only once. + (let ((machines (filter pred + (delete-duplicates (build-machines machine-file) + build-machine=?)))) + (info (G_ "getting status of ~a build machines defined in '~a'...~%") + (length machines) machine-file) + (for-each (lambda (machine) + (let* ((node (make-node (open-ssh-session machine))) + (uts (node-eval node '(uname)))) + (format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\ + host name: ~a~% normalized load: ~a~%" + (build-machine-name machine) + (utsname:sysname uts) (utsname:release uts) + (utsname:machine uts) + (utsname:nodename uts) + (parameterize ((current-error-port (%make-void-port "rw+"))) + (machine-load machine))))) + machines))) + ;;; ;;; Entry point. @@ -691,6 +718,18 @@ machine." (() (values %machine-file (const #t))) (x (leave (G_ "wrong number of arguments~%")))))) (check-machine-availability (or file %machine-file) pred)))) + (("status" rest ...) + (with-error-handling + (let-values (((file pred) + (match rest + ((file regexp) + (values file + (compose (cut string-match regexp <>) + build-machine-name))) + ((file) (values file (const #t))) + (() (values %machine-file (const #t))) + (x (leave (G_ "wrong number of arguments~%")))))) + (check-machine-status (or file %machine-file) pred)))) (("--version") (show-version-and-exit "guix offload")) (("--help") -- cgit v1.3 From 5a5d1a7f471d0f914f7d3448c9ce672f09c1cb70 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Mon, 18 Dec 2017 00:30:32 +0100 Subject: doc: Fix typo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi: remove double occurence of generations. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 1 - 1 file changed, 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index cb6e6b1c6..242e54fd1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18372,7 +18372,6 @@ system. A possibly empty list of @code{menu-entry} objects (see below), denoting entries to appear in the bootloader menu, in addition to the current system entry and the entry pointing to previous system generations. -generations. @item @code{default-entry} (default: @code{0}) The index of the default boot menu entry. Index 0 is for the entry of the -- cgit v1.3 From 8b223ceac4ff0781e95d69362875f87cff03f4d6 Mon Sep 17 00:00:00 2001 From: Clément Lassieur Date: Sat, 9 Dec 2017 12:59:12 +0100 Subject: services: nginx: Replace 'http-port' and 'https-port' with 'listen'. * doc/guix.texi (Web Services, Version Control Services): Update accordingly. * gnu/services/certbot.scm (certbot-nginx-server-configurations): Likewise. * gnu/services/version-control.scm (%cgit-configuration-nginx): Likewise. * gnu/services/web.scm (, emit-nginx-server-config): Likewise. * gnu/tests/version-control.scm (%cgit-configuration-nginx, %git-nginx-configuration): Likewise. * gnu/tests/web.scm (%nginx-servers, %php-fpm-nginx-server-blocks): Likewise. --- doc/guix.texi | 20 +++++++++----------- gnu/services/certbot.scm | 4 ++-- gnu/services/version-control.scm | 3 ++- gnu/services/web.scm | 16 ++++++---------- gnu/tests/version-control.scm | 7 +++---- gnu/tests/web.scm | 6 +++--- 6 files changed, 25 insertions(+), 31 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 242e54fd1..e44478cbf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14938,17 +14938,15 @@ Data type representing the configuration of an nginx server block. This type has the following parameters: @table @asis -@item @code{http-port} (default: @code{80}) -Nginx will listen for HTTP connection on this port. Set it at @code{#f} if -nginx should not listen for HTTP (non secure) connection for this -@dfn{server block}. +@item @code{listen} (default: @code{'("80" "443 ssl")}) +Each @code{listen} directive sets the address and port for IP, or the +path for a UNIX-domain socket on which the server will accept requests. +Both address and port, or only address or only port can be specified. +An address may also be a hostname, for example: -@item @code{https-port} (default: @code{443}) -Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if -nginx should not listen for HTTPS (secure) connection for this @dfn{server block}. - -Note that nginx can listen for HTTP and HTTPS connections in the same -@dfn{server block}. +@example +'("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000") +@end example @item @code{server-name} (default: @code{(list 'default)}) A list of server names this server represents. @code{'default} represents the @@ -17689,7 +17687,7 @@ serve the default @file{/srv/git} over HTTPS might be: (server-blocks (list (nginx-server-configuration - (http-port #f) + (listen '("443 ssl")) (server-name "git.my-host.org") (ssl-certificate "/etc/letsencrypt/live/git.my-host.org/fullchain.pem") diff --git a/gnu/services/certbot.scm b/gnu/services/certbot.scm index 0d72a4b70..8aac2638b 100644 --- a/gnu/services/certbot.scm +++ b/gnu/services/certbot.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 ng0 ;;; Copyright © 2016 Sou Bunnbu +;;; Copyright © 2017 Clément Lassieur ;;; ;;; This file is part of GNU Guix. ;;; @@ -97,8 +98,7 @@ (map (lambda (host) (nginx-server-configuration - (http-port 80) - (https-port #f) + (listen '("80")) (ssl-certificate #f) (ssl-certificate-key #f) (server-name (list host)) diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm index fce2ce1c2..6bf656949 100644 --- a/gnu/services/version-control.scm +++ b/gnu/services/version-control.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016 ng0 ;;; Copyright © 2016 Sou Bunnbu ;;; Copyright © 2017 Oleg Pykhalov +;;; Copyright © 2017 Clément Lassieur ;;; ;;; This file is part of GNU Guix. ;;; @@ -231,7 +232,7 @@ access to exported repositories under @file{/srv/git}." "fastcgi_param HTTP_HOST $server_name;" "fastcgi_pass 127.0.0.1:9000;"))))) (try-files (list "$uri" "@cgit")) - (https-port #f) + (listen '("80")) (ssl-certificate #f) (ssl-certificate-key #f)))) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 582cf535c..8a16f50de 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2016, 2017 Julien Lepiller ;;; Copyright © 2017 Christopher Baines ;;; Copyright © 2017 nee +;;; Copyright © 2017 Clément Lassieur ;;; ;;; This file is part of GNU Guix. ;;; @@ -49,8 +50,7 @@ nginx-server-configuration nginx-server-configuration? - nginx-server-configuration-http-port - nginx-server-configuartion-https-port + nginx-server-configuration-listen nginx-server-configuration-server-name nginx-server-configuration-root nginx-server-configuration-locations @@ -135,10 +135,8 @@ (define-record-type* nginx-server-configuration make-nginx-server-configuration nginx-server-configuration? - (http-port nginx-server-configuration-http-port - (default 80)) - (https-port nginx-server-configuration-https-port - (default 443)) + (listen nginx-server-configuration-listen + (default '("80" "443 ssl"))) (server-name nginx-server-configuration-server-name (default (list 'default))) (root nginx-server-configuration-root @@ -225,8 +223,7 @@ of index files." " }\n")))) (define (emit-nginx-server-config server) - (let ((http-port (nginx-server-configuration-http-port server)) - (https-port (nginx-server-configuration-https-port server)) + (let ((listen (nginx-server-configuration-listen server)) (server-name (nginx-server-configuration-server-name server)) (ssl-certificate (nginx-server-configuration-ssl-certificate server)) (ssl-certificate-key @@ -245,8 +242,7 @@ of index files." '()))) (list " server {\n" - (and/l http-port " listen " (number->string <>) ";\n") - (and/l https-port " listen " (number->string <>) " ssl;\n") + (map (lambda (directive) (list " listen " directive ";\n")) listen) " server_name " (config-domain-strings server-name) ";\n" (and/l ssl-certificate " ssl_certificate " <> ";\n") (and/l ssl-certificate-key " ssl_certificate_key " <> ";\n") diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 2cbacf0ef..7367861b0 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Oleg Pykhalov ;;; Copyright © 2017 Ludovic Courtès +;;; Copyright © 2017 Clément Lassieur ;;; ;;; This file is part of GNU Guix. ;;; @@ -78,8 +79,7 @@ "fastcgi_param HTTP_HOST $server_name;" "fastcgi_pass 127.0.0.1:9000;"))))) (try-files (list "$uri" "@cgit")) - (http-port 19418) - (https-port #f) + (listen '("19418")) (ssl-certificate #f) (ssl-certificate-key #f)))) @@ -211,8 +211,7 @@ HTTP-PORT." (server-blocks (list (nginx-server-configuration - (http-port 19418) - (https-port #f) + (listen '("19418")) (ssl-certificate #f) (ssl-certificate-key #f) (locations diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index e975cb830..f1214fb5f 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Ludovic Courtès ;;; Copyright © 2017 Christopher Baines +;;; Copyright © 2017 Clément Lassieur ;;; ;;; This file is part of GNU Guix. ;;; @@ -47,7 +48,7 @@ ;; Server blocks. (list (nginx-server-configuration (root "/srv") - (http-port 8042)))) + (listen '("8042" "443 ssl"))))) (define %nginx-os ;; Operating system under test. @@ -153,8 +154,7 @@ echo(\"Computed by php:\".((string)(2+3))); (root "/srv") (locations (list (nginx-php-location))) - (http-port 8042) - (https-port #f) + (listen "8042") (ssl-certificate #f) (ssl-certificate-key #f)))) -- cgit v1.3 From b05e8ee1205bc10f2ab33045f257170d4ce1999b Mon Sep 17 00:00:00 2001 From: Clément Lassieur Date: Sat, 9 Dec 2017 22:47:53 +0100 Subject: services: nginx: Allow to add raw content to the server blocks. * doc/guix.texi (Web Services): Document 'raw-content'. * gnu/services/web.scm ()[raw-content]: New field. (emit-nginx-server-config): Add it. --- doc/guix.texi | 3 +++ gnu/services/web.scm | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index e44478cbf..68f3a8878 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14979,6 +14979,9 @@ you don't have a key or you don't want to use HTTPS. @item @code{server-tokens?} (default: @code{#f}) Whether the server should add its configuration to response. +@item @code{raw-content} (default: @code{'()}) +A list of raw lines added to the server block. + @end table @end deftp diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 8a16f50de..2371ddb6d 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -58,6 +58,7 @@ nginx-server-configuration-ssl-certificate nginx-server-configuration-ssl-certificate-key nginx-server-configuration-server-tokens? + nginx-server-configuration-raw-content nginx-upstream-configuration @@ -152,7 +153,9 @@ (ssl-certificate-key nginx-server-configuration-ssl-certificate-key (default #f)) (server-tokens? nginx-server-configuration-server-tokens? - (default #f))) + (default #f)) + (raw-content nginx-server-configuration-raw-content + (default '()))) (define-record-type* nginx-upstream-configuration make-nginx-upstream-configuration @@ -232,7 +235,8 @@ of index files." (index (nginx-server-configuration-index server)) (try-files (nginx-server-configuration-try-files server)) (server-tokens? (nginx-server-configuration-server-tokens? server)) - (locations (nginx-server-configuration-locations server))) + (locations (nginx-server-configuration-locations server)) + (raw-content (nginx-server-configuration-raw-content server))) (define-syntax-parameter <> (syntax-rules ())) (define-syntax-rule (and/l x tail ...) (let ((x* x)) @@ -255,6 +259,7 @@ of index files." "\n" (map emit-nginx-location-config locations) "\n" + (map (lambda (x) (list " " x "\n")) raw-content) " }\n"))) (define (emit-nginx-upstream-config upstream) -- cgit v1.3 From 45f6211730157c50ade4dbf770e60871f1067ad6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 18 Dec 2017 23:16:35 +0100 Subject: doc: Clarify treatment of the root account. * doc/guix.texi (operating-system Reference): Clarify the situation of UID 0. --- doc/guix.texi | 3 +++ 1 file changed, 3 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 68f3a8878..3bb29db96 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8700,6 +8700,9 @@ also specified. @xref{Mapped Devices} and @ref{File Systems}. @itemx @code{groups} (default: @var{%base-groups}) List of user accounts and groups. @xref{User Accounts}. +If the @code{users} list lacks a user account with UID@tie{}0, a +``root'' account with UID@tie{}0 is automatically added. + @item @code{skeletons} (default: @code{(default-skeletons)}) A list target file name/file-like object tuples (@pxref{G-Expressions, file-like objects}). These are the skeleton files that will be added to -- cgit v1.3