summary refs log tree commit diff
path: root/gnu/services
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/base.scm17
-rw-r--r--gnu/services/cgit.scm17
-rw-r--r--gnu/services/dbus.scm2
-rw-r--r--gnu/services/desktop.scm72
-rw-r--r--gnu/services/dns.scm81
-rw-r--r--gnu/services/games.scm2
-rw-r--r--gnu/services/messaging.scm22
-rw-r--r--gnu/services/networking.scm5
-rw-r--r--gnu/services/sound.scm86
-rw-r--r--gnu/services/web.scm72
10 files changed, 354 insertions, 22 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index eb82b2ddcf..b34bb7132b 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -303,15 +303,14 @@ seconds after @code{SIGTERM} has been sent are terminated with
 
 (define (file-system->fstab-entry file-system)
   "Return a @file{/etc/fstab} entry for @var{file-system}."
-  (string-append (case (file-system-title file-system)
-                   ((label)
-                    (string-append "LABEL=" (file-system-device file-system)))
-                   ((uuid)
-                    (string-append
-                     "UUID="
-                     (uuid->string (file-system-device file-system))))
-                   (else
-                    (file-system-device file-system)))
+  (string-append (match (file-system-device file-system)
+                   ((? file-system-label? label)
+                    (string-append "LABEL="
+                                   (file-system-label->string label)))
+                   ((? uuid? uuid)
+                    (string-append "UUID=" (uuid->string uuid)))
+                   ((? string? device)
+                    device))
                  "\t"
                  (file-system-mount-point file-system) "\t"
                  (file-system-type file-system) "\t"
diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm
index 8ef12cd5a0..3289d37333 100644
--- a/gnu/services/cgit.scm
+++ b/gnu/services/cgit.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2018 Christopher Baines <mail@cbaines.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -115,6 +116,10 @@
 (define (serialize-file-object field-name val)
   (serialize-string field-name val))
 
+(define (project-list? val)
+  (or (list? val)
+      (file-object? val)))
+
 
 ;;;
 ;;; Serialize <nginx-server-configuration>
@@ -167,7 +172,12 @@
   (if (null? val) ""
       (serialize-field
        'project-list
-       (plain-file "project-list" (string-join val "\n")))))
+       (if (file-object? val)
+           val
+           (plain-file "project-list" (string-join val "\n"))))))
+
+(define (serialize-extra-options extra-options)
+  (string-join extra-options "\n" 'suffix))
 
 (define repository-directory? string?)
 
@@ -543,7 +553,7 @@ disabled.")
    "Flag which, when set to @samp{#t}, will make cgit omit the standard
 header on all pages.")
   (project-list
-   (list '())
+   (project-list '())
    "A list of subdirectories inside of @code{repository-directory}, relative
 to it, that should loaded as Git repositories.  An empty list means that all
 subdirectories will be loaded.")
@@ -641,6 +651,7 @@ for cgit to allow access to that repository.")
   (define (rest? field)
     (not (memq (configuration-field-name field)
                '(project-list
+                 extra-options
                  repository-directory
                  repositories))))
   #~(string-append
@@ -649,6 +660,8 @@ for cgit to allow access to that repository.")
      #$(serialize-project-list
         'project-list
         (cgit-configuration-project-list config))
+     #$(serialize-extra-options
+        (cgit-configuration-extra-options config))
      #$(serialize-repository-directory
         'repository-directory
         (cgit-configuration-repository-directory config))
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
index 360a8af9ab..1e24d93ccb 100644
--- a/gnu/services/dbus.scm
+++ b/gnu/services/dbus.scm
@@ -63,7 +63,7 @@ all the services that may be activated by the daemon."
                                        (find-files
                                         (string-append
                                          service
-                                         "/share/dbus-1/system-services")
+                                         "/share/dbus-1/")
                                         "\\.service$"))
                                      (list #$@services)))
 
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 517d5d3efe..1e8c02c02a 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -5,6 +5,8 @@
 ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
 ;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2017 Nils Gillmann <ng0@n0.is>
+;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,8 +31,10 @@
   #:use-module (gnu services avahi)
   #:use-module (gnu services xorg)
   #:use-module (gnu services networking)
+  #:use-module (gnu services sound)
   #:use-module ((gnu system file-systems)
                 #:select (%elogind-file-systems))
+  #:use-module (gnu system)
   #:use-module (gnu system shadow)
   #:use-module (gnu system pam)
   #:use-module (gnu packages glib)
@@ -44,9 +48,11 @@
   #:use-module (gnu packages linux)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages mate)
+  #:use-module (gnu packages enlightenment)
   #:use-module (guix records)
   #:use-module (guix packages)
   #:use-module (guix store)
+  #:use-module (guix utils)
   #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
@@ -96,6 +102,10 @@
 
             x11-socket-directory-service
 
+            enlightenment-desktop-configuration
+            enlightenment-desktop-configuration?
+            enlightenment-desktop-service-type
+
             %desktop-services))
 
 ;;; Commentary:
@@ -819,7 +829,8 @@ rules."
                              gnome-polkit-settings)
           (service-extension profile-service-type
                              (compose list
-                                      gnome-package))))))
+                                      gnome-package))))
+   (description "Run the GNOME desktop environment.")))
 
 (define* (gnome-desktop-service #:key (config (gnome-desktop-configuration)))
   "Return a service that adds the @code{gnome} package to the system profile,
@@ -845,7 +856,8 @@ and extends polkit with the actions from @code{gnome-settings-daemon}."
                                       mate-package))
           (service-extension profile-service-type
                              (compose list
-                                      mate-package))))))
+                                      mate-package))))
+   (description "Run the MATE desktop environment.")))
 
 (define* (mate-desktop-service #:key (config (mate-desktop-configuration)))
   "Return a service that adds the @code{mate} package to the system profile,
@@ -899,6 +911,60 @@ with the administrator's password."
                         (let ((directory "/tmp/.X11-unix"))
                           (mkdir-p directory)
                           (chmod directory #o777))))))
+
+;;;
+;;; Enlightenment desktop service.
+;;;
+
+(define-record-type* <enlightenment-desktop-configuration>
+  enlightenment-desktop-configuration make-enlightenment-desktop-configuration
+  enlightenment-desktop-configuration?
+  ;; <package>
+  (enlightenment        enlightenment-package
+                        (default enlightenment)))
+
+(define (enlightenment-setuid-programs enlightenment-desktop-configuration)
+  (match-record enlightenment-desktop-configuration
+                <enlightenment-desktop-configuration>
+                (enlightenment)
+    (list (file-append enlightenment
+                       "/lib/enlightenment/utils/enlightenment_sys")
+          (file-append enlightenment
+                       "/lib/enlightenment/utils/enlightenment_backlight")
+          ;; TODO: Move this binary to a screen-locker service.
+          (file-append enlightenment
+                       "/lib/enlightenment/utils/enlightenment_ckpasswd")
+          (file-append enlightenment
+                       (string-append
+                         "/lib/enlightenment/modules/cpufreq/"
+                         (match (string-tokenize (%current-system)
+                                                 (char-set-complement (char-set #\-)))
+                                ((arch "linux") (string-append "linux-gnu-" arch))
+                                ((arch "gnu")   (string-append "gnu-" arch)))
+                         "-"
+                         (version-major+minor (package-version enlightenment))
+                         "/freqset")))))
+
+(define enlightenment-desktop-service-type
+  (service-type
+   (name 'enlightenment-desktop)
+   (extensions
+    (list (service-extension dbus-root-service-type
+                             (compose list
+                                      (package-direct-input-selector
+                                       "efl")
+                                      enlightenment-package))
+          (service-extension setuid-program-service-type
+                             enlightenment-setuid-programs)
+          (service-extension profile-service-type
+                             (compose list
+                                      enlightenment-package))))
+   (default-value (enlightenment-desktop-configuration))
+   (description
+    "Return a service that adds the @code{enlightenment} package to the system
+profile, and extends dbus with the ability for @code{efl} to generate
+thumbnails and makes setuid the programs which enlightenment needs to function
+as expected.")))
 
 
 ;;;
@@ -934,6 +1000,8 @@ with the administrator's password."
 
          x11-socket-directory-service
 
+         (service alsa-service-type)
+
          %base-services))
 
 ;;; desktop.scm ends here
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 673ab1a98d..2c57a36b84 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -27,6 +27,7 @@
   #:use-module (guix records)
   #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
   #:use-module (ice-9 match)
@@ -41,7 +42,10 @@
             knot-configuration
             define-zone-entries
             zone-file
-            zone-entry))
+            zone-entry
+
+            dnsmasq-service-type
+            dnsmasq-configuration))
 
 ;;;
 ;;; Knot DNS.
@@ -591,3 +595,78 @@
                                            knot-activation)
                         (service-extension account-service-type
                                            (const %knot-accounts))))))
+
+
+;;;
+;;; Dnsmasq.
+;;;
+
+(define-record-type* <dnsmasq-configuration>
+  dnsmasq-configuration make-dnsmasq-configuration
+  dnsmasq-configuration?
+  (package          dnsmasq-configuration-package
+                    (default dnsmasq))  ;package
+  (no-hosts?        dnsmasq-configuration-no-hosts?
+                    (default #f))       ;boolean
+  (port             dnsmasq-configuration-port
+                    (default 53))       ;integer
+  (local-service?   dnsmasq-configuration-local-service?
+                    (default #t))       ;boolean
+  (listen-addresses dnsmasq-configuration-listen-address
+                    (default '()))      ;list of string
+  (resolv-file      dnsmasq-configuration-resolv-file
+                    (default "/etc/resolv.conf")) ;string
+  (no-resolv?       dnsmasq-configuration-no-resolv?
+                    (default #f))       ;boolean
+  (servers          dnsmasq-configuration-servers
+                    (default '()))      ;list of string
+  (cache-size       dnsmasq-configuration-cache-size
+                    (default 150))      ;integer
+  (negative-cache?  dnsmasq-configuration-negative-cache?
+                    (default #t)))      ;boolean
+
+(define dnsmasq-shepherd-service
+  (match-lambda
+    (($ <dnsmasq-configuration> package
+                                no-hosts?
+                                port local-service? listen-addresses
+                                resolv-file no-resolv? servers
+                                cache-size negative-cache?)
+     (shepherd-service
+      (provision '(dnsmasq))
+      (requirement '(networking))
+      (documentation "Run the dnsmasq DNS server.")
+      (start #~(make-forkexec-constructor
+                '(#$(file-append package "/sbin/dnsmasq")
+                  "--keep-in-foreground"
+                  "--pid-file=/run/dnsmasq.pid"
+                  #$@(if no-hosts?
+                         '("--no-hosts")
+                         '())
+                  #$(format #f "--port=~a" port)
+                  #$@(if local-service?
+                         '("--local-service")
+                         '())
+                  #$@(map (cut format #f "--listen-address=~a" <>)
+                          listen-addresses)
+                  #$(format #f "--resolv-file=~a" resolv-file)
+                  #$@(if no-resolv?
+                         '("--no-resolv")
+                         '())
+                  #$@(map (cut format #f "--server=~a" <>)
+                          servers)
+                  #$(format #f "--cache-size=~a" cache-size)
+                  #$@(if negative-cache?
+                         '()
+                         '("--no-negcache")))
+                #:pid-file "/run/dnsmasq.pid"))
+      (stop #~(make-kill-destructor))))))
+
+(define dnsmasq-service-type
+  (service-type
+   (name 'dnsmasq)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             (compose list dnsmasq-shepherd-service))))
+   (default-value (dnsmasq-configuration))
+   (description "Run the dnsmasq DNS server.")))
diff --git a/gnu/services/games.scm b/gnu/services/games.scm
index b146696237..b9d78e078d 100644
--- a/gnu/services/games.scm
+++ b/gnu/services/games.scm
@@ -27,7 +27,7 @@
   #:use-module (guix records)
   #:use-module (ice-9 match)
   #:export (wesnothd-configuration
-            wesnoth-configuration?
+            wesnothd-configuration?
             wesnothd-service-type))
 
 ;;;
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
index 80ffed0f2f..4b7e724a78 100644
--- a/gnu/services/messaging.scm
+++ b/gnu/services/messaging.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -691,7 +692,14 @@ See also @url{https://prosody.im/doc/modules/mod_muc}."
                        (service-extension account-service-type
                                           (const %prosody-accounts))
                        (service-extension activation-service-type
-                                          prosody-activation)))))
+                                          prosody-activation)))
+                (default-value (prosody-configuration
+                                (virtualhosts
+                                 (list
+                                  (virtualhost-configuration
+                                   (domain "localhost"))))))
+                (description
+                 "Run Prosody, a modern XMPP communication server.")))
 
 ;; A little helper to make it easier to document all those fields.
 (define (generate-documentation)
@@ -783,20 +791,24 @@ string, you could instantiate a prosody service like this:
              (default "127.0.0.1"))
   (port bitlbee-configuration-port
         (default 6667))
+  (plugins bitlbee-plugins
+           (default '()))
   (extra-settings bitlbee-configuration-extra-settings
                   (default "")))
 
 (define bitlbee-shepherd-service
   (match-lambda
-    (($ <bitlbee-configuration> bitlbee interface port extra-settings)
-     (let ((conf (plain-file "bitlbee.conf"
-                             (string-append "
+    (($ <bitlbee-configuration> bitlbee interface port
+                                plugins extra-settings)
+     (let ((conf (mixed-text-file "bitlbee.conf"
+                                  "
   [settings]
   User = bitlbee
   ConfigDir = /var/lib/bitlbee
   DaemonInterface = " interface "
   DaemonPort = " (number->string port) "
-" extra-settings))))
+  PluginDir = " (directory-union "bitlbee-plugins" plugins) "/lib/bitlbee
+" extra-settings)))
 
        (with-imported-modules (source-module-closure
                                '((gnu build shepherd)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 0c9c69eef5..e4441f6475 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -464,6 +464,8 @@ make an initial adjustment of more than 1,000 seconds."
                                           openntpd-shepherd-service)
                        (service-extension account-service-type
                                           (const %ntp-accounts))
+                       (service-extension profile-service-type
+                                          (compose list openntpd-configuration-openntpd))
                        (service-extension activation-service-type
                                           openntpd-service-activation)))
                 (default-value (openntpd-configuration))
@@ -952,6 +954,8 @@ wireless networking."))))
                   (extensions
                    (list (service-extension shepherd-root-service-type
                                             connman-shepherd-service)
+                         (service-extension polkit-service-type
+                                            connman-package)
                          (service-extension dbus-root-service-type
                                             connman-package)
                          (service-extension activation-service-type
@@ -959,6 +963,7 @@ wireless networking."))))
                          ;; Add connman to the system profile.
                          (service-extension profile-service-type
                                             connman-package)))
+                  (default-value (connman-configuration))
                   (description
                    "Run @url{https://01.org/connman,Connman},
 a network connection manager."))))
diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
new file mode 100644
index 0000000000..5fe555e8b6
--- /dev/null
+++ b/gnu/services/sound.scm
@@ -0,0 +1,86 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services sound)
+  #:use-module (gnu services base)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix records)
+  #:use-module (guix store)
+  #:use-module (gnu packages pulseaudio)
+  #:use-module (ice-9 match)
+  #:export (alsa-configuration
+            alsa-service-type))
+
+;;; Commentary:
+;;;
+;;; Sound services.
+;;;
+;;; Code:
+
+
+;;;
+;;; ALSA
+;;;
+
+(define-record-type* <alsa-configuration>
+  alsa-configuration make-alsa-configuration alsa-configuration?
+  (pulseaudio?   alsa-configuration-pulseaudio? ;boolean
+                 (default #t))
+  (extra-options alsa-configuration-extra-options ;string
+                 (default "")))
+
+(define (alsa-config-file config)
+  "Return the ALSA configuration file corresponding to CONFIG."
+  (plain-file "asound.conf"
+              (string-append "# Generated by 'alsa-service'.\n\n"
+                             (if (alsa-configuration-pulseaudio? config)
+                                 "# Use PulseAudio by default
+pcm.!default {
+  type pulse
+  fallback \"sysdefault\"
+  hint {
+    show on
+    description \"Default ALSA Output (currently PulseAudio Sound Server)\"
+  }
+}
+
+ctl.!default {
+  type pulse
+  fallback \"sysdefault\"
+}
+"
+                                 "")
+                             (alsa-configuration-extra-options config))))
+
+(define (alsa-etc-service config)
+  (list `("asound.conf" ,(alsa-config-file config))))
+
+(define alsa-service-type
+  (service-type
+   (name 'alsa)
+   (extensions
+    (list (service-extension etc-service-type alsa-etc-service)))
+   (default-value (alsa-configuration))
+   (description "Configure low-level Linux sound support, ALSA.")))
+
+;;; sound.scm ends here
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index b336a8dd30..aae2f3db0d 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
 ;;; Copyright © 2017 nee <nee-git@hidamari.blue>
 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,11 +26,14 @@
 (define-module (gnu services web)
   #:use-module (gnu services)
   #:use-module (gnu services shepherd)
+  #:use-module (gnu system pam)
   #:use-module (gnu system shadow)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages web)
   #:use-module (gnu packages php)
+  #:use-module (gnu packages guile)
   #:use-module (guix records)
+  #:use-module (guix modules)
   #:use-module (guix gexp)
   #:use-module ((guix utils) #:select (version-major))
   #:use-module ((guix packages) #:select (package-version))
@@ -155,7 +159,11 @@
             php-fpm-service-type
             nginx-php-location
 
-            cat-avatar-generator-service))
+            cat-avatar-generator-service
+
+            hpcguix-web-configuration
+            hpcguix-web-configuration?
+            hpcguix-web-service-type))
 
 ;;; Commentary:
 ;;;
@@ -893,3 +901,65 @@ a webserver.")
                 (nginx-server-configuration-locations configuration)))
             (root #~(string-append #$package
                                    "/share/web/cat-avatar-generator"))))))
+
+
+(define-record-type* <hpcguix-web-configuration>
+  hpcguix-web-configuration make-hpcguix-web-configuration
+  hpcguix-web-configuration?
+
+  (package  hpcguix-web-package (default hpcguix-web)) ;<package>
+
+  ;; Specs is gexp of hpcguix-web configuration file
+  (specs    hpcguix-web-configuration-specs))
+
+(define %hpcguix-web-accounts
+  (list (user-group
+         (name "hpcguix-web")
+         (system? #t))
+        (user-account
+         (name "hpcguix-web")
+         (group "hpcguix-web")
+         (system? #t)
+         (comment "hpcguix-web")
+         (home-directory "/var/empty")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define %hpcguix-web-activation
+  #~(begin
+      (use-modules (guix build utils))
+      (let ((home-dir "/var/cache/guix/web")
+            (user (getpwnam "hpcguix-web")))
+        (mkdir-p home-dir)
+        (chown home-dir (passwd:uid user) (passwd:gid user))
+        (chmod home-dir #o755))))
+
+(define (hpcguix-web-shepherd-service config)
+  (let ((specs       (hpcguix-web-configuration-specs config))
+        (hpcguix-web (hpcguix-web-package config)))
+    (with-imported-modules (source-module-closure
+                            '((gnu build shepherd)))
+      (shepherd-service
+       (documentation "hpcguix-web daemon")
+       (provision     '(hpcguix-web))
+       (requirement   '(networking))
+       (start #~(make-forkexec-constructor
+                 (list #$(file-append hpcguix-web "/bin/run")
+                       (string-append "--config="
+                                      #$(scheme-file "hpcguix-web.scm" specs)))
+                 #:user "hpcguix-web"
+                 #:group "hpcguix-web"
+                 #:environment-variables
+                 (list "XDG_CACHE_HOME=/var/cache")))
+       (stop #~(make-kill-destructor))))))
+
+(define hpcguix-web-service-type
+  (service-type
+   (name 'hpcguix-web)
+   (description "Run the hpcguix-web server.")
+   (extensions
+    (list (service-extension account-service-type
+                             (const %hpcguix-web-accounts))
+          (service-extension activation-service-type
+                             (const %hpcguix-web-activation))
+          (service-extension shepherd-root-service-type
+                             (compose list hpcguix-web-shepherd-service))))))