Mirror of GNU Guix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1734 lines
68 KiB

Correct name and email address for ng0. * .mailmap, Makefile.am, doc/guix.de.texi, doc/guix.fr.texi, doc/guix.texi, etc/completion/fish/guix.fish, gnu/packages/accessibility.scm, gnu/packages/admin.scm, gnu/packages/audio.scm, gnu/packages/autotools.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/cinnamon.scm, gnu/packages/compression.scm, gnu/packages/crypto.scm, gnu/packages/databases.scm, gnu/packages/django.scm, gnu/packages/dns.scm, gnu/packages/elixir.scm, gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm, gnu/packages/enlightenment.scm, gnu/packages/erlang.scm, gnu/packages/fonts.scm, gnu/packages/fontutils.scm, gnu/packages/forth.scm, gnu/packages/fvwm.scm, gnu/packages/games.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gnuzilla.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm,gnu/packages/guile-xyz.scm, gnu/packages/haskell-check.scm, gnu/packages/haskell-crypto.scm, gnu/packages/haskell.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/irc.scm, gnu/packages/language.scm, gnu/packages/libcanberra.scm, gnu/packages/linux.scm, gnu/packages/lisp.scm, gnu/packages/lolcode.scm, gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/mail.scm, gnu/packages/markup.scm, gnu/packages/mate.scm, gnu/packages/maths.scm, gnu/packages/mc.scm, gnu/packages/messaging.scm, gnu/packages/music.scm, gnu/packages/ncurses.scm, gnu/packages/networking.scm, gnu/packages/nickle.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm, gnu/packages/perl-check.scm, gnu/packages/perl.scm, gnu/packages/python-compression.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/python-xyz.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/ssh.scm, gnu/packages/suckless.scm, gnu/packages/tbb.scm, gnu/packages/telephony.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm, gnu/packages/tor.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/web.scm, gnu/packages/wm.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/services/certbot.scm, gnu/services/desktop.scm, gnu/services/version-control.scm, gnu/services/web.scm, guix/import/hackage.scm, guix/licenses.scm: Correct name and email address for ng0. Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr>
3 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Rename 'dmd' services to 'shepherd'. * gnu/services/shepherd.scm (dmd-root-service-type, %dmd-root-service) (dmd-service-type, <dmd-service>, dmd-service, dmd-service?) (make-dmd-service, dmd-service-documentation, dmd-service-provision) (dmd-service-requirement, dmd-service-respawn, dmd-service-start) (dmd-service-stop, dmd-service-auto-start?, dmd-service-modules) (dmd-service-imported-modules, dmd-service-file-name, dmd-service-file) (dmd-service-back-edges): Rename to... (shepherd-root-service-type, %shepherd-root-service, shepherd-service-type) (<shepherd-service>, shepherd-service, shepherd-service?) (make-shepherd-service, shepherd-service-documentation) (shepherd-service-provision, shepherd-service-requirement) (shepherd-service-respawn, shepherd-service-start) (shepherd-service-stop, shepherd-service-auto-start?) (shepherd-service-modules, shepherd-service-imported-modules) (shepherd-service-file-name, shepherd-service-file) (shepherd-service-back-edges): ...this * gnu/services.scm: Adjust comments. * gnu/services/avahi.scm (avahi-dmd-service): Rename to... (avahi-shepherd-service): ... this. * gnu/services/base.scm (%root-file-system-dmd-service) (file-system->dmd-service-name, mapped-device->dmd-service-name) (dependency->dmd-service-name, file-system-dmd-service) (mingetty-dmd-service, nscd-dmd-service, guix-dmd-service) (guix-publish-dmd-service, udev-dmd-service, gpm-dmd-service): Rename to... (%root-file-system-shepherd-service) (file-system->shepherd-service-name, mapped-device->shepherd-service-name) (dependency->shepherd-service-name, file-system-shepherd-service) (mingetty-shepherd-service, nscd-shepherd-service, guix-shepherd-service) (guix-publish-shepherd-service, udev-shepherd-service) (gpm-shepherd-service): ... this. * gnu/services/databases.scm (postgresql-dmd-service): Rename to... (postgresql-shepherd-service): ... this. * gnu/services/desktop.scm (upower-dmd-service, elogind-dmd-service): Rename to... (upower-shepherd-service, elogind-shepherd-service): ... this. * gnu/services/dbus.scm (dbus-dmd-service): Rename to... (dbus-shepherd-service): ... this. * gnu/services/lirc.scm (lirc-dmd-service): Rename to... (lirc-shepherd-service): ... this. * gnu/services/mail.scm (dovecot-dmd-service): Rename to... (dovecot-shepherd-service): ... this. * gnu/services/networking.scm (ntp-dmd-service, tor-dmd-service) (bitlbee-dmd-service, wicd-dmd-service, network-manager-dmd-service): Rename to... (dbus-shepherd-service): ... this. * gnu/services/ssh.scm (lsh-dmd-service): Rename to... (lsh-shepherd-service): ... this. * gnu/services/web.scm (nginx-dmd-service): Rename to... (nginx-shepherd-service): ... this. * gnu/services/xorg.scm (slim-dmd-service): Rename to... (slim-shepherd-service): ... this. * gnu/system.scm (essential-services): Use '%shepherd-root-service'. * gnu/system/install.scm (cow-store-service-type): Adjust accordingly. * guix/scripts/system.scm (dmd-service-node-label, dmd-service-node-type) (export-dmd-graph): Likewise. * tests/guix-system.sh: Likewise. * tests/services.scm ("dmd-service-back-edges"): Rename to... ("shepherd-service-back-edges"): Adjust accordingly. * doc/guix.texi: Likewise. * doc/images/service-graph.dot: Use 'shepherd' service name.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
services: Introduce extensible services. This patch rewrites GuixSD services to make them extensible. * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/dbus.scm. * gnu/services.scm (<service>): Replace with new record type. (<service-extension>, <service-type>): New record types. (write-service-type, compute-boot-script, second-argument): New procedures. (%boot-service, boot-service-type): New variables. (file-union, directory-union, modprobe-wrapper, activation-service->script, activation-script, gexps->activation-gexp): New procedures. (activation-service-type, %activation-service): New variables. (etc-directory, files->etc-directory, etc-service): New procedures. (etc-service-type, setuid-program-service, firmware-service-type): New variables. (firmware->activation-gexp): New procedure. (&service-error, &missing-target-service-error, &ambiguous-target-service-error): New condition types. (service-back-edges, fold-services): New procedures. * gnu/services/avahi.scm (<avahi-configuration>): New record type. (configuration-file): Replace keyword parameters with a single 'config' parameter. (%avahi-accounts, %avahi-activation, avahi-service-type): New variables. (avahi-dmd-service): New procedure. (avahi-service): Rewrite using 'service' and 'avahi-configuration'. * gnu/services/base.scm (%root-file-system-dmd-service, root-file-system-service-type): New variables. (root-file-system-service): Use them. (file-system->dmd-service-name): New procedure. (file-system-service-type): New variable. (file-system-service): Use it. Replace keyword parameters with a single 'file-system' object. (user-unmount-service-type): New variable. (user-unmount-service): Use it. (user-processes-service-type): New variable. (user-processes-service): Use it. (host-name-service-type): New variable. (host-name-service): Use it. (console-keymap-service-type): New variable. (console-keymap-service): Use it. (console-font-service-type): New variable. (console-font-service): Use it. (mingetty-pam-service, mingetty-dmd-service): New procedures. (mingetty-service-type): New variable. (mingetty-service): Use it. (nscd-dmd-service): New procedure. (nscd-activation, nscd-service-type): New variables. (nscd-service): Use the latter. (syslog-service-type): New variable. (syslog-service): Use it. (<guix-configuration>): New record type. (%default-guix-configuration): New variable. (guix-dmd-service, guix-accounts, guix-activation): New procedures. (guix-service-type): New variable. (guix-service): Replace list of keyword parameters with a single 'config' parameter. Rewrite using 'service'. (<udev-configuration>): New record type. (udev-dmd-service): New procedure. (udev-service-type): New variable. (udev-service): Use it. (device-mapping-service-type): New variable. (device-mapping-service): Use it. (swap-service-type): New variable. (swap-service): Use it. * gnu/services/databases.scm (<postgresql-configuration>): New record type. (%postgresql-accounts, postgresql-activation): New variables. (postgresql-dmd-service): New procedure. (postgresql-service): Rewrite using 'service' and 'postgresql-configuration'. * gnu/services/dbus.scm: New file. * gnu/services/desktop.scm (dbus-configuration-directory, dbus-service): Remove. (wrapped-dbus-service): New procedure. (<upower-configuration>): New record type. (upower-configuration-file): Replace keyword parameters with single <upower-configuration> parameter. (%upower-accounts, %upower-activation): New variables. (upower-dbus-service, upower-dmd-service): New procedures. (upower-service-type): New variable. (upower-service): Rewrite using 'service' and 'upower-configuration'. (%colord-activation, %colord-accounts): New variables. (colord-dmd-service): New procedure. (colord-service-type): New variable. (colord-service): Rewrite using 'service'. (<geoclue-configuration>): New record type. (geoclue-configuration-file): Replace keyword parameters with a single 'config' parameter. (geoclue-dbus-service, geoclue-dmd-service): New procedures. (%geoclue-accounts, geoclue-service-type): New variables. (geoclue-service): Rewrite using 'service' and 'geoclue-configuration'. (%polkit-accounts, %polkit-pam-services, polkit-service-type): New variables. (polkit-dmd-service): New procedure. (polkit-service): Rewrite using 'service'. (<elogind-configuration>)[elogind]: New field. (elogind-dmd-service): New procedure. (elogind-service-type): New variable. (elogind-service): Rewrite using 'service'. (%desktop-services): Remove argument to 'dbus-service'. Remove 'map' over %BASE-SERVICES. * gnu/services/dmd.scm (dmd-boot-gexp): New procedure. (dmd-root-service-type, %dmd-root-service): New variables. (dmd-service-type): New macro. (<dmd-service>): New record type. * gnu/services/lirc.scm (<lirc-configuration>): New record type. (%lirc-activation): New variable. (lirc-dmd-service): New procedure. (lirc-service-type): New variable. (lirc-service): Rewrite using 'service' and 'lirc-configuration'. * gnu/services/networking.scm (<static-networking>): New record type. (static-networking-service-type): New variable. (static-networking-service): Rewrite using 'service' and 'static-networking'. (dhcp-client-service-type): New variable. (dhcp-client-service): Rewrite using 'service'. (<ntp-configuration>): New record type. (ntp-dmd-service): New procedure. (ntp-service-type): New variable. (ntp-service): New procedure. (%tor-accounts, tor-service-type): New variable. (tor-dmd-service): New procedure. (tor-service): Rewrite using 'service'. (<bitlbee-configuration>): New record type. (bitlbee-dmd-service): New procedure. (%bitlbee-accounts, %bitlbee-activation, bitlbee-service-type): New variables. (bitlbee-service): Rewrite using 'service'. (%wicd-activation): New variable. (wicd-dmd-service): New procedure. (wicd-service-type): New variable. (wicd-service): Rewrite using 'service'. * gnu/services/ssh.scm (<lsh-configuration>): New record type. (activation): Rename to... (lsh-initialization): ... this. (lsh-activation, lsh-dmd-service, lsh-pam-services): New procedures. (lsh-service-type): New variable. (lsh-service): Rewrite using 'service' and 'lsh-configuration'. * gnu/services/web.scm (<nginx-configuration>): New record type. (%nginx-accounts): New variable. (nginx-activation, nginx-dmd-service): New procedures. (nginx-service-type): New variable. (nginx-service): Rewrite using 'service' and 'nginx-configuration'. * gnu/services/xorg.scm (<slim-configuration>): New record type. (slim-pam-service, slim-dmd-service): New procedures. (slim-service-type): New variable. (slim-service): Rewrite using 'service' and 'slim-configuration'. * gnu/system.scm (file-union): Remove. (other-file-system-services): Adjust to new 'file-system-service' signature. (essential-services): Add #:container? parameter. Add %DMD-ROOT-SERVICE, %ACTIVATION-SERVICE, and calls to 'pam-root-service', 'account-service', 'operating-system-etc-service', and a SETUID-PROGRAM-SERVICE instance. (operating-system-services): Pass #:container? to 'essential-services. (etc-directory): Remove. (operating-system-etc-service): New procedure. Rewrite as a call to 'etc-service'. (operating-system-accounts): Change to not return accounts required by services. (operating-system-etc-directory): Rewrite as a call to 'fold-services' and 'etc-directory'. (user-group->gexp, user-account->gexp, modprobe-wrapper): Remove. (operating-system-activation-script): Rewrite as a call to 'fold-services' and 'activation-service->script'. (operating-system-boot-script): Likewise. (operating-system-derivation): Add call to 'lower-object'. (emacs-site-file, emacs-site-directory, shells-file): Change to use 'computed-file' and 'scheme-file' instead of the monadic procedures. * gnu/system/install.scm (cow-store-service-type): New variable. (cow-store-service): Rewrite using 'service'. (/etc/configuration-files): New procedure. (configuration-template-service-type, %configuration-template-service): New variables. (configuration-template-service): Remove. (installation-services): Adjust accordingly. Adjust argument to 'guix-service'. * gnu/system/linux.scm (/etc-entry, pam-root-service): New procedures. (pam-root-service-type): New variable. * gnu/system/shadow.scm (user-group->gexp, user-account->gexp, account-activation, etc-skel, account-service): New procedures. (account-service-type): New variable. * tests/services.scm: New file. * doc/guix.texi (Base Services, Desktop Services): Adjust accordingly. (Defining Services): Rewrite. * doc/images/service-graph.dot: New file. * doc.am (DOT_FILES): Add it. * po/guix/POTFILES.in: Add gnu/services.scm.
6 years ago
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 David Thompson <davet@gnu.org>
  3. ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2016 ng0 <ng0@n0.is>
  5. ;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu>
  6. ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
  7. ;;; Copyright © 2017 nee <nee-git@hidamari.blue>
  8. ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
  9. ;;; Copyright © 2018 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
  10. ;;; Copyright © 2017, 2018, 2019 Christopher Baines <mail@cbaines.net>
  11. ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
  12. ;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de>
  13. ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
  14. ;;;
  15. ;;; This file is part of GNU Guix.
  16. ;;;
  17. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  18. ;;; under the terms of the GNU General Public License as published by
  19. ;;; the Free Software Foundation; either version 3 of the License, or (at
  20. ;;; your option) any later version.
  21. ;;;
  22. ;;; GNU Guix is distributed in the hope that it will be useful, but
  23. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  24. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. ;;; GNU General Public License for more details.
  26. ;;;
  27. ;;; You should have received a copy of the GNU General Public License
  28. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  29. (define-module (gnu services web)
  30. #:use-module (gnu services)
  31. #:use-module (gnu services shepherd)
  32. #:use-module (gnu services admin)
  33. #:use-module (gnu services getmail)
  34. #:use-module (gnu services mail)
  35. #:use-module (gnu system pam)
  36. #:use-module (gnu system shadow)
  37. #:use-module (gnu packages admin)
  38. #:use-module (gnu packages databases)
  39. #:use-module (gnu packages web)
  40. #:use-module (gnu packages patchutils)
  41. #:use-module (gnu packages php)
  42. #:use-module (gnu packages python)
  43. #:use-module (gnu packages gnupg)
  44. #:use-module (gnu packages guile)
  45. #:use-module (gnu packages logging)
  46. #:use-module (gnu packages mail)
  47. #:use-module (guix packages)
  48. #:use-module (guix records)
  49. #:use-module (guix modules)
  50. #:use-module (guix utils)
  51. #:use-module (guix gexp)
  52. #:use-module ((guix store) #:select (text-file))
  53. #:use-module ((guix utils) #:select (version-major))
  54. #:use-module ((guix packages) #:select (package-version))
  55. #:use-module (srfi srfi-1)
  56. #:use-module (srfi srfi-9)
  57. #:use-module (ice-9 match)
  58. #:export (<httpd-configuration>
  59. httpd-configuration
  60. httpd-configuration?
  61. httpd-configuration-package
  62. httpd-configuration-pid-file
  63. httpd-configuration-config
  64. <httpd-virtualhost>
  65. httpd-virtualhost
  66. httpd-virtualhost?
  67. httpd-virtualhost-addresses-and-ports
  68. httpd-virtualhost-contents
  69. <httpd-config-file>
  70. httpd-config-file
  71. httpd-config-file?
  72. httpd-config-file-modules
  73. httpd-config-file-server-root
  74. httpd-config-file-server-name
  75. httpd-config-file-listen
  76. httpd-config-file-pid-file
  77. httpd-config-file-error-log
  78. httpd-config-file-user
  79. httpd-config-file-group
  80. <httpd-module>
  81. httpd-module
  82. httpd-module?
  83. %default-httpd-modules
  84. httpd-service-type
  85. <nginx-configuration>
  86. nginx-configuration
  87. nginx-configuration?
  88. nginx-configuartion-nginx
  89. nginx-configuration-log-directory
  90. nginx-configuration-run-directory
  91. nginx-configuration-server-blocks
  92. nginx-configuration-upstream-blocks
  93. nginx-configuration-server-names-hash-bucket-size
  94. nginx-configuration-server-names-hash-bucket-max-size
  95. nginx-configuration-modules
  96. nginx-configuration-extra-content
  97. nginx-configuration-file
  98. <nginx-server-configuration>
  99. nginx-server-configuration
  100. nginx-server-configuration?
  101. nginx-server-configuration-listen
  102. nginx-server-configuration-server-name
  103. nginx-server-configuration-root
  104. nginx-server-configuration-locations
  105. nginx-server-configuration-index
  106. nginx-server-configuration-ssl-certificate
  107. nginx-server-configuration-ssl-certificate-key
  108. nginx-server-configuration-server-tokens?
  109. nginx-server-configuration-raw-content
  110. <nginx-upstream-configuration>
  111. nginx-upstream-configuration
  112. nginx-upstream-configuration?
  113. nginx-upstream-configuration-name
  114. nginx-upstream-configuration-servers
  115. <nginx-location-configuration>
  116. nginx-location-configuration
  117. nginx-location-configuration?
  118. nginx-location-configuration-uri
  119. nginx-location-configuration-body
  120. <nginx-named-location-configuration>
  121. nginx-named-location-configuration
  122. nginx-named-location-configuration?
  123. nginx-named-location-configuration-name
  124. nginx-named-location-configuration-body
  125. nginx-service
  126. nginx-service-type
  127. fcgiwrap-configuration
  128. fcgiwrap-configuration?
  129. fcgiwrap-service-type
  130. <php-fpm-configuration>
  131. php-fpm-configuration
  132. make-php-fpm-configuration
  133. php-fpm-configuration?
  134. php-fpm-configuration-php
  135. php-fpm-configuration-socket
  136. php-fpm-configuration-user
  137. php-fpm-configuration-group
  138. php-fpm-configuration-socket-user
  139. php-fpm-configuration-socket-group
  140. php-fpm-configuration-pid-file
  141. php-fpm-configuration-log-file
  142. php-fpm-configuration-process-manager
  143. php-fpm-configuration-display-errors
  144. php-fpm-configuration-timezone
  145. php-fpm-configuration-workers-log-file
  146. php-fpm-configuration-file
  147. <php-fpm-dynamic-process-manager-configuration>
  148. php-fpm-dynamic-process-manager-configuration
  149. make-php-fpm-dynamic-process-manager-configuration
  150. php-fpm-dynamic-process-manager-configuration?
  151. php-fpm-dynamic-process-manager-configuration-max-children
  152. php-fpm-dynamic-process-manager-configuration-start-servers
  153. php-fpm-dynamic-process-manager-configuration-min-spare-servers
  154. php-fpm-dynamic-process-manager-configuration-max-spare-servers
  155. <php-fpm-static-process-manager-configuration>
  156. php-fpm-static-process-manager-configuration
  157. make-php-fpm-static-process-manager-configuration
  158. php-fpm-static-process-manager-configuration?
  159. php-fpm-static-process-manager-configuration-max-children
  160. <php-fpm-on-demand-process-manager-configuration>
  161. php-fpm-on-demand-process-manager-configuration
  162. make-php-fpm-on-demand-process-manager-configuration
  163. php-fpm-on-demand-process-manager-configuration?
  164. php-fpm-on-demand-process-manager-configuration-max-children
  165. php-fpm-on-demand-process-manager-configuration-process-idle-timeout
  166. php-fpm-service-type
  167. nginx-php-location
  168. cat-avatar-generator-service
  169. hpcguix-web-configuration
  170. hpcguix-web-configuration?
  171. hpcguix-web-service-type
  172. <tailon-configuration-file>
  173. tailon-configuration-file
  174. tailon-configuration-file?
  175. tailon-configuration-file-files
  176. tailon-configuration-file-bind
  177. tailon-configuration-file-relative-root
  178. tailon-configuration-file-allow-transfers?
  179. tailon-configuration-file-follow-names?
  180. tailon-configuration-file-tail-lines
  181. tailon-configuration-file-allowed-commands
  182. tailon-configuration-file-debug?
  183. tailon-configuration-file-http-auth
  184. tailon-configuration-file-users
  185. <tailon-configuration>
  186. tailon-configuration
  187. tailon-configuration?
  188. tailon-configuration-config-file
  189. tailon-configuration-package
  190. tailon-service-type
  191. <varnish-configuration>
  192. varnish-configuration
  193. varnish-configuration?
  194. varnish-configuration-package
  195. varnish-configuration-name
  196. varnish-configuration-backend
  197. varnish-configuration-vcl
  198. varnish-configuration-listen
  199. varnish-configuration-storage
  200. varnish-configuration-parameters
  201. varnish-configuration-extra-options
  202. varnish-service-type
  203. <patchwork-database-configuration>
  204. patchwork-database-configuration
  205. patchwork-database-configuration?
  206. patchwork-database-configuration-engine
  207. patchwork-database-configuration-name
  208. patchwork-database-configuration-user
  209. patchwork-database-configuration-password
  210. patchwork-database-configuration-host
  211. patchwork-database-configuration-port
  212. <patchwork-settings-module>
  213. patchwork-settings-module
  214. patchwork-settings-module?
  215. patchwork-settings-module-database-configuration
  216. patchwork-settings-module-secret-key
  217. patchwork-settings-module-allowed-hosts
  218. patchwork-settings-module-default-from-email
  219. patchwork-settings-module-static-url
  220. patchwork-settings-module-admins
  221. patchwork-settings-module-debug?
  222. patchwork-settings-module-enable-rest-api?
  223. patchwork-settings-module-enable-xmlrpc?
  224. patchwork-settings-module-force-https-links?
  225. patchwork-settings-module-extra-settings
  226. <patchwork-configuration>
  227. patchwork-configuration
  228. patchwork-configuration?
  229. patchwork-configuration-patchwork
  230. patchwork-configuration-settings-module
  231. patchwork-configuration-domain
  232. patchwork-virtualhost
  233. patchwork-service-type
  234. mumi-service-type))
  235. ;;; Commentary:
  236. ;;;
  237. ;;; Web services.
  238. ;;;
  239. ;;; Code:
  240. (define-record-type* <httpd-module>
  241. httpd-module make-httpd-module
  242. httpd-module?
  243. (name httpd-load-module-name)
  244. (file httpd-load-module-file))
  245. ;; Default modules for the httpd-service-type, taken from etc/httpd/httpd.conf
  246. ;; file in the httpd package.
  247. (define %default-httpd-modules
  248. (map (match-lambda
  249. ((name file)
  250. (httpd-module
  251. (name name)
  252. (file file))))
  253. '(("authn_file_module" "modules/mod_authn_file.so")
  254. ("authn_core_module" "modules/mod_authn_core.so")
  255. ("authz_host_module" "modules/mod_authz_host.so")
  256. ("authz_groupfile_module" "modules/mod_authz_groupfile.so")
  257. ("authz_user_module" "modules/mod_authz_user.so")
  258. ("authz_core_module" "modules/mod_authz_core.so")
  259. ("access_compat_module" "modules/mod_access_compat.so")
  260. ("auth_basic_module" "modules/mod_auth_basic.so")
  261. ("reqtimeout_module" "modules/mod_reqtimeout.so")
  262. ("filter_module" "modules/mod_filter.so")
  263. ("mime_module" "modules/mod_mime.so")
  264. ("log_config_module" "modules/mod_log_config.so")
  265. ("env_module" "modules/mod_env.so")
  266. ("headers_module" "modules/mod_headers.so")
  267. ("setenvif_module" "modules/mod_setenvif.so")
  268. ("version_module" "modules/mod_version.so")
  269. ("unixd_module" "modules/mod_unixd.so")
  270. ("status_module" "modules/mod_status.so")
  271. ("autoindex_module" "modules/mod_autoindex.so")
  272. ("dir_module" "modules/mod_dir.so")
  273. ("alias_module" "modules/mod_alias.so"))))
  274. (define-record-type* <httpd-config-file>
  275. httpd-config-file make-httpd-config-file
  276. httpd-config-file?
  277. (modules httpd-config-file-modules
  278. (default %default-httpd-modules))
  279. (server-root httpd-config-file-server-root
  280. (default httpd))
  281. (server-name httpd-config-file-server-name
  282. (default #f))
  283. (document-root httpd-config-file-document-root
  284. (default "/srv/http"))
  285. (listen httpd-config-file-listen
  286. (default '("80")))
  287. (pid-file httpd-config-file-pid-file
  288. (default "/var/run/httpd"))
  289. (error-log httpd-config-file-error-log
  290. (default "/var/log/httpd/error_log"))
  291. (user httpd-config-file-user
  292. (default "httpd"))
  293. (group httpd-config-file-group
  294. (default "httpd"))
  295. (extra-config httpd-config-file-extra-config
  296. (default
  297. (list "TypesConfig etc/httpd/mime.types"))))
  298. (define-gexp-compiler (httpd-config-file-compiler
  299. (file <httpd-config-file>) system target)
  300. (match file
  301. (($ <httpd-config-file> load-modules server-root server-name
  302. document-root listen pid-file error-log
  303. user group extra-config)
  304. (gexp->derivation
  305. "httpd.conf"
  306. #~(call-with-output-file (ungexp output "out")
  307. (lambda (port)
  308. (display
  309. (string-append
  310. (ungexp-splicing
  311. `(,@(append-map
  312. (match-lambda
  313. (($ <httpd-module> name module)
  314. `("LoadModule " ,name " " ,module "\n")))
  315. load-modules)
  316. ,@`("ServerRoot " ,server-root "\n")
  317. ,@(if server-name
  318. `("ServerName " ,server-name "\n")
  319. '())
  320. ,@`("DocumentRoot " ,document-root "\n")
  321. ,@(append-map
  322. (lambda (listen-value)
  323. `("Listen " ,listen-value "\n"))
  324. listen)
  325. ,@(if pid-file
  326. `("Pidfile " ,pid-file "\n")
  327. '())
  328. ,@(if error-log
  329. `("ErrorLog " ,error-log "\n")
  330. '())
  331. ,@(if user
  332. `("User " ,user "\n")
  333. '())
  334. ,@(if group
  335. `("Group " ,group "\n")
  336. '())
  337. "\n\n"
  338. ,@extra-config)))
  339. port)))
  340. #:local-build? #t))))
  341. (define-record-type <httpd-virtualhost>
  342. (httpd-virtualhost addresses-and-ports contents)
  343. httpd-virtualhost?
  344. (addresses-and-ports httpd-virtualhost-addresses-and-ports)
  345. (contents httpd-virtualhost-contents))
  346. (define-record-type* <httpd-configuration>
  347. httpd-configuration make-httpd-configuration
  348. httpd-configuration?
  349. (package httpd-configuration-package
  350. (default httpd))
  351. (pid-file httpd-configuration-pid-file
  352. (default "/var/run/httpd"))
  353. (config httpd-configuration-config
  354. (default (httpd-config-file))))
  355. (define %httpd-accounts
  356. (list (user-group (name "httpd") (system? #t))
  357. (user-account
  358. (name "httpd")
  359. (group "httpd")
  360. (system? #t)
  361. (comment "Apache HTTPD server user")
  362. (home-directory "/var/empty")
  363. (shell (file-append shadow "/sbin/nologin")))))
  364. (define httpd-shepherd-services
  365. (match-lambda
  366. (($ <httpd-configuration> package pid-file config)
  367. (list (shepherd-service
  368. (provision '(httpd))
  369. (documentation "The Apache HTTP Server")
  370. (requirement '(networking))
  371. (start #~(make-forkexec-constructor
  372. `(#$(file-append package "/bin/httpd")
  373. #$@(if config
  374. (list "-f" config)
  375. '()))
  376. #:pid-file #$pid-file))
  377. (stop #~(make-kill-destructor)))))))
  378. (define httpd-activation
  379. (match-lambda
  380. (($ <httpd-configuration> package pid-file config)
  381. (match-record
  382. config
  383. <httpd-config-file>
  384. (error-log document-root)
  385. #~(begin
  386. (use-modules (guix build utils))
  387. (mkdir-p #$(dirname error-log))
  388. (mkdir-p #$document-root))))))
  389. (define (httpd-process-extensions original-config extension-configs)
  390. (let ((config (httpd-configuration-config
  391. original-config)))
  392. (if (httpd-config-file? config)
  393. (httpd-configuration
  394. (inherit original-config)
  395. (config
  396. (httpd-config-file
  397. (inherit config)
  398. (extra-config
  399. (append (httpd-config-file-extra-config config)
  400. (append-map
  401. (match-lambda
  402. (($ <httpd-virtualhost>
  403. addresses-and-ports
  404. contents)
  405. `(,(string-append
  406. "\n<VirtualHost " addresses-and-ports ">\n")
  407. ,@contents
  408. "\n</VirtualHost>\n"))
  409. ((? string? x)
  410. `("\n" ,x "\n"))
  411. ((? list? x)
  412. `("\n" ,@x "\n")))
  413. extension-configs)))))))))
  414. (define httpd-service-type
  415. (service-type (name 'httpd)
  416. (extensions
  417. (list (service-extension shepherd-root-service-type
  418. httpd-shepherd-services)
  419. (service-extension activation-service-type
  420. httpd-activation)
  421. (service-extension account-service-type
  422. (const %httpd-accounts))))
  423. (compose concatenate)
  424. (extend httpd-process-extensions)
  425. (default-value
  426. (httpd-configuration))))
  427. (define-record-type* <nginx-server-configuration>
  428. nginx-server-configuration make-nginx-server-configuration
  429. nginx-server-configuration?
  430. (listen nginx-server-configuration-listen
  431. (default '("80" "443 ssl")))
  432. (server-name nginx-server-configuration-server-name
  433. (default (list 'default)))
  434. (root nginx-server-configuration-root
  435. (default "/srv/http"))
  436. (locations nginx-server-configuration-locations
  437. (default '()))
  438. (index nginx-server-configuration-index
  439. (default (list "index.html")))
  440. (try-files nginx-server-configuration-try-files
  441. (default '()))
  442. (ssl-certificate nginx-server-configuration-ssl-certificate
  443. (default #f))
  444. (ssl-certificate-key nginx-server-configuration-ssl-certificate-key
  445. (default #f))
  446. (server-tokens? nginx-server-configuration-server-tokens?
  447. (default #f))
  448. (raw-content nginx-server-configuration-raw-content
  449. (default '())))
  450. (define-record-type* <nginx-upstream-configuration>
  451. nginx-upstream-configuration make-nginx-upstream-configuration
  452. nginx-upstream-configuration?
  453. (name nginx-upstream-configuration-name)
  454. (servers nginx-upstream-configuration-servers))
  455. (define-record-type* <nginx-location-configuration>
  456. nginx-location-configuration make-nginx-location-configuration
  457. nginx-location-configuration?
  458. (uri nginx-location-configuration-uri
  459. (default #f))
  460. (body nginx-location-configuration-body))
  461. (define-record-type* <nginx-named-location-configuration>
  462. nginx-named-location-configuration make-nginx-named-location-configuration
  463. nginx-named-location-configuration?
  464. (name nginx-named-location-configuration-name
  465. (default #f))
  466. (body nginx-named-location-configuration-body))
  467. (define-record-type* <nginx-configuration>
  468. nginx-configuration make-nginx-configuration
  469. nginx-configuration?
  470. (nginx nginx-configuration-nginx ;<package>
  471. (default nginx))
  472. (log-directory nginx-configuration-log-directory ;string
  473. (default "/var/log/nginx"))
  474. (run-directory nginx-configuration-run-directory ;string
  475. (default "/var/run/nginx"))
  476. (server-blocks nginx-configuration-server-blocks
  477. (default '())) ;list of <nginx-server-configuration>
  478. (upstream-blocks nginx-configuration-upstream-blocks
  479. (default '())) ;list of <nginx-upstream-configuration>
  480. (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size
  481. (default #f))
  482. (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size
  483. (default #f))
  484. (modules nginx-configuration-modules (default '()))
  485. (global-directives nginx-configuration-global-directives (default '()))
  486. (extra-content nginx-configuration-extra-content
  487. (default ""))
  488. (file nginx-configuration-file ;#f | string | file-like
  489. (default #f)))
  490. (define (config-domain-strings names)
  491. "Return a string denoting the nginx config representation of NAMES, a list
  492. of domain names."
  493. (map (match-lambda
  494. ('default "_ ")
  495. ((? string? str) (list str " ")))
  496. names))
  497. (define (config-index-strings names)
  498. "Return a string denoting the nginx config representation of NAMES, a list
  499. of index files."
  500. (map (match-lambda
  501. ((? string? str) (list str " ")))
  502. names))
  503. (define (emit-load-module module)
  504. (list "load_module " module ";\n"))
  505. (define emit-global-directive
  506. (match-lambda
  507. ((key . (? list? alist))
  508. (format #f "~a { ~{~a~}}~%" key (map emit-global-directive alist)))
  509. ((key . value)
  510. (format #f "~a ~a;~%" key value))))
  511. (define emit-nginx-location-config
  512. (match-lambda
  513. (($ <nginx-location-configuration> uri body)
  514. (list
  515. " location " uri " {\n"
  516. (map (lambda (x) (list " " x "\n")) body)
  517. " }\n"))
  518. (($ <nginx-named-location-configuration> name body)
  519. (list
  520. " location @" name " {\n"
  521. (map (lambda (x) (list " " x "\n")) body)
  522. " }\n"))))
  523. (define (emit-nginx-server-config server)
  524. (let ((listen (nginx-server-configuration-listen server))
  525. (server-name (nginx-server-configuration-server-name server))
  526. (ssl-certificate (nginx-server-configuration-ssl-certificate server))
  527. (ssl-certificate-key
  528. (nginx-server-configuration-ssl-certificate-key server))
  529. (root (nginx-server-configuration-root server))
  530. (index (nginx-server-configuration-index server))
  531. (try-files (nginx-server-configuration-try-files server))
  532. (server-tokens? (nginx-server-configuration-server-tokens? server))
  533. (locations (nginx-server-configuration-locations server))
  534. (raw-content (nginx-server-configuration-raw-content server)))
  535. (define-syntax-parameter <> (syntax-rules ()))
  536. (define-syntax-rule (and/l x tail ...)
  537. (let ((x* x))
  538. (if x*
  539. (syntax-parameterize ((<> (identifier-syntax x*)))
  540. (list tail ...))
  541. '())))
  542. (list
  543. " server {\n"
  544. (map (lambda (directive) (list " listen " directive ";\n")) listen)
  545. " server_name " (config-domain-strings server-name) ";\n"
  546. (and/l ssl-certificate " ssl_certificate " <> ";\n")
  547. (and/l ssl-certificate-key " ssl_certificate_key " <> ";\n")
  548. " root " root ";\n"
  549. " index " (config-index-strings index) ";\n"
  550. (if (not (nil? try-files))
  551. (and/l (config-index-strings try-files) " try_files " <> ";\n")
  552. "")
  553. " server_tokens " (if server-tokens? "on" "off") ";\n"
  554. "\n"
  555. (map emit-nginx-location-config locations)
  556. "\n"
  557. (map (lambda (x) (list " " x "\n")) raw-content)
  558. " }\n")))
  559. (define (emit-nginx-upstream-config upstream)
  560. (list
  561. " upstream " (nginx-upstream-configuration-name upstream) " {\n"
  562. (map (lambda (server)
  563. (simple-format #f " server ~A;\n" server))
  564. (nginx-upstream-configuration-servers upstream))
  565. " }\n"))
  566. (define (flatten . lst)
  567. "Return a list that recursively concatenates all sub-lists of LST."
  568. (define (flatten1 head out)
  569. (if (list? head)
  570. (fold-right flatten1 out head)
  571. (cons head out)))
  572. (fold-right flatten1 '() lst))
  573. (define (default-nginx-config config)
  574. (match-record config
  575. <nginx-configuration>
  576. (nginx log-directory run-directory
  577. server-blocks upstream-blocks
  578. server-names-hash-bucket-size
  579. server-names-hash-bucket-max-size
  580. modules
  581. global-directives
  582. extra-content)
  583. (apply mixed-text-file "nginx.conf"
  584. (flatten
  585. "user nginx nginx;\n"
  586. "pid " run-directory "/pid;\n"
  587. "error_log " log-directory "/error.log info;\n"
  588. (map emit-global-directive global-directives)
  589. (map emit-load-module modules)
  590. "http {\n"
  591. " client_body_temp_path " run-directory "/client_body_temp;\n"
  592. " proxy_temp_path " run-directory "/proxy_temp;\n"
  593. " fastcgi_temp_path " run-directory "/fastcgi_temp;\n"
  594. " uwsgi_temp_path " run-directory "/uwsgi_temp;\n"
  595. " scgi_temp_path " run-directory "/scgi_temp;\n"
  596. " access_log " log-directory "/access.log;\n"
  597. " include " nginx "/share/nginx/conf/mime.types;\n"
  598. (if server-names-hash-bucket-size
  599. (string-append
  600. " server_names_hash_bucket_size "
  601. (number->string server-names-hash-bucket-size)
  602. ";\n")
  603. "")
  604. (if server-names-hash-bucket-max-size
  605. (string-append
  606. " server_names_hash_bucket_max_size "
  607. (number->string server-names-hash-bucket-max-size)
  608. ";\n")
  609. "")
  610. "\n"
  611. (map emit-nginx-upstream-config upstream-blocks)
  612. (map emit-nginx-server-config server-blocks)
  613. extra-content
  614. "\n}\n"))))
  615. (define %nginx-accounts
  616. (list (user-group (name "nginx") (system? #t))
  617. (user-account
  618. (name "nginx")
  619. (group "nginx")
  620. (system? #t)
  621. (comment "nginx server user")
  622. (home-directory "/var/empty")
  623. (shell (file-append shadow "/sbin/nologin")))))
  624. (define (nginx-activation config)
  625. (match-record config
  626. <nginx-configuration>
  627. (nginx log-directory run-directory file)
  628. #~(begin
  629. (use-modules (guix build utils))
  630. (format #t "creating nginx log directory '~a'~%" #$log-directory)
  631. (mkdir-p #$log-directory)
  632. (format #t "creating nginx run directory '~a'~%" #$run-directory)
  633. (mkdir-p #$run-directory)
  634. (format #t "creating nginx temp directories '~a/{client_body,proxy,fastcgi,uwsgi,scgi}_temp'~%" #$run-directory)
  635. (mkdir-p (string-append #$run-directory "/client_body_temp"))
  636. (mkdir-p (string-append #$run-directory "/proxy_temp"))
  637. (mkdir-p (string-append #$run-directory "/fastcgi_temp"))
  638. (mkdir-p (string-append #$run-directory "/uwsgi_temp"))
  639. (mkdir-p (string-append #$run-directory "/scgi_temp"))
  640. ;; Start-up logs. Once configuration is loaded, nginx switches to
  641. ;; log-directory.
  642. (mkdir-p (string-append #$run-directory "/logs"))
  643. ;; Check configuration file syntax.
  644. (system* (string-append #$nginx "/sbin/nginx")
  645. "-c" #$(or file
  646. (default-nginx-config config))
  647. "-p" #$run-directory
  648. "-t"))))
  649. (define (nginx-shepherd-service config)
  650. (match-record config
  651. <nginx-configuration>
  652. (nginx file run-directory)
  653. (let* ((nginx-binary (file-append nginx "/sbin/nginx"))
  654. (pid-file (in-vicinity run-directory "pid"))
  655. (nginx-action
  656. (lambda args
  657. #~(lambda _
  658. (invoke #$nginx-binary "-c"
  659. #$(or file
  660. (default-nginx-config config))
  661. #$@args)
  662. (match '#$args
  663. (("-s" . _) #f)
  664. (_
  665. ;; When FILE is true, we cannot be sure that PID-FILE will
  666. ;; be created, so assume it won't show up. When FILE is
  667. ;; false, read PID-FILE.
  668. #$(if file
  669. #~#t
  670. #~(read-pid-file #$pid-file))))))))
  671. ;; TODO: Add 'reload' action.
  672. (list (shepherd-service
  673. (provision '(nginx))
  674. (documentation "Run the nginx daemon.")
  675. (requirement '(user-processes loopback))
  676. (modules `((ice-9 match)
  677. ,@%default-modules))
  678. (start (nginx-action "-p" run-directory))
  679. (stop (nginx-action "-s" "stop")))))))
  680. (define nginx-service-type
  681. (service-type (name 'nginx)
  682. (extensions
  683. (list (service-extension shepherd-root-service-type
  684. nginx-shepherd-service)
  685. (service-extension activation-service-type
  686. nginx-activation)
  687. (service-extension account-service-type
  688. (const %nginx-accounts))))
  689. (compose concatenate)
  690. (extend (lambda (config servers)
  691. (nginx-configuration
  692. (inherit config)
  693. (server-blocks
  694. (append (nginx-configuration-server-blocks config)
  695. servers)))))
  696. (default-value (nginx-configuration))
  697. (description "Run the nginx Web server.")))
  698. (define-record-type* <fcgiwrap-configuration> fcgiwrap-configuration
  699. make-fcgiwrap-configuration
  700. fcgiwrap-configuration?
  701. (package fcgiwrap-configuration-package ;<package>
  702. (default fcgiwrap))
  703. (socket fcgiwrap-configuration-socket
  704. (default "tcp:127.0.0.1:9000"))
  705. (user fcgiwrap-configuration-user
  706. (default "fcgiwrap"))
  707. (group fcgiwrap-configuration-group
  708. (default "fcgiwrap")))
  709. (define fcgiwrap-accounts
  710. (match-lambda
  711. (($ <fcgiwrap-configuration> package socket user group)
  712. (filter identity
  713. (list
  714. (and (equal? group "fcgiwrap")
  715. (user-group
  716. (name "fcgiwrap")
  717. (system? #t)))
  718. (and (equal? user "fcgiwrap")
  719. (user-account
  720. (name "fcgiwrap")
  721. (group group)
  722. (system? #t)
  723. (comment "Fcgiwrap Daemon")
  724. (home-directory "/var/empty")
  725. (shell (file-append shadow "/sbin/nologin")))))))))
  726. (define fcgiwrap-shepherd-service
  727. (match-lambda
  728. (($ <fcgiwrap-configuration> package socket user group)
  729. (list (shepherd-service
  730. (provision '(fcgiwrap))
  731. (documentation "Run the fcgiwrap daemon.")
  732. (requirement '(networking))
  733. (start #~(make-forkexec-constructor
  734. '(#$(file-append package "/sbin/fcgiwrap")
  735. "-s" #$socket)
  736. #:user #$user #:group #$group))
  737. (stop #~(make-kill-destructor)))))))
  738. (define fcgiwrap-service-type
  739. (service-type (name 'fcgiwrap)
  740. (extensions
  741. (list (service-extension shepherd-root-service-type
  742. fcgiwrap-shepherd-service)
  743. (service-extension account-service-type
  744. fcgiwrap-accounts)))
  745. (default-value (fcgiwrap-configuration))))
  746. (define-record-type* <php-fpm-configuration> php-fpm-configuration
  747. make-php-fpm-configuration
  748. php-fpm-configuration?
  749. (php php-fpm-configuration-php ;<package>
  750. (default php))
  751. (socket php-fpm-configuration-socket
  752. (default (string-append "/var/run/php"
  753. (version-major (package-version php))
  754. "-fpm.sock")))
  755. (user php-fpm-configuration-user
  756. (default "php-fpm"))
  757. (group php-fpm-configuration-group
  758. (default "php-fpm"))
  759. (socket-user php-fpm-configuration-socket-user
  760. (default "php-fpm"))
  761. (socket-group php-fpm-configuration-socket-group
  762. (default "nginx"))
  763. (pid-file php-fpm-configuration-pid-file
  764. (default (string-append "/var/run/php"
  765. (version-major (package-version php))
  766. "-fpm.pid")))
  767. (log-file php-fpm-configuration-log-file
  768. (default (string-append "/var/log/php"
  769. (version-major (package-version php))
  770. "-fpm.log")))
  771. (process-manager php-fpm-configuration-process-manager
  772. (default (php-fpm-dynamic-process-manager-configuration)))
  773. (display-errors php-fpm-configuration-display-errors
  774. (default #f))
  775. (timezone php-fpm-configuration-timezone
  776. (default #f))
  777. (workers-log-file php-fpm-configuration-workers-log-file
  778. (default (string-append "/var/log/php"
  779. (version-major (package-version php))
  780. "-fpm.www.log")))
  781. (file php-fpm-configuration-file ;#f | file-like
  782. (default #f)))
  783. (define-record-type* <php-fpm-dynamic-process-manager-configuration>
  784. php-fpm-dynamic-process-manager-configuration
  785. make-php-fpm-dynamic-process-manager-configuration
  786. php-fpm-dynamic-process-manager-configuration?
  787. (max-children php-fpm-dynamic-process-manager-configuration-max-children
  788. (default 5))
  789. (start-servers php-fpm-dynamic-process-manager-configuration-start-servers
  790. (default 2))
  791. (min-spare-servers php-fpm-dynamic-process-manager-configuration-min-spare-servers
  792. (default 1))
  793. (max-spare-servers php-fpm-dynamic-process-manager-configuration-max-spare-servers
  794. (default 3)))
  795. (define-record-type* <php-fpm-static-process-manager-configuration>
  796. php-fpm-static-process-manager-configuration
  797. make-php-fpm-static-process-manager-configuration
  798. php-fpm-static-process-manager-configuration?
  799. (max-children php-fpm-static-process-manager-configuration-max-children
  800. (default 5)))
  801. (define-record-type* <php-fpm-on-demand-process-manager-configuration>
  802. php-fpm-on-demand-process-manager-configuration
  803. make-php-fpm-on-demand-process-manager-configuration
  804. php-fpm-on-demand-process-manager-configuration?
  805. (max-children php-fpm-on-demand-process-manager-configuration-max-children
  806. (default 5))
  807. (process-idle-timeout php-fpm-on-demand-process-manager-configuration-process-idle-timeout
  808. (default 10)))
  809. (define php-fpm-accounts
  810. (match-lambda
  811. (($ <php-fpm-configuration> php socket user group socket-user socket-group _ _ _ _ _ _)
  812. (list
  813. (user-group (name "php-fpm") (system? #t))
  814. (user-group
  815. (name group)
  816. (system? #t))
  817. (user-account
  818. (name user)
  819. (group group)
  820. (supplementary-groups '("php-fpm"))
  821. (system? #t)
  822. (comment "php-fpm daemon user")
  823. (home-directory "/var/empty")
  824. (shell (file-append shadow "/sbin/nologin")))))))
  825. (define (default-php-fpm-config socket user group socket-user socket-group
  826. pid-file log-file pm display-errors timezone workers-log-file)
  827. (apply mixed-text-file "php-fpm.conf"
  828. (flatten
  829. "[global]\n"
  830. "pid =" pid-file "\n"
  831. "error_log =" log-file "\n"
  832. "[www]\n"
  833. "user =" user "\n"
  834. "group =" group "\n"
  835. "listen =" socket "\n"
  836. "listen.owner =" socket-user "\n"
  837. "listen.group =" socket-group "\n"
  838. (if timezone
  839. (string-append "php_admin_value[date.timezone] = \"" timezone "\"\n")
  840. "")
  841. (match pm
  842. (($ <php-fpm-dynamic-process-manager-configuration>
  843. pm.max-children
  844. pm.start-servers
  845. pm.min-spare-servers
  846. pm.max-spare-servers)
  847. (list
  848. "pm = dynamic\n"
  849. "pm.max_children =" (number->string pm.max-children) "\n"
  850. "pm.start_servers =" (number->string pm.start-servers) "\n"
  851. "pm.min_spare_servers =" (number->string pm.min-spare-servers) "\n"
  852. "pm.max_spare_servers =" (number->string pm.max-spare-servers) "\n"))
  853. (($ <php-fpm-static-process-manager-configuration>
  854. pm.max-children)
  855. (list
  856. "pm = static\n"
  857. "pm.max_children =" (number->string pm.max-children) "\n"))
  858. (($ <php-fpm-on-demand-process-manager-configuration>
  859. pm.max-children
  860. pm.process-idle-timeout)
  861. (list
  862. "pm = ondemand\n"
  863. "pm.max_children =" (number->string pm.max-children) "\n"
  864. "pm.process_idle_timeout =" (number->string pm.process-idle-timeout) "s\n")))
  865. "php_flag[display_errors] = " (if display-errors "on" "off") "\n"
  866. (if workers-log-file
  867. (list "catch_workers_output = yes\n"
  868. "php_admin_value[error_log] =" workers-log-file "\n"
  869. "php_admin_flag[log_errors] = on\n")
  870. (list "catch_workers_output = no\n")))))
  871. (define php-fpm-shepherd-service
  872. (match-lambda
  873. (($ <php-fpm-configuration> php socket user group socket-user socket-group
  874. pid-file log-file pm display-errors
  875. timezone workers-log-file file)
  876. (list (shepherd-service
  877. (provision '(php-fpm))
  878. (documentation "Run the php-fpm daemon.")
  879. (requirement '(networking))
  880. (start #~(make-forkexec-constructor
  881. '(#$(file-append php "/sbin/php-fpm")
  882. "--fpm-config"
  883. #$(or file
  884. (default-php-fpm-config socket user group
  885. socket-user socket-group pid-file log-file
  886. pm display-errors timezone workers-log-file)))
  887. #:pid-file #$pid-file))
  888. (stop #~(make-kill-destructor)))))))
  889. (define (php-fpm-activation config)
  890. #~(begin
  891. (use-modules (guix build utils))
  892. (let* ((user (getpwnam #$(php-fpm-configuration-user config)))
  893. (touch (lambda (file-name)
  894. (call-with-output-file file-name (const #t))))
  895. (workers-log-file
  896. #$(php-fpm-configuration-workers-log-file config))
  897. (init-log-file
  898. (lambda (file-name)
  899. (when workers-log-file
  900. (when (not (file-exists? file-name))
  901. (touch file-name))
  902. (chown file-name (passwd:uid user) (passwd:gid user))
  903. (chmod file-name #o660)))))
  904. (init-log-file #$(php-fpm-configuration-log-file config))
  905. (init-log-file workers-log-file))))
  906. (define php-fpm-service-type
  907. (service-type
  908. (name 'php-fpm)
  909. (description
  910. "Run @command{php-fpm} to provide a fastcgi socket for calling php through
  911. a webserver.")
  912. (extensions
  913. (list (service-extension shepherd-root-service-type
  914. php-fpm-shepherd-service)
  915. (service-extension activation-service-type
  916. php-fpm-activation)
  917. (service-extension account-service-type
  918. php-fpm-accounts)))
  919. (default-value (php-fpm-configuration))))
  920. (define* (nginx-php-location
  921. #:key
  922. (nginx-package nginx)
  923. (socket (string-append "/var/run/php"
  924. (version-major (package-version php))
  925. "-fpm.sock")))
  926. "Return a nginx-location-configuration that makes nginx run .php files."
  927. (nginx-location-configuration
  928. (uri "~ \\.php$")
  929. (body (list
  930. "fastcgi_split_path_info ^(.+\\.php)(/.+)$;"
  931. (string-append "fastcgi_pass unix:" socket ";")
  932. "fastcgi_index index.php;"
  933. (list "include " nginx-package "/share/nginx/conf/fastcgi.conf;")))))
  934. (define* (cat-avatar-generator-service
  935. #:key
  936. (cache-dir "/var/cache/cat-avatar-generator")
  937. (package cat-avatar-generator)
  938. (configuration (nginx-server-configuration)))
  939. (simple-service
  940. 'cat-http-server nginx-service-type
  941. (list (nginx-server-configuration
  942. (inherit configuration)
  943. (locations
  944. (cons
  945. (let ((base (nginx-php-location)))
  946. (nginx-location-configuration
  947. (inherit base)
  948. (body (list (string-append "fastcgi_param CACHE_DIR \""
  949. cache-dir "\";")
  950. (nginx-location-configuration-body base)))))
  951. (nginx-server-configuration-locations configuration)))
  952. (root #~(string-append #$package
  953. "/share/web/cat-avatar-generator"))))))
  954. (define-record-type* <hpcguix-web-configuration>
  955. hpcguix-web-configuration make-hpcguix-web-configuration
  956. hpcguix-web-configuration?
  957. (package hpcguix-web-package (default hpcguix-web)) ;<package>
  958. ;; Specs is gexp of hpcguix-web configuration file
  959. (specs hpcguix-web-configuration-specs))
  960. (define %hpcguix-web-accounts
  961. (list (user-group
  962. (name "hpcguix-web")
  963. (system? #t))
  964. (user-account
  965. (name "hpcguix-web")
  966. (group "hpcguix-web")
  967. (system? #t)
  968. (comment "hpcguix-web")
  969. (home-directory "/var/empty")
  970. (shell (file-append shadow "/sbin/nologin")))))
  971. (define %hpcguix-web-activation
  972. (with-imported-modules '((guix build utils))
  973. #~(begin
  974. (use-modules (guix build utils)
  975. (ice-9 ftw))
  976. (let ((home-dir "/var/cache/guix/web")
  977. (user (getpwnam "hpcguix-web")))
  978. (mkdir-p home-dir)
  979. (chown home-dir (passwd:uid user) (passwd:gid user))
  980. (chmod home-dir #o755)
  981. ;; Remove stale 'packages.json.lock' file (and other lock files, if
  982. ;; any) since that would prevent 'packages.json' from being updated.
  983. (for-each (lambda (lock)
  984. (delete-file (string-append home-dir "/" lock)))
  985. (scandir home-dir
  986. (lambda (file)
  987. (string-suffix? ".lock" file))))))))
  988. (define %hpcguix-web-log-file
  989. "/var/log/hpcguix-web.log")
  990. (define %hpcguix-web-log-rotations
  991. (list (log-rotation
  992. (files (list %hpcguix-web-log-file))
  993. (frequency 'weekly))))
  994. (define (hpcguix-web-shepherd-service config)
  995. (let ((specs (hpcguix-web-configuration-specs config))
  996. (hpcguix-web (hpcguix-web-package config)))
  997. (with-imported-modules (source-module-closure
  998. '((gnu build shepherd)))
  999. (shepherd-service
  1000. (documentation "hpcguix-web daemon")
  1001. (provision '(hpcguix-web))
  1002. (requirement '(networking))
  1003. (start #~(make-forkexec-constructor
  1004. (list #$(file-append hpcguix-web "/bin/run")
  1005. (string-append "--config="
  1006. #$(scheme-file "hpcguix-web.scm" specs)))
  1007. #:user "hpcguix-web"
  1008. #:group "hpcguix-web"
  1009. #:environment-variables
  1010. (list "XDG_CACHE_HOME=/var/cache"
  1011. "SSL_CERT_DIR=/etc/ssl/certs")
  1012. #:log-file #$%hpcguix-web-log-file))
  1013. (stop #~(make-kill-destructor))))))
  1014. (define hpcguix-web-service-type
  1015. (service-type
  1016. (name 'hpcguix-web)
  1017. (description "Run the hpcguix-web server.")
  1018. (extensions
  1019. (list (service-extension account-service-type
  1020. (const %hpcguix-web-accounts))
  1021. (service-extension activation-service-type
  1022. (const %hpcguix-web-activation))
  1023. (service-extension rottlog-service-type
  1024. (const %hpcguix-web-log-rotations))
  1025. (service-extension shepherd-root-service-type
  1026. (compose list hpcguix-web-shepherd-service))))))
  1027. ;;;
  1028. ;;; Tailon
  1029. ;;;
  1030. (define-record-type* <tailon-configuration-file>
  1031. tailon-configuration-file make-tailon-configuration-file
  1032. tailon-configuration-file?
  1033. (files tailon-configuration-file-files
  1034. (default '("/var/log")))
  1035. (bind tailon-configuration-file-bind
  1036. (default "localhost:8080"))
  1037. (relative-root tailon-configuration-file-relative-root
  1038. (default #f))
  1039. (allow-transfers? tailon-configuration-file-allow-transfers?
  1040. (default #t))
  1041. (follow-names? tailon-configuration-file-follow-names?
  1042. (default #t))
  1043. (tail-lines tailon-configuration-file-tail-lines
  1044. (default 200))
  1045. (allowed-commands tailon-configuration-file-allowed-commands
  1046. (default '("tail" "grep" "awk")))
  1047. (debug? tailon-configuration-file-debug?
  1048. (default #f))
  1049. (wrap-lines tailon-configuration-file-wrap-lines
  1050. (default #t))
  1051. (http-auth tailon-configuration-file-http-auth
  1052. (default #f))
  1053. (users tailon-configuration-file-users
  1054. (default #f)))
  1055. (define (tailon-configuration-files-string files)
  1056. (string-append
  1057. "\n"
  1058. (string-join
  1059. (map
  1060. (lambda (x)
  1061. (string-append
  1062. " - "
  1063. (cond
  1064. ((string? x)
  1065. (simple-format #f "'~A'" x))
  1066. ((list? x)
  1067. (string-join
  1068. (cons (simple-format #f "'~A':" (car x))
  1069. (map
  1070. (lambda (x) (simple-format #f " - '~A'" x))
  1071. (cdr x)))
  1072. "\n"))
  1073. (else (error x)))))
  1074. files)
  1075. "\n")))
  1076. (define-gexp-compiler (tailon-configuration-file-compiler
  1077. (file <tailon-configuration-file>) system target)
  1078. (match file
  1079. (($ <tailon-configuration-file> files bind relative-root
  1080. allow-transfers? follow-names?
  1081. tail-lines allowed-commands debug?
  1082. wrap-lines http-auth users)
  1083. (text-file
  1084. "tailon-config.yaml"
  1085. (string-concatenate
  1086. (filter-map
  1087. (match-lambda
  1088. ((key . #f) #f)
  1089. ((key . value) (string-append key ": " value "\n")))
  1090. `(("files" . ,(tailon-configuration-files-string files))
  1091. ("bind" . ,bind)
  1092. ("relative-root" . ,relative-root)
  1093. ("allow-transfers" . ,(if allow-transfers? "true" "false"))
  1094. ("follow-names" . ,(if follow-names? "true" "false"))
  1095. ("tail-lines" . ,(number->string tail-lines))
  1096. ("commands" . ,(string-append "["
  1097. (string-join allowed-commands ", ")
  1098. "]"))
  1099. ("debug" . ,(if debug? "true" #f))
  1100. ("wrap-lines" . ,(if wrap-lines "true" "false"))
  1101. ("http-auth" . ,http-auth)
  1102. ("users" . ,(if users
  1103. (string-concatenate
  1104. (cons "\n"
  1105. (map (match-lambda
  1106. ((user . pass)
  1107. (string-append
  1108. " " user ":" pass)))
  1109. users)))
  1110. #f)))))))))
  1111. (define-record-type* <tailon-configuration>
  1112. tailon-configuration make-tailon-configuration
  1113. tailon-configuration?
  1114. (config-file tailon-configuration-config-file
  1115. (default (tailon-configuration-file)))
  1116. (package tailon-configuration-package
  1117. (default tailon)))
  1118. (define tailon-shepherd-service
  1119. (match-lambda
  1120. (($ <tailon-configuration> config-file package)
  1121. (list (shepherd-service
  1122. (provision '(tailon))
  1123. (documentation "Run the tailon daemon.")
  1124. (start #~(make-forkexec-constructor
  1125. `(,(string-append #$package "/bin/tailon")
  1126. "-c" ,#$config-file)
  1127. #:user "tailon"
  1128. #:group "tailon"))
  1129. (stop #~(make-kill-destructor)))))))
  1130. (define %tailon-accounts
  1131. (list (user-group (name "tailon") (system? #t))
  1132. (user-account
  1133. (name "tailon")
  1134. (group "tailon")
  1135. (system? #t)
  1136. (comment "tailon")
  1137. (home-directory "/var/empty")
  1138. (shell (file-append shadow "/sbin/nologin")))))
  1139. (define tailon-service-type
  1140. (service-type
  1141. (name 'tailon)
  1142. (description
  1143. "Run Tailon, a Web application for monitoring, viewing, and searching log
  1144. files.")
  1145. (extensions
  1146. (list (service-extension shepherd-root-service-type
  1147. tailon-shepherd-service)
  1148. (service-extension account-service-type
  1149. (const %tailon-accounts))))
  1150. (compose concatenate)
  1151. (extend (lambda (parameter files)
  1152. (tailon-configuration
  1153. (inherit parameter)
  1154. (config-file
  1155. (let ((old-config-file
  1156. (tailon-configuration-config-file parameter)))
  1157. (tailon-configuration-file
  1158. (inherit old-config-file)
  1159. (files (append (tailon-configuration-file-files old-config-file)
  1160. files))))))))
  1161. (default-value (tailon-configuration))))
  1162. ;;;
  1163. ;;; Varnish
  1164. ;;;
  1165. (define-record-type* <varnish-configuration>
  1166. varnish-configuration make-varnish-configuration
  1167. varnish-configuration?
  1168. (package varnish-configuration-package ;<package>
  1169. (default varnish))
  1170. (name varnish-configuration-name ;string
  1171. (default "default"))
  1172. (backend varnish-configuration-backend ;string
  1173. (default "localhost:8080"))
  1174. (vcl varnish-configuration-vcl ;#f | <file-like>
  1175. (default #f))
  1176. (listen varnish-configuration-listen ;list of strings
  1177. (default '("localhost:80")))
  1178. (storage varnish-configuration-storage ;list of strings
  1179. (default '("malloc,128m")))
  1180. (parameters varnish-configuration-parameters ;list of string pairs
  1181. (default '()))
  1182. (extra-options varnish-configuration-extra-options ;list of strings
  1183. (default '())))
  1184. (define %varnish-accounts
  1185. (list (user-group
  1186. (name "varnish")
  1187. (system? #t))
  1188. (user-account
  1189. (name "varnish")
  1190. (group "varnish")
  1191. (system? #t)
  1192. (comment "Varnish Cache User")
  1193. (home-directory "/var/varnish")
  1194. (shell (file-append shadow "/sbin/nologin")))))
  1195. (define varnish-shepherd-service
  1196. (match-lambda
  1197. (($ <varnish-configuration> package name backend vcl listen storage
  1198. parameters extra-options)
  1199. (list (shepherd-service
  1200. (provision (list (symbol-append 'varnish- (string->symbol name))))
  1201. (documentation (string-append "The Varnish Web Accelerator"
  1202. " (" name ")"))
  1203. (requirement '(networking))
  1204. (start #~(make-forkexec-constructor
  1205. (list #$(file-append package "/sbin/varnishd")
  1206. "-n" #$name
  1207. #$@(if vcl
  1208. #~("-f" #$vcl)
  1209. #~("-b" #$backend))
  1210. #$@(append-map (lambda (a) (list "-a" a)) listen)
  1211. #$@(append-map (lambda (s) (list "-s" s)) storage)
  1212. #$@(append-map (lambda (p)
  1213. (list "-p" (format #f "~a=~a"
  1214. (car p) (cdr p))))
  1215. parameters)
  1216. #$@extra-options)
  1217. ;; Varnish will drop privileges to the "varnish" user when
  1218. ;; it exists. Not passing #:user here allows the service
  1219. ;; to bind to ports < 1024.
  1220. #:pid-file (if (string-prefix? "/" #$name)
  1221. (string-append #$name "/_.pid")
  1222. (string-append "/var/varnish/" #$name "/_.pid"))))
  1223. (stop #~(make-kill-destructor)))))))
  1224. (define varnish-service-type
  1225. (service-type
  1226. (name 'varnish)
  1227. (description "Run the Varnish cache server.")
  1228. (extensions
  1229. (list (service-extension account-service-type
  1230. (const %varnish-accounts))
  1231. (service-extension shepherd-root-service-type
  1232. varnish-shepherd-service)))
  1233. (default-value
  1234. (varnish-configuration))))
  1235. ;;;
  1236. ;;; Patchwork
  1237. ;;;
  1238. (define-record-type* <patchwork-database-configuration>
  1239. patchwork-database-configuration make-patchwork-database-configuration
  1240. patchwork-database-configuration?
  1241. (engine patchwork-database-configuration-engine
  1242. (default "django.db.backends.postgresql_psycopg2"))
  1243. (name patchwork-database-configuration-name
  1244. (default "patchwork"))
  1245. (user patchwork-database-configuration-user
  1246. (default "httpd"))
  1247. (password patchwork-database-configuration-password
  1248. (default ""))
  1249. (host patchwork-database-configuration-host
  1250. (default ""))
  1251. (port patchwork-database-configuration-port
  1252. (default "")))
  1253. (define-record-type* <patchwork-settings-module>
  1254. patchwork-settings-module make-patchwork-settings-module
  1255. patchwork-settings-module?
  1256. (database-configuration patchwork-settings-module-database-configuration
  1257. (default (patchwork-database-configuration)))
  1258. (secret-key-file patchwork-settings-module-secret-key-file
  1259. (default "/etc/patchwork/django-secret-key"))
  1260. (allowed-hosts patchwork-settings-module-allowed-hosts)
  1261. (default-from-email patchwork-settings-module-default-from-email)
  1262. (static-url patchwork-settings-module-static-url
  1263. (default "/static/"))
  1264. (admins patchwork-settings-module-admins
  1265. (default '()))
  1266. (debug? patchwork-settings-module-debug?
  1267. (default #f))
  1268. (enable-rest-api? patchwork-settings-module-enable-rest-api?
  1269. (default #t))
  1270. (enable-xmlrpc? patchwork-settings-module-enable-xmlrpc?
  1271. (default #t))
  1272. (force-https-links? patchwork-settings-module-force-https-links?
  1273. (default #t))
  1274. (extra-settings patchwork-settings-module-extra-settings
  1275. (default "")))
  1276. (define-record-type* <patchwork-configuration>
  1277. patchwork-configuration make-patchwork-configuration
  1278. patchwork-configuration?
  1279. (patchwork patchwork-configuration-patchwork
  1280. (default patchwork))
  1281. (domain patchwork-configuration-domain)
  1282. (settings-module patchwork-configuration-settings-module)
  1283. (static-path patchwork-configuration-static-url
  1284. (default "/static/"))
  1285. (getmail-retriever-config getmail-retriever-config))
  1286. ;; Django uses a Python module for configuration, so this compiler generates a
  1287. ;; Python module from the configuration record.
  1288. (define-gexp-compiler (patchwork-settings-module-compiler
  1289. (file <patchwork-settings-module>) system target)
  1290. (match file
  1291. (($ <patchwork-settings-module> database-configuration secret-key-file
  1292. allowed-hosts default-from-email
  1293. static-url admins debug? enable-rest-api?
  1294. enable-xmlrpc? force-https-links?
  1295. extra-configuration)
  1296. (gexp->derivation
  1297. "patchwork-settings"
  1298. (with-imported-modules '((guix build utils))
  1299. #~(let ((output #$output))
  1300. (define (create-__init__.py filename)
  1301. (call-with-output-file filename
  1302. (lambda (port) (display "" port))))
  1303. (use-modules (guix build utils)
  1304. (srfi srfi-1))
  1305. (mkdir-p (string-append output "/guix/patchwork"))
  1306. (create-__init__.py
  1307. (string-append output "/guix/__init__.py"))
  1308. (create-__init__.py
  1309. (string-append output "/guix/patchwork/__init__.py"))
  1310. (call-with-output-file
  1311. (string-append output "/guix/patchwork/settings.py")
  1312. (lambda (port)
  1313. (display
  1314. (string-append "from patchwork.settings.base import *
  1315. # Configuration from Guix
  1316. with open('" #$secret-key-file "') as f:
  1317. SECRET_KEY = f.read().strip()
  1318. ALLOWED_HOSTS = [
  1319. " #$(string-concatenate
  1320. (map (lambda (allowed-host)
  1321. (string-append " '" allowed-host "'\n"))
  1322. allowed-hosts))
  1323. "]
  1324. DEFAULT_FROM_EMAIL = '" #$default-from-email "'
  1325. SERVER_EMAIL = DEFAULT_FROM_EMAIL
  1326. NOTIFICATION_FROM_EMAIL = DEFAULT_FROM_EMAIL
  1327. ADMINS = [
  1328. " #$(string-concatenate
  1329. (map (match-lambda
  1330. ((name email-address)
  1331. (string-append
  1332. "('" name "','" email-address "'),")))
  1333. admins))
  1334. "]
  1335. DEBUG = " #$(if debug? "True" "False") "
  1336. ENABLE_REST_API = " #$(if enable-rest-api? "True" "False") "
  1337. ENABLE_XMLRPC = " #$(if enable-xmlrpc? "True" "False") "
  1338. FORCE_HTTPS_LINKS = " #$(if force-https-links? "True" "False") "
  1339. DATABASES = {
  1340. 'default': {
  1341. " #$(match database-configuration
  1342. (($ <patchwork-database-configuration>
  1343. engine name user password host port)
  1344. (string-append
  1345. " 'ENGINE': '" engine "',\n"
  1346. " 'NAME': '" name "',\n"
  1347. " 'USER': '" user "',\n"
  1348. " 'PASSWORD': '" password "',\n"
  1349. " 'HOST': '" host "',\n"
  1350. " 'PORT': '" port "',\n"))) "
  1351. },
  1352. }
  1353. " #$(if debug?
  1354. #~(string-append "STATIC_ROOT = '"
  1355. #$(file-append patchwork "/share/patchwork/htdocs")
  1356. "'")
  1357. #~(string-append "STATIC_URL = '" #$static-url "'")) "
  1358. STATICFILES_STORAGE = (
  1359. 'django.contrib.staticfiles.storage.StaticFilesStorage'
  1360. )
  1361. # Guix Extra Configuration
  1362. " #$extra-configuration "
  1363. ") port)))
  1364. #t))
  1365. #:local-build? #t))))
  1366. (define patchwork-virtualhost
  1367. (match-lambda
  1368. (($ <patchwork-configuration> patchwork domain
  1369. settings-module static-path
  1370. getmail-retriever-config)
  1371. (define wsgi.py
  1372. (file-append patchwork
  1373. (string-append
  1374. "/lib/python"
  1375. (version-major+minor
  1376. (package-version python))
  1377. "/site-packages/patchwork/wsgi.py")))
  1378. (httpd-virtualhost
  1379. "*:8080"
  1380. `("ServerAdmin admin@example.com`
  1381. ServerName " ,domain "
  1382. LogFormat \"%v %h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\"\" customformat
  1383. LogLevel info
  1384. CustomLog \"/var/log/httpd/" ,domain "-access_log\" customformat
  1385. ErrorLog /var/log/httpd/error.log
  1386. WSGIScriptAlias / " ,wsgi.py "
  1387. WSGIDaemonProcess " ,(package-name patchwork) " user=httpd group=httpd processes=1 threads=2 display-name=%{GROUP} lang='en_US.UTF-8' locale='en_US.UTF-8' python-path=" ,settings-module "
  1388. WSGIProcessGroup " ,(package-name patchwork) "
  1389. WSGIPassAuthorization On
  1390. <Files " ,wsgi.py ">
  1391. Require all granted
  1392. </Files>
  1393. " ,@(if static-path
  1394. `("Alias " ,static-path " " ,patchwork "/share/patchwork/htdocs/")
  1395. '())
  1396. "
  1397. <Directory \"/srv/http/" ,domain "/\">
  1398. AllowOverride None
  1399. Options MultiViews Indexes SymlinksIfOwnerMatch IncludesNoExec
  1400. Require method GET POST OPTIONS
  1401. </Directory>")))))
  1402. (define (patchwork-httpd-configuration patchwork-configuration)
  1403. (list "WSGISocketPrefix /var/run/mod_wsgi"
  1404. (list "LoadModule wsgi_module "
  1405. (file-append mod-wsgi "/modules/mod_wsgi.so"))
  1406. (patchwork-virtualhost patchwork-configuration)))
  1407. (define (patchwork-django-admin-gexp patchwork settings-module)
  1408. #~(lambda command
  1409. (let ((pid (primitive-fork))
  1410. (user (getpwnam "httpd")))
  1411. (if (eq? pid 0)
  1412. (dynamic-wind
  1413. (const #t)
  1414. (lambda ()
  1415. (setgid (passwd:gid user))
  1416. (setuid (passwd:uid user))
  1417. (setenv "DJANGO_SETTINGS_MODULE" "guix.patchwork.settings")
  1418. (setenv "PYTHONPATH" #$settings-module)
  1419. (primitive-exit
  1420. (if (zero?
  1421. (apply system*
  1422. #$(file-append patchwork "/bin/patchwork-admin")
  1423. command))
  1424. 0
  1425. 1)))
  1426. (lambda ()
  1427. (primitive-exit 1)))
  1428. (zero? (cdr (waitpid pid)))))))
  1429. (define (patchwork-django-admin-action patchwork settings-module)
  1430. (shepherd-action
  1431. (name 'django-admin)
  1432. (documentation
  1433. "Run a django admin command for patchwork")
  1434. (procedure (patchwork-django-admin-gexp patchwork settings-module))))
  1435. (define patchwork-shepherd-services
  1436. (match-lambda
  1437. (($ <patchwork-configuration> patchwork domain
  1438. settings-module static-path
  1439. getmail-retriever-config)
  1440. (define secret-key-file-creation-gexp
  1441. (if (patchwork-settings-module? settings-module)
  1442. (with-extensions (list guile-gcrypt)
  1443. #~(let ((secret-key-file
  1444. #$(patchwork-settings-module-secret-key-file
  1445. settings-module)))
  1446. (use-modules (guix build utils)
  1447. (gcrypt random))
  1448. (unless (file-exists? secret-key-file)
  1449. (mkdir-p (dirname secret-key-file))
  1450. (call-with-output-file secret-key-file
  1451. (lambda (port)
  1452. (display (random-token 30 'very-strong) port)))
  1453. (let* ((pw (getpwnam "httpd"))
  1454. (uid (passwd:uid pw))
  1455. (gid (passwd:gid pw)))
  1456. (chown secret-key-file uid gid)
  1457. (chmod secret-key-file #o400)))))
  1458. #~()))
  1459. (list (shepherd-service
  1460. (requirement '(postgres))
  1461. (provision (list (string->symbol
  1462. (string-append (package-name patchwork)
  1463. "-setup"))))
  1464. (start
  1465. #~(lambda ()
  1466. (define run-django-admin-command
  1467. #$(patchwork-django-admin-gexp patchwork
  1468. settings-module))
  1469. #$secret-key-file-creation-gexp
  1470. (run-django-admin-command "migrate")))
  1471. (stop #~(const #f))
  1472. (actions
  1473. (list (patchwork-django-admin-action patchwork
  1474. settings-module)))
  1475. (respawn? #f)
  1476. (documentation "Setup Patchwork."))))))
  1477. (define patchwork-getmail-configs
  1478. (match-lambda
  1479. (($ <patchwork-configuration> patchwork domain
  1480. settings-module static-path
  1481. getmail-retriever-config)
  1482. (list
  1483. (getmail-configuration
  1484. (name (string->symbol (package-name patchwork)))
  1485. (user "httpd")
  1486. (directory (string-append
  1487. "/var/lib/getmail/" (package-name patchwork)))
  1488. (rcfile
  1489. (getmail-configuration-file
  1490. (retriever getmail-retriever-config)
  1491. (destination
  1492. (getmail-destination-configuration
  1493. (type "MDA_external")
  1494. (path (file-append patchwork "/bin/patchwork-admin"))
  1495. (extra-parameters
  1496. '((arguments . ("parsemail"))))))
  1497. (options
  1498. (getmail-options-configuration
  1499. (read-all #f)
  1500. (delivered-to #f)
  1501. (received #f)))))
  1502. (idle (assq-ref
  1503. (getmail-retriever-configuration-extra-parameters
  1504. getmail-retriever-config)
  1505. 'mailboxes))
  1506. (environment-variables
  1507. (list "DJANGO_SETTINGS_MODULE=guix.patchwork.settings"
  1508. #~(string-append "PYTHONPATH=" #$settings-module))))))))
  1509. (define patchwork-service-type
  1510. (service-type
  1511. (name 'patchwork-setup)
  1512. (extensions
  1513. (list (service-extension httpd-service-type
  1514. patchwork-httpd-configuration)
  1515. (service-extension shepherd-root-service-type
  1516. patchwork-shepherd-services)
  1517. (service-extension getmail-service-type
  1518. patchwork-getmail-configs)))
  1519. (description
  1520. "Patchwork patch tracking system.")))
  1521. ;;;
  1522. ;;; Mumi.
  1523. ;;;
  1524. (define %mumi-activation
  1525. (with-imported-modules '((guix build utils))
  1526. #~(begin
  1527. (use-modules (guix build utils))
  1528. (mkdir-p "/var/mumi/db")
  1529. (mkdir-p "/var/mumi/mails")
  1530. (let* ((pw (getpwnam "mumi"))
  1531. (uid (passwd:uid pw))
  1532. (gid (passwd:gid pw)))
  1533. (chown "/var/mumi" uid gid)
  1534. (chown "/var/mumi/mails" uid gid)
  1535. (chown "/var/mumi/db" uid gid)))))
  1536. (define %mumi-accounts
  1537. (list (user-group (name "mumi") (system? #t))
  1538. (user-account
  1539. (name "mumi")
  1540. (group "mumi")
  1541. (system? #t)
  1542. (comment "Mumi web server")
  1543. (home-directory "/var/empty")
  1544. (shell (file-append shadow "/sbin/nologin")))))
  1545. (define (mumi-shepherd-services mumi)
  1546. (list (shepherd-service
  1547. (provision '(mumi))
  1548. (documentation "Mumi bug-tracking web interface.")
  1549. (requirement '(networking))
  1550. (start #~(make-forkexec-constructor
  1551. '(#$(file-append mumi "/bin/mumi"))
  1552. #:user "mumi" #:group "mumi"
  1553. #:log-file "/var/log/mumi.log"))
  1554. (stop #~(make-kill-destructor)))
  1555. (shepherd-service
  1556. (provision '(mumi-worker))
  1557. (documentation "Mumi bug-tracking web interface.")
  1558. (requirement '(networking))
  1559. (start #~(make-forkexec-constructor
  1560. '(#$(file-append mumi "/bin/mumi") "--worker")
  1561. #:user "mumi" #:group "mumi"
  1562. #:log-file "/var/log/mumi.worker.log"))
  1563. (stop #~(make-kill-destructor)))))
  1564. (define mumi-service-type
  1565. (service-type
  1566. (name 'mumi)
  1567. (extensions
  1568. (list (service-extension activation-service-type
  1569. (const %mumi-activation))
  1570. (service-extension account-service-type
  1571. (const %mumi-accounts))
  1572. (service-extension shepherd-root-service-type
  1573. mumi-shepherd-services)))
  1574. (description
  1575. "Run Mumi, a Web interface to the Debbugs bug-tracking server.")
  1576. (default-value mumi)))