From f2bee4210ff7da38696d8e49999282e27b4a6364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 15 Jan 2018 22:04:55 +0100 Subject: services: bitlbee: Move to (gnu services messaging). * gnu/services/networking.scm () (bitlbee-shepherd-service, %bitlbee-accounts, %bitlbee-activation) (bitlbee-service-type, bitlbee-service): Move to... * gnu/services/messaging.scm: ... here. * doc/guix.texi (Networking Services): Move 'bitlbee-service' doc to... (Messaging Services): ... here. --- gnu/services/messaging.scm | 117 +++++++++++++++++++++++++++++++++++++++++++- gnu/services/networking.scm | 113 ------------------------------------------ 2 files changed, 116 insertions(+), 114 deletions(-) (limited to 'gnu/services') diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index a9820ed21f..c0ccdbad33 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2017 Mathieu Othacehe +;;; Copyright © 2015, 2017, 2018 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ #:use-module (gnu services configuration) #:use-module (gnu system shadow) #:use-module (guix gexp) + #:use-module (guix modules) #:use-module (guix records) #:use-module (guix packages) #:use-module (srfi srfi-1) @@ -42,7 +44,12 @@ ssl-configuration %default-modules-enabled - prosody-configuration-pidfile)) + prosody-configuration-pidfile + + bitlbee-configuration + bitlbee-configuration? + bitlbee-service + bitlbee-service-type)) ;;; Commentary: ;;; @@ -751,3 +758,111 @@ string, you could instantiate a prosody service like this: (opaque-prosody-configuration (prosody.cfg.lua \"\"))) @end example")) + + +;;; +;;; BitlBee. +;;; + +(define-record-type* + bitlbee-configuration make-bitlbee-configuration + bitlbee-configuration? + (bitlbee bitlbee-configuration-bitlbee + (default bitlbee)) + (interface bitlbee-configuration-interface + (default "127.0.0.1")) + (port bitlbee-configuration-port + (default 6667)) + (extra-settings bitlbee-configuration-extra-settings + (default ""))) + +(define bitlbee-shepherd-service + (match-lambda + (($ bitlbee interface port extra-settings) + (let ((conf (plain-file "bitlbee.conf" + (string-append " + [settings] + User = bitlbee + ConfigDir = /var/lib/bitlbee + DaemonInterface = " interface " + DaemonPort = " (number->string port) " +" extra-settings)))) + + (with-imported-modules (source-module-closure + '((gnu build shepherd) + (gnu system file-systems))) + (list (shepherd-service + (provision '(bitlbee)) + + ;; Note: If networking is not up, then /etc/resolv.conf + ;; doesn't get mapped in the container, hence the dependency + ;; on 'networking'. + (requirement '(user-processes networking)) + + (modules '((gnu build shepherd) + (gnu system file-systems))) + (start #~(make-forkexec-constructor/container + (list #$(file-append bitlbee "/sbin/bitlbee") + "-n" "-F" "-u" "bitlbee" "-c" #$conf) + + #:pid-file "/var/run/bitlbee.pid" + #:mappings (list (file-system-mapping + (source "/var/lib/bitlbee") + (target source) + (writable? #t))))) + (stop #~(make-kill-destructor))))))))) + +(define %bitlbee-accounts + ;; User group and account to run BitlBee. + (list (user-group (name "bitlbee") (system? #t)) + (user-account + (name "bitlbee") + (group "bitlbee") + (system? #t) + (comment "BitlBee daemon user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define %bitlbee-activation + ;; Activation gexp for BitlBee. + #~(begin + (use-modules (guix build utils)) + + ;; This directory is used to store OTR data. + (mkdir-p "/var/lib/bitlbee") + (let ((user (getpwnam "bitlbee"))) + (chown "/var/lib/bitlbee" + (passwd:uid user) (passwd:gid user))))) + +(define bitlbee-service-type + (service-type (name 'bitlbee) + (extensions + (list (service-extension shepherd-root-service-type + bitlbee-shepherd-service) + (service-extension account-service-type + (const %bitlbee-accounts)) + (service-extension activation-service-type + (const %bitlbee-activation)))) + (default-value (bitlbee-configuration)) + (description + "Run @url{http://bitlbee.org,BitlBee}, a daemon that acts as +a gateway between IRC and chat networks."))) + +(define* (bitlbee-service #:key (bitlbee bitlbee) + (interface "127.0.0.1") (port 6667) + (extra-settings "")) + "Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that +acts as a gateway between IRC and chat networks. + +The daemon will listen to the interface corresponding to the IP address +specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only +local clients can connect, whereas @code{0.0.0.0} means that connections can +come from any networking interface. + +In addition, @var{extra-settings} specifies a string to append to the +configuration file." + (service bitlbee-service-type + (bitlbee-configuration + (bitlbee bitlbee) + (interface interface) (port port) + (extra-settings extra-settings)))) diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index c3ba0787c0..5ba3c5eed6 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -74,11 +74,6 @@ tor-service tor-service-type - bitlbee-configuration - bitlbee-configuration? - bitlbee-service - bitlbee-service-type - wicd-service-type wicd-service @@ -736,114 +731,6 @@ project's documentation} for more information." (service tor-hidden-service-type (hidden-service name mapping))) - -;;; -;;; BitlBee. -;;; - -(define-record-type* - bitlbee-configuration make-bitlbee-configuration - bitlbee-configuration? - (bitlbee bitlbee-configuration-bitlbee - (default bitlbee)) - (interface bitlbee-configuration-interface - (default "127.0.0.1")) - (port bitlbee-configuration-port - (default 6667)) - (extra-settings bitlbee-configuration-extra-settings - (default ""))) - -(define bitlbee-shepherd-service - (match-lambda - (($ bitlbee interface port extra-settings) - (let ((conf (plain-file "bitlbee.conf" - (string-append " - [settings] - User = bitlbee - ConfigDir = /var/lib/bitlbee - DaemonInterface = " interface " - DaemonPort = " (number->string port) " -" extra-settings)))) - - (with-imported-modules (source-module-closure - '((gnu build shepherd) - (gnu system file-systems))) - (list (shepherd-service - (provision '(bitlbee)) - - ;; Note: If networking is not up, then /etc/resolv.conf - ;; doesn't get mapped in the container, hence the dependency - ;; on 'networking'. - (requirement '(user-processes networking)) - - (modules '((gnu build shepherd) - (gnu system file-systems))) - (start #~(make-forkexec-constructor/container - (list #$(file-append bitlbee "/sbin/bitlbee") - "-n" "-F" "-u" "bitlbee" "-c" #$conf) - - #:pid-file "/var/run/bitlbee.pid" - #:mappings (list (file-system-mapping - (source "/var/lib/bitlbee") - (target source) - (writable? #t))))) - (stop #~(make-kill-destructor))))))))) - -(define %bitlbee-accounts - ;; User group and account to run BitlBee. - (list (user-group (name "bitlbee") (system? #t)) - (user-account - (name "bitlbee") - (group "bitlbee") - (system? #t) - (comment "BitlBee daemon user") - (home-directory "/var/empty") - (shell (file-append shadow "/sbin/nologin"))))) - -(define %bitlbee-activation - ;; Activation gexp for BitlBee. - #~(begin - (use-modules (guix build utils)) - - ;; This directory is used to store OTR data. - (mkdir-p "/var/lib/bitlbee") - (let ((user (getpwnam "bitlbee"))) - (chown "/var/lib/bitlbee" - (passwd:uid user) (passwd:gid user))))) - -(define bitlbee-service-type - (service-type (name 'bitlbee) - (extensions - (list (service-extension shepherd-root-service-type - bitlbee-shepherd-service) - (service-extension account-service-type - (const %bitlbee-accounts)) - (service-extension activation-service-type - (const %bitlbee-activation)))) - (default-value (bitlbee-configuration)) - (description - "Run @url{http://bitlbee.org,BitlBee}, a daemon that acts as -a gateway between IRC and chat networks."))) - -(define* (bitlbee-service #:key (bitlbee bitlbee) - (interface "127.0.0.1") (port 6667) - (extra-settings "")) - "Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that -acts as a gateway between IRC and chat networks. - -The daemon will listen to the interface corresponding to the IP address -specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only -local clients can connect, whereas @code{0.0.0.0} means that connections can -come from any networking interface. - -In addition, @var{extra-settings} specifies a string to append to the -configuration file." - (service bitlbee-service-type - (bitlbee-configuration - (bitlbee bitlbee) - (interface interface) (port port) - (extra-settings extra-settings)))) - ;;; ;;; Wicd. -- cgit v1.2.3 From 37af37dcc9a5d4fbb16540d5972fd5333043b413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 15 Jan 2018 22:16:36 +0100 Subject: doc: Deprecate 'bitlbee-service' procedure. * gnu/services/messaging.scm (bitlbee-service): Mark as deprecated. * doc/guix.texi (Messaging Services): Document 'bitlbee-service-type' and 'bitlbee-configuration'. Remove 'bitlbee-service'. --- gnu/services/messaging.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index c0ccdbad33..427e2121f6 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -848,7 +848,7 @@ string, you could instantiate a prosody service like this: "Run @url{http://bitlbee.org,BitlBee}, a daemon that acts as a gateway between IRC and chat networks."))) -(define* (bitlbee-service #:key (bitlbee bitlbee) +(define* (bitlbee-service #:key (bitlbee bitlbee) ;deprecated (interface "127.0.0.1") (port 6667) (extra-settings "")) "Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that -- cgit v1.2.3 From d067e4badcaa705d8cb68d81c534ba69c3fa6e13 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 12 Dec 2017 06:48:48 +0000 Subject: gnu: services: web: Add service for httpd. * gnu/services/web.scm (, , ): New record types. (%default-httpd-modules, %httpd-accounts, httpd-service-type): New variables. (httpd-shepherd-services, httpd-activation, httpd-process-extensions): New procedures. * gnu/tests/web.scm (run-httpd-test): New procedure. (%httpd-os, %tests-httpd): New variables. * doc/guix.texi (Web Services): Document the Apache HTTP Server. --- gnu/services/web.scm | 229 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 228 insertions(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 2371ddb6d0..c1ffe3e055 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -34,8 +34,36 @@ #:use-module ((guix utils) #:select (version-major)) #:use-module ((guix packages) #:select (package-version)) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) #:use-module (ice-9 match) - #:export ( + #:export ( + httpd-configuration + httpd-configuration? + httpd-configuration-package + httpd-configuration-pid-file + httpd-configuration-config + + + httpd-virtualhost + httpd-virtualhost? + httpd-virtualhost-addresses-and-ports + httpd-virtualhost-contents + + + httpd-config-file + httpd-config-file? + httpd-config-file-modules + httpd-config-file-server-root + httpd-config-file-server-name + httpd-config-file-listen + httpd-config-file-pid-file + httpd-config-file-error-log + httpd-config-file-user + httpd-config-file-group + + httpd-service-type + + nginx-configuration nginx-configuration? nginx-configuartion-nginx @@ -133,6 +161,205 @@ ;;; ;;; Code: +(define-record-type* + httpd-module make-httpd-module + httpd-module? + (name httpd-load-module-name) + (file httpd-load-module-file)) + +;; Default modules for the httpd-service-type, taken from etc/httpd/httpd.conf +;; file in the httpd package. +(define %default-httpd-modules + (map (match-lambda + ((name file) + (httpd-module + (name name) + (file file)))) + '(("authn_file_module" "modules/mod_authn_file.so") + ("authn_core_module" "modules/mod_authn_core.so") + ("authz_host_module" "modules/mod_authz_host.so") + ("authz_groupfile_module" "modules/mod_authz_groupfile.so") + ("authz_user_module" "modules/mod_authz_user.so") + ("authz_core_module" "modules/mod_authz_core.so") + ("access_compat_module" "modules/mod_access_compat.so") + ("auth_basic_module" "modules/mod_auth_basic.so") + ("reqtimeout_module" "modules/mod_reqtimeout.so") + ("filter_module" "modules/mod_filter.so") + ("mime_module" "modules/mod_mime.so") + ("log_config_module" "modules/mod_log_config.so") + ("env_module" "modules/mod_env.so") + ("headers_module" "modules/mod_headers.so") + ("setenvif_module" "modules/mod_setenvif.so") + ("version_module" "modules/mod_version.so") + ("unixd_module" "modules/mod_unixd.so") + ("status_module" "modules/mod_status.so") + ("autoindex_module" "modules/mod_autoindex.so") + ("dir_module" "modules/mod_dir.so") + ("alias_module" "modules/mod_alias.so")))) + +(define-record-type* + httpd-config-file make-httpd-config-file + httpd-config-file? + (modules httpd-config-file-modules + (default %default-httpd-modules)) + (server-root httpd-config-file-server-root + (default httpd)) + (server-name httpd-config-file-server-name + (default #f)) + (document-root httpd-config-file-document-root + (default "/srv/http")) + (listen httpd-config-file-listen + (default '("80"))) + (pid-file httpd-config-file-pid-file + (default "/var/run/httpd")) + (error-log httpd-config-file-error-log + (default "/var/log/httpd/error_log")) + (user httpd-config-file-user + (default "httpd")) + (group httpd-config-file-group + (default "httpd")) + (extra-config httpd-config-file-extra-config + (default + (list "TypesConfig etc/httpd/mime.types")))) + +(define-gexp-compiler (httpd-config-file-compiler + (file ) system target) + (match file + (($ load-modules server-root server-name + document-root listen pid-file error-log + user group extra-config) + (gexp->derivation + "httpd.conf" + #~(call-with-output-file (ungexp output "out") + (lambda (port) + (display + (string-append + (ungexp-splicing + `(,@(append-map + (match-lambda + (($ name module) + `("LoadModule " ,name " " ,module "\n"))) + load-modules) + ,@`("ServerRoot " ,server-root "\n") + ,@(if server-name + `("ServerName " ,server-name "\n") + '()) + ,@`("DocumentRoot " ,document-root "\n") + ,@(append-map + (lambda (listen-value) + `("Listen " ,listen-value "\n")) + listen) + ,@(if pid-file + `("Pidfile " ,pid-file "\n") + '()) + ,@(if error-log + `("ErrorLog " ,error-log "\n") + '()) + ,@(if user + `("User " ,user "\n") + '()) + ,@(if group + `("Group " ,group "\n") + '()) + "\n\n" + ,@extra-config))) + port))) + #:local-build? #t)))) + +(define-record-type + (httpd-virtualhost addresses-and-ports contents) + httpd-virtualhost? + (addresses-and-ports httpd-virtualhost-addresses-and-ports) + (contents httpd-virtualhost-contents)) + +(define-record-type* + httpd-configuration make-httpd-configuration + httpd-configuration? + (package httpd-configuration-package + (default httpd)) + (pid-file httpd-configuration-pid-file + (default "/var/run/httpd")) + (config httpd-configuration-config + (default (httpd-config-file)))) + +(define %httpd-accounts + (list (user-group (name "httpd") (system? #t)) + (user-account + (name "httpd") + (group "httpd") + (system? #t) + (comment "Apache HTTPD server user") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define httpd-shepherd-services + (match-lambda + (($ package pid-file config) + (list (shepherd-service + (provision '(httpd)) + (documentation "The Apache HTTP Server") + (requirement '(networking)) + (start #~(make-forkexec-constructor + `(#$(file-append package "/bin/httpd") + #$@(if config + (list "-f" config) + '())) + #:pid-file #$pid-file)) + (stop #~(make-kill-destructor))))))) + +(define httpd-activation + (match-lambda + (($ package pid-file config) + (match-record + config + + (error-log document-root) + #~(begin + (use-modules (guix build utils)) + + (mkdir-p #$(dirname error-log)) + (mkdir-p #$document-root)))))) + +(define (httpd-process-extensions original-config extension-configs) + (let ((config (httpd-configuration-config + original-config))) + (if (httpd-config-file? config) + (httpd-configuration + (inherit original-config) + (config + (httpd-config-file + (inherit config) + (extra-config + (append (httpd-config-file-extra-config config) + (append-map + (match-lambda + (($ + addresses-and-ports + contents) + `(,(string-append + "\n") + ,@contents + "\n\n")) + ((? string? x) + `("\n" ,x "\n")) + ((? list? x) + `("\n" ,@x "\n"))) + extension-configs))))))))) + +(define httpd-service-type + (service-type (name 'httpd) + (extensions + (list (service-extension shepherd-root-service-type + httpd-shepherd-services) + (service-extension activation-service-type + httpd-activation) + (service-extension account-service-type + (const %httpd-accounts)))) + (compose concatenate) + (extend httpd-process-extensions) + (default-value + (httpd-configuration)))) + (define-record-type* nginx-server-configuration make-nginx-server-configuration nginx-server-configuration? -- cgit v1.2.3 From 162a13740041f907f0ce5c2aa05b52b162b4e81a Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 19 Jan 2018 16:25:13 +0100 Subject: =?UTF-8?q?gnu:=20Consistently=20Write=20=E2=80=98file=20system(s)?= =?UTF-8?q?=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is the GNU way. * doc/guix.texi (Build Systems, DNS Services): Write ‘file system(s)’. * gnu/build/vm.scm (create-ext-file-system, create-fat-file-system): Likewise. * gnu/packages/backup.scm (dirvish, rsnapshot)[description]: Likewise. * gnu/packages/check.scm (python-testpath)[description]: Likewise. * gnu/packages/disk.scm (pydf)[description]: Likewise. * gnu/packages/file-systems.scm (disorderfs)[synopsis, description]: Likewise. (glusterfs)[description]: Likewise. * gnu/packages/haskell.scm (ghc-directory, ghc-system-fileio-bootstrap) (ghc-system-fileio)[synopsis]: Likewise. (ghc-fsnotify)[description]: Likewise. * gnu/packages/linux.scm (proot)[description]: Likewise. (jmtpfs)[synopsis, description]: Likewise. * gnu/packages/mate.scm (caja, caja-extensions)[description]: Likewise. * gnu/packages/storage.scm (ceph)[description]: Likewise. * gnu/packages/sync.scm (lsyncd)[description]: Likewise. * gnu/packages/syncthing.scm (syncthing)[synopsis]: Likewise. (go-github-com-zillode-notify)[description]: Likewise. * gnu/services/nfs.scm (pipefs-service-type): Likewise. * guix/scripts/system.scm (perform-action): Likewise. --- gnu/services/nfs.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/nfs.scm b/gnu/services/nfs.scm index 8f58920e4a..6ed4c0eabf 100644 --- a/gnu/services/nfs.scm +++ b/gnu/services/nfs.scm @@ -88,7 +88,7 @@ (define pipefs-directory (pipefs-configuration-mount-point config)) (shepherd-service - (documentation "Mount the pipefs pseudo filesystem.") + (documentation "Mount the pipefs pseudo file system.") (provision '(rpc-pipefs)) (start #~(lambda () -- cgit v1.2.3