>From 0478b5720a8fcc71d682ccf62bae839a71453b86 Mon Sep 17 00:00:00 2001 From: Julien Lepiller
Date: Sun, 6 Nov 2016 10:26:45 +0100 Subject: [PATCH 1/3] Make nginx-service extensible * gnu/services/web.scm (nginx-service-type): Make extensible. --- doc/guix.texi | 38 ++++++++++++++++++++++++++++++++++++-- gnu/services/web.scm | 33 +++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1075a7e..4b60a4a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10400,8 +10400,8 @@ The @code{(gnu services web)} module provides the following service: @deffn {Scheme Procedure} nginx-service [#:nginx nginx] @ [#:log-directory ``/var/log/nginx''] @ [#:run-directory ``/var/run/nginx''] @ - [#:vhost-list (list (nginx-vhost-configuration))] @ - [#:config-file] + [#:vhost-list '()] @ + [#:config-file @code{#f}] Return a service that runs @var{nginx}, the nginx web server. @@ -10417,6 +10417,40 @@ this to work, use the default value for @var{config-file}. @end deffn address@hidden {Scheme Variable} nginx-service-type +This is the type for the nginx web server. + +This service can be extended to add more vhosts than the default ones. To add address@hidden hosts}, you can either put them in the @var{vhost-lists} of the address@hidden procedure, or create a separate service for all or parts +of them. For example: + address@hidden +(define vh nginx-vhost-configuration + (root "/var/www/extra-website")) +(nginx-service) +(simple-service 'foo nginx-service-type + (list vh)) address@hidden example + +Is a service that adds a new @dfn{virtual host} to the list of existing ones. +You can add as many such services as you want. + +You can also use a more complete service definition: + address@hidden +(define foo + (service-type (name 'foo) + (extensions (list (service-extension nginx-service-type + (const (list vh))))))) +(nginx-service) +(service foo #t) address@hidden example + +Note that @code{(nginx-service)} needs to be defined only once. + address@hidden deffn + @deftp {Data Type} nginx-vhost-configuration Data type representing the configuration of an nginx virtual host. This type has the following parameters: diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 59e1e54..50f83f3 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -28,6 +28,7 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:export (nginx-configuration nginx-configuration? nginx-vhost-configuration @@ -67,6 +68,8 @@ (nginx nginx-configuration-nginx) ;