diff options
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/base.scm | 50 | ||||
-rw-r--r-- | gnu/services/mail.scm | 52 | ||||
-rw-r--r-- | gnu/services/web.scm | 7 |
3 files changed, 80 insertions, 29 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 79ba205c54..67972bf614 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -129,6 +129,8 @@ guix-publish-configuration-host guix-publish-configuration-compression-level guix-publish-configuration-nar-path + guix-publish-configuration-cache + guix-publish-configuration-ttl guix-publish-service guix-publish-service-type @@ -1442,14 +1444,21 @@ failed to register hydra.gnu.org public key: ~a~%" status)))))))) (default 80)) (host guix-publish-configuration-host ;string (default "localhost")) - (compression-level guix-publish-compression-level ;integer + (compression-level guix-publish-configuration-compression-level ;integer (default 3)) - (nar-path guix-publish-nar-path ;string - (default "nar"))) + (nar-path guix-publish-configuration-nar-path ;string + (default "nar")) + (cache guix-publish-configuration-cache ;#f | string + (default #f)) + (workers guix-publish-configuration-workers ;#f | integer + (default #f)) + (ttl guix-publish-configuration-ttl ;#f | integer + (default #f))) (define guix-publish-shepherd-service (match-lambda - (($ <guix-publish-configuration> guix port host compression nar-path) + (($ <guix-publish-configuration> guix port host compression + nar-path cache workers ttl) (list (shepherd-service (provision '(guix-publish)) (requirement '(guix-daemon)) @@ -1459,7 +1468,20 @@ failed to register hydra.gnu.org public key: ~a~%" status)))))))) "-p" #$(number->string port) "-C" #$(number->string compression) (string-append "--nar-path=" #$nar-path) - (string-append "--listen=" #$host)))) + (string-append "--listen=" #$host) + #$@(if workers + #~((string-append "--workers=" + #$(number->string + workers))) + #~()) + #$@(if ttl + #~((string-append "--ttl=" + #$(number->string ttl) + "s")) + #~()) + #$@(if cache + #~((string-append "--cache=" #$cache)) + #~())))) (stop #~(make-kill-destructor))))))) (define %guix-publish-accounts @@ -1472,13 +1494,29 @@ failed to register hydra.gnu.org public key: ~a~%" status)))))))) (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) +(define (guix-publish-activation config) + (let ((cache (guix-publish-configuration-cache config))) + (if cache + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (mkdir-p #$cache) + (let* ((pw (getpw "guix-publish")) + (uid (passwd:uid pw)) + (gid (passwd:gid pw))) + (chown #$cache uid gid)))) + #t))) + (define guix-publish-service-type (service-type (name 'guix-publish) (extensions (list (service-extension shepherd-root-service-type guix-publish-shepherd-service) (service-extension account-service-type - (const %guix-publish-accounts)))) + (const %guix-publish-accounts)) + (service-extension activation-service-type + guix-publish-activation))) (default-value (guix-publish-configuration)))) (define* (guix-publish-service #:key (guix guix) (port 80) (host "localhost")) diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 20043d7518..6305f06f85 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -35,6 +35,7 @@ #:use-module (guix gexp) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (srfi srfi-1) #:export (dovecot-service dovecot-service-type dovecot-configuration @@ -57,6 +58,8 @@ opensmtpd-service-type %default-opensmtpd-config-file + mail-aliases-service-type + exim-configuration exim-configuration? exim-service-type @@ -1662,6 +1665,31 @@ accept from local for any relay ;;; +;;; mail aliases. +;;; + +(define (mail-aliases-etc aliases) + `(("aliases" ,(plain-file "aliases" + ;; Ideally we'd use a format string like + ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a + ;; warning that I can't figure out how to fix, + ;; so we'll just use string-join below instead. + (format #f "~:{~a: ~a\n~}" + (map (match-lambda + ((alias addresses ...) + (list alias (string-join addresses ",")))) + aliases)))))) + +(define mail-aliases-service-type + (service-type + (name 'mail-aliases) + (extensions + (list (service-extension etc-service-type mail-aliases-etc))) + (compose concatenate) + (extend append))) + + +;;; ;;; Exim. ;;; @@ -1671,9 +1699,7 @@ accept from local for any relay (package exim-configuration-package ;<package> (default exim)) (config-file exim-configuration-config-file ;file-like - (default #f)) - (aliases exim-configuration-aliases ;; list of lists - (default '()))) + (default #f))) (define %exim-accounts (list (user-group @@ -1700,7 +1726,7 @@ exim_group = exim (define exim-shepherd-service (match-lambda - (($ <exim-configuration> package config-file aliases) + (($ <exim-configuration> package config-file) (list (shepherd-service (provision '(exim mta)) (documentation "Run the exim daemon.") @@ -1713,7 +1739,7 @@ exim_group = exim (define exim-activation (match-lambda - (($ <exim-configuration> package config-file aliases) + (($ <exim-configuration> package config-file) (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) @@ -1726,20 +1752,6 @@ exim_group = exim (zero? (system* #$(file-append package "/bin/exim") "-bV" "-C" #$(exim-computed-config-file package config-file)))))))) -(define exim-etc - (match-lambda - (($ <exim-configuration> package config-file aliases) - `(("aliases" ,(plain-file "aliases" - ;; Ideally we'd use a format string like - ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a - ;; warning that I can't figure out how to fix, - ;; so we'll just use string-join below instead. - (format #f "~:{~a: ~a\n~}" - (map (lambda (entry) - (list (car entry) - (string-join (cdr entry) ","))) - aliases)))))))) - (define exim-profile (compose list exim-configuration-package)) @@ -1751,4 +1763,4 @@ exim_group = exim (service-extension account-service-type (const %exim-accounts)) (service-extension activation-service-type exim-activation) (service-extension profile-service-type exim-profile) - (service-extension etc-service-type exim-etc))))) + (service-extension mail-aliases-service-type (const '())))))) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 11408d7b0e..b7b2f67f13 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -180,7 +180,7 @@ of index files." (nginx-upstream-configuration-servers upstream))) " }\n")) -(define (default-nginx-config log-directory run-directory server-list upstream-list) +(define (default-nginx-config nginx log-directory run-directory server-list upstream-list) (mixed-text-file "nginx.conf" "user nginx nginx;\n" "pid " run-directory "/pid;\n" @@ -192,6 +192,7 @@ of index files." " uwsgi_temp_path " run-directory "/uwsgi_temp;\n" " scgi_temp_path " run-directory "/scgi_temp;\n" " access_log " log-directory "/access.log;\n" + " include " nginx "/share/nginx/conf/mime.types;\n" "\n" (string-join (filter (lambda (section) (not (null? section))) @@ -235,7 +236,7 @@ of index files." ;; Check configuration file syntax. (system* (string-append #$nginx "/sbin/nginx") "-c" #$(or config-file - (default-nginx-config log-directory + (default-nginx-config nginx log-directory run-directory server-blocks upstream-blocks)) "-t"))))) @@ -250,7 +251,7 @@ of index files." (zero? (system* #$nginx-binary "-c" #$(or config-file - (default-nginx-config log-directory + (default-nginx-config nginx log-directory run-directory server-blocks upstream-blocks)) #$@args)))))) |