aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-06-12gnu: sqlite: Update to 3.24.0.Tobias Geerinckx-Rice
* gnu/packages/databases.scm (sqlite): Update to 3.24.0.
2018-06-12gnu: perl: Ungraft version 5.26.2.Tobias Geerinckx-Rice
* gnu/packages/perl.scm (perl): Update to 5.26.2. [replacement]: Ungraft. (perl-5.26.2, perl/fixed): Remove variables.
2018-06-12gnu: cmake: Update to 3.11.3.Tobias Geerinckx-Rice
* gnu/packages/cmake.scm (cmake): Update to 3.11.3.
2018-06-12gnu: linux-pam: Update to 1.3.1.Tobias Geerinckx-Rice
* gnu/packages/linux.scm (linux-pam): Update to 1.3.1. [source]: Update upstream URI.
2018-06-12gnu: nghttp2: Update to 1.32.0.Tobias Geerinckx-Rice
* gnu/packages/web.scm (nghttp2): Update to 1.32.0.
2018-06-12gnu: jansson: Update to 2.11.Tobias Geerinckx-Rice
* gnu/packages/web.scm (jansson): Update to 2.11.
2018-06-12gnu: libidn: Update to 1.35.Tobias Geerinckx-Rice
* gnu/packages/libidn.scm (libidn): Update to 1.35. [source]: Remove now-unnecessary snippet.
2018-06-12gnu: wayland-protocols: Update to 1.14.Tobias Geerinckx-Rice
* gnu/packages/freedesktop.scm (wayland-protocols): Update to 1.14.
2018-06-12gnu: libunistring: Update to 0.9.10.Tobias Geerinckx-Rice
* gnu/packages/libunistring.scm (libunistring): Update to 0.9.10. [source]: Remove now-unnecessary snippet.
2018-06-12gnu: libdrm: Update to 2.4.92.Tobias Geerinckx-Rice
* gnu/packages/xdisorg.scm (libdrm): Update to 2.4.92.
2018-06-12gnu: freetype: Update to 2.9.1.Tobias Geerinckx-Rice
* gnu/packages/fontutils.scm (freetype): Update to 2.9.1. [source]: Remove patch... * gnu/packages/patches/freetype-CVE-2018-6942.patch: ...delete... * gnu/local.mk (dist_patch_DATA): ...and remove it.
2018-06-12gnu: bison: Update to 3.0.5.Tobias Geerinckx-Rice
* gnu/packages/bison.scm (bison): Update to 3.0.5.
2018-06-12gnu: isl: Update to 0.19.Tobias Geerinckx-Rice
* gnu/packages/gcc.scm (isl): Update to 0.19.
2018-06-12gnu: mit-krb5: Update to 1.16.1.Tobias Geerinckx-Rice
* gnu/packages/kerberos.scm (mit-krb5): Update to 1.16.1.
2018-06-12gnu: cups, cups-minimal: Update to 2.2.8.Tobias Geerinckx-Rice
* gnu/packages/cups.scm (cups-minimal): Update to 2.2.8. [source]: Remove patch... * gnu/packages/patches/cups-fix-builds-without-PAM.patch: ...delete... * gnu/local.mk (dist_patch_DATA): ..and remove it.
2018-06-12gnu: shared-mime-info: Update to 1.9.Tobias Geerinckx-Rice
* gnu/packages/gnome.scm (shared-mime-info): Update to 1.9.
2018-06-12gnu: fribidi: Update to 1.0.4.Tobias Geerinckx-Rice
* gnu/packages/fribidi.scm (fribidi): Update to 1.0.4.
2018-06-06build-system/r: Fix type error.Ricardo Wurmus
Reported-by: Mark H Weaver <mhw@netris.org> * guix/build/r-build-system.scm (pipe-to-r): Pass a list to the condition's "arguments" field.
2018-06-06Merge branch 'origin/core-updates-next' into core-updatesRicardo Wurmus
2018-06-06Merge branch 'master' into core-updatesRicardo Wurmus
2018-06-06gnu: colobot: Update to 0.1.11.1-alpha.Nicolas Goaziou
* gnu/packages/games.scm (colobot): Update to 0.1.11.1-alpha. [native-inputs]: Update "colobot-data" and "colobot-music" to 0.1.11.1-alpha.
2018-06-06gnu: scribus: Add "libzmf" dependencyNicolas Goaziou
* gnu/packages/scribus.scm (scribus)[inputs]: Add "libzmf".
2018-06-06gnu: scribus: Update to 1.5.4.Nicolas Goaziou
* gnu/packages/scribus.scm (scribus): Update to 1.5.4. [source]: Remove patches. [arguments]: Remove `patch-source' phase.
2018-06-06gnu: vulkan-loader: Update URL and change name.Rutger Helling
* gnu/packages/emulators.scm: Change references from 'vulkan-icd-loader' to 'vulkan-loader'. * gnu/packages/games.scm: Change references from 'vulkan-icd-loader' to 'vulkan-loader'. * gnu/packages/video.scm: Change references from 'vulkan-icd-loader' to 'vulkan-loader'. * gnu/packages/vulkan.scm (vulkan-loader): Rename from 'vulkan-icd-loader' to 'vulkan-loader'. Update URL and hash. * gnu/packages/wine.scm: Change references from 'vulkan-icd-loader' to 'vulkan-loader'.
2018-06-06gnu: you-get: Update to 0.4.1077.Rutger Helling
* gnu/packages/video.scm (you-get): Update to 0.4.1077.
2018-06-06gnu: diffoscope: Update to 95.Rutger Helling
* gnu/packages/package-management.scm (diffoscope): Update to 95.
2018-06-06gnu: epiphany: Update to 3.28.2.1.Rutger Helling
* gnu/packages/gnome.scm (epiphany): Update to 3.28.2.1.
2018-06-06gnu: gnome-disk-utility: Update to 3.28.3.Rutger Helling
* gnu/packages/gnome.scm (gnome-disk-utility): Update to 3.28.3.
2018-06-06gnu: gnome-terminal: Update to 3.28.2.Rutger Helling
* gnu/packages/gnome.scm (gnome-terminal): Update to 3.28.2.
2018-06-06gnu: gedit: Update to 3.28.1.Rutger Helling
* gnu/packages/gnome.scm (gedit): Update to 3.28.1.
2018-06-06tests: Adjust 'guix package' test to "python2" name.Ludovic Courtès
This is a followup to a7714d42de2c3082f3609d1e63c83d703fb39cf9, which renamed Python 2.x to "python2". * tests/guix-package.sh: Use g-wrap and guile@2.0 when testing collisions.
2018-06-06tests: Adjust graph test.Ludovic Courtès
This is a followup to 301a4249064227bc4883e4e5b638e85a65925ba0, which added a dependency to sed. * tests/graph.scm ("node-edges"): Use 'hello', not 'sed', as the example of a package without any dependency.
2018-06-06gnu: vigra: Disable broken test.Ricardo Wurmus
* gnu/packages/image.scm (vigra)[arguments]: Add phase "disable-broken-test"; enable parallel build.
2018-06-06gnu: lynx: Update to 2.8.9dev.19.Rutger Helling
* gnu/packages/web-browsers.scm (lynx): Update to 2.8.9dev.19.
2018-06-06gnu: esmtp: Replace 'bootstrap phase.Efraim Flashner
* gnu/packages/mail.scm (esmtp)[arguments]: Use custom 'autoconf phase to replace default 'bootstrap phase.
2018-06-06gnu: can-utils: Remove 'bootstrap phase.Efraim Flashner
* gnu/packages/networking.scm (can-utils)[arguments]: Remove unnecessary 'bootstrap phase.
2018-06-06gnu: gerbv: Update to 2.6.2.Tobias Geerinckx-Rice
* gnu/packages/engineering.scm (gerbv): Update to 2.6.2. [arguments]: Remove ‘autoconf’ phase... [native-inputs]: ...and remove its dependencies.
2018-06-06gnu: linsmith: Update to 0.99.31.Tobias Geerinckx-Rice
* gnu/packages/engineering.scm (linsmith): Update to 0.99.31.
2018-06-06gnu: linsmith: Use HTTPS home page.Tobias Geerinckx-Rice
* gnu/packages/engineering.scm (linsmith)[home-page]: Use HTTPS.
2018-06-06gnu: python-lmdb: Update to 0.94.Tobias Geerinckx-Rice
* gnu/packages/databases.scm (python-lmdb): Update to 0.94.
2018-06-06gnu: debootstrap: Update to 1.0.101.Tobias Geerinckx-Rice
* gnu/packages/debian.scm (debootstrap): Update to 1.0.101.
2018-06-06gnu: tomb: Update to 2.5.Tobias Geerinckx-Rice
* gnu/packages/crypto.scm (tomb): Update to 2.5. [inputs, arguments]: Add util-linux for ‘findmnt’.
2018-06-06gnu: cfitsio: Update to 3.450.Tobias Geerinckx-Rice
* gnu/packages/astronomy.scm (cfitsio): Update to 3.450.
2018-06-06gnu: gnuastro: Update to 0.6.Tobias Geerinckx-Rice
* gnu/packages/astronomy.scm (gnuastro): Update to 0.6.
2018-06-06gnu: wcslib: Fix build.Tobias Geerinckx-Rice
* gnu/packages/astronomy.scm (wcslib)[arguments]: Skip the default ‘install-license-files’ phase. Don't build or test in parallel.
2018-06-06gnu: inxi: Update to 3.0.11-1.Tobias Geerinckx-Rice
* gnu/packages/admin.scm (inxi): Update to 3.0.11-1.
2018-06-06gnu: inxi: Use GIT-FETCH.Tobias Geerinckx-Rice
* gnu/packages/admin.scm (inxi)[source]: Use GIT-FETCH. [native-inputs]: Remove tar. [arguments]: Adjust accordingly.
2018-06-06gnu: inxi: Fix man page location.Tobias Geerinckx-Rice
* gnu/packages/admin.scm (inxi)[arguments]: Install man page to /share/man instead of /share/doc/man.
2018-06-06gnu: ruby-asciidoctor: Use HTTPS home page.Tobias Geerinckx-Rice
* gnu/packages/ruby.scm (ruby-asciidoctor)[home-page]: Use HTTPS.
2018-06-06gnu: ruby-asciidoctor: Update to 1.5.7.1.Tobias Geerinckx-Rice
* gnu/packages/ruby.scm (ruby-asciidoctor): Update to 1.5.7.1.
TNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu services databases) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages databases) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (<postgresql-config-file> postgresql-config-file postgresql-config-file? postgresql-config-file-log-destination postgresql-config-file-hba-file postgresql-config-file-ident-file postgresql-config-file-extra-config <postgresql-configuration> postgresql-configuration postgresql-configuration? postgresql-configuration-postgresql postgresql-configuration-port postgresql-configuration-locale postgresql-configuration-file postgresql-configuration-data-directory postgresql-service postgresql-service-type memcached-service-type <memcached-configuration> memcached-configuration memcached-configuration? memcached-configuration-memecached memcached-configuration-interfaces memcached-configuration-tcp-port memcached-configuration-udp-port memcached-configuration-additional-options <mongodb-configuration> mongodb-configuration mongodb-configuration? mongodb-configuration-mongodb mongodb-configuration-config-file mongodb-configuration-data-directory mongodb-service-type mysql-service mysql-service-type mysql-configuration mysql-configuration? redis-configuration redis-configuration? redis-service-type)) ;;; Commentary: ;;; ;;; Database services. ;;; ;;; Code: (define %default-postgres-hba (plain-file "pg_hba.conf" " local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust")) (define %default-postgres-ident (plain-file "pg_ident.conf" "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) (define-record-type* <postgresql-config-file> postgresql-config-file make-postgresql-config-file postgresql-config-file? (log-destination postgresql-config-file-log-destination (default "syslog")) (hba-file postgresql-config-file-hba-file (default %default-postgres-hba)) (ident-file postgresql-config-file-ident-file (default %default-postgres-ident)) (extra-config postgresql-config-file-extra-config (default '()))) (define-gexp-compiler (postgresql-config-file-compiler (file <postgresql-config-file>) system target) (match file (($ <postgresql-config-file> log-destination hba-file ident-file extra-config) (define (single-quote string) (if string (list "'" string "'") '())) (define contents (append-map (match-lambda ((key) '()) ((key . #f) '()) ((key values ...) `(,key " = " ,@values "\n"))) `(("log_destination" ,@(single-quote log-destination)) ("hba_file" ,@(single-quote hba-file)) ("ident_file" ,@(single-quote ident-file)) ,@extra-config))) (gexp->derivation "postgresql.conf" #~(call-with-output-file (ungexp output "out") (lambda (port) (display (string-append #$@contents) port))) #:local-build? #t)))) (define-record-type* <postgresql-configuration> postgresql-configuration make-postgresql-configuration postgresql-configuration? (postgresql postgresql-configuration-postgresql ;<package> (default postgresql)) (port postgresql-configuration-port (default 5432)) (locale postgresql-configuration-locale (default "en_US.utf8")) (config-file postgresql-configuration-file (default (postgresql-config-file))) (data-directory postgresql-configuration-data-directory (default "/var/lib/postgresql/data"))) (define %postgresql-accounts (list (user-group (name "postgres") (system? #t)) (user-account (name "postgres") (group "postgres") (system? #t) (comment "PostgreSQL server user") (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define postgresql-activation (match-lambda (($ <postgresql-configuration> postgresql port locale config-file data-directory) #~(begin (use-modules (guix build utils) (ice-9 match)) (let ((user (getpwnam "postgres")) (initdb (string-append #$postgresql "/bin/initdb")) (initdb-args (append (if #$locale (list (string-append "--locale=" #$locale)) '())))) ;; Create db state directory. (mkdir-p #$data-directory) (chown #$data-directory (passwd:uid user) (passwd:gid user)) ;; Drop privileges and init state directory in a new ;; process. Wait for it to finish before proceeding. (match (primitive-fork) (0 ;; Exit with a non-zero status code if an exception is thrown. (dynamic-wind (const #t) (lambda () (setgid (passwd:gid user)) (setuid (passwd:uid user)) (primitive-exit (apply system* initdb "-D" #$data-directory initdb-args))) (lambda () (primitive-exit 1)))) (pid (waitpid pid)))))))) (define postgresql-shepherd-service (match-lambda (($ <postgresql-configuration> postgresql port locale config-file data-directory) (let* ((pg_ctl-wrapper ;; Wrapper script that switches to the 'postgres' user before ;; launching daemon. (program-file "pg_ctl-wrapper" #~(begin (use-modules (ice-9 match) (ice-9 format)) (match (command-line) ((_ mode) (let ((user (getpwnam "postgres")) (pg_ctl #$(file-append postgresql "/bin/pg_ctl")) (options (format #f "--config-file=~a -p ~d" #$config-file #$port))) (setgid (passwd:gid user)) (setuid (passwd:uid user)) (execl pg_ctl pg_ctl "-D" #$data-directory "-o" options mode))))))) (action (lambda args #~(lambda _ (invoke #$pg_ctl-wrapper #$@args))))) (list (shepherd-service (provision '(postgres)) (documentation "Run the PostgreSQL daemon.") (requirement '(user-processes loopback syslogd)) (start (action "start")) (stop (action "stop")))))))) (define postgresql-service-type (service-type (name 'postgresql) (extensions (list (service-extension shepherd-root-service-type postgresql-shepherd-service) (service-extension activation-service-type postgresql-activation) (service-extension account-service-type (const %postgresql-accounts)))) (default-value (postgresql-configuration)))) (define* (postgresql-service #:key (postgresql postgresql) (port 5432) (locale "en_US.utf8") (config-file (postgresql-config-file)) (data-directory "/var/lib/postgresql/data")) "Return a service that runs @var{postgresql}, the PostgreSQL database server. The PostgreSQL daemon loads its runtime configuration from @var{config-file} and stores the database cluster in @var{data-directory}." (service postgresql-service-type (postgresql-configuration (postgresql postgresql) (port port) (locale locale) (config-file config-file) (data-directory data-directory)))) ;;; ;;; Memcached ;;; (define-record-type* <memcached-configuration> memcached-configuration make-memcached-configuration memcached-configuration? (memcached memcached-configuration-memcached ;<package> (default memcached)) (interfaces memcached-configuration-interfaces (default '("0.0.0.0"))) (tcp-port memcached-configuration-tcp-port (default 11211)) (udp-port memcached-configuration-udp-port (default 11211)) (additional-options memcached-configuration-additional-options (default '()))) (define %memcached-accounts (list (user-group (name "memcached") (system? #t)) (user-account (name "memcached") (group "memcached") (system? #t) (comment "Memcached server user") (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define memcached-activation #~(begin (use-modules (guix build utils)) (let ((user (getpwnam "memcached"))) (mkdir-p "/var/run/memcached") (chown "/var/run/memcached" (passwd:uid user) (passwd:gid user))))) (define memcached-shepherd-service (match-lambda (($ <memcached-configuration> memcached interfaces tcp-port udp-port additional-options) (with-imported-modules (source-module-closure '((gnu build shepherd))) (list (shepherd-service (provision '(memcached)) (documentation "Run the Memcached daemon.") (requirement '(user-processes loopback)) (modules '((gnu build shepherd))) (start #~(make-forkexec-constructor `(#$(file-append memcached "/bin/memcached") "-l" #$(string-join interfaces ",") "-p" #$(number->string tcp-port) "-U" #$(number->string udp-port) "--daemon" ;; Memcached changes to the memcached user prior to ;; writing the pid file, so write it to a directory ;; that memcached owns. "-P" "/var/run/memcached/pid" "-u" "memcached" ,#$@additional-options) #:log-file "/var/log/memcached" #:pid-file "/var/run/memcached/pid")) (stop #~(make-kill-destructor)))))))) (define memcached-service-type (service-type (name 'memcached) (extensions (list (service-extension shepherd-root-service-type memcached-shepherd-service) (service-extension activation-service-type (const memcached-activation)) (service-extension account-service-type (const %memcached-accounts)))) (default-value (memcached-configuration)))) ;;; ;;; MongoDB ;;; (define %default-mongodb-configuration-file (plain-file "mongodb.yaml" "# GNU Guix: MongoDB default configuration file processManagement: pidFilePath: /var/run/mongodb/pid storage: dbPath: /var/lib/mongodb ")) (define-record-type* <mongodb-configuration> mongodb-configuration make-mongodb-configuration mongodb-configuration? (mongodb mongodb-configuration-mongodb (default mongodb)) (config-file mongodb-configuration-config-file (default %default-mongodb-configuration-file)) (data-directory mongodb-configuration-data-directory (default "/var/lib/mongodb"))) (define %mongodb-accounts (list (user-group (name "mongodb") (system? #t)) (user-account (name "mongodb") (group "mongodb") (system? #t) (comment "Mongodb server user") (home-directory "/var/lib/mongodb") (shell (file-append shadow "/sbin/nologin"))))) (define mongodb-activation (match-lambda (($ <mongodb-configuration> mongodb config-file data-directory) #~(begin (use-modules (guix build utils)) (let ((user (getpwnam "mongodb"))) (for-each (lambda (directory) (mkdir-p directory) (chown directory (passwd:uid user) (passwd:gid user))) '("/var/run/mongodb" #$data-directory))))))) (define mongodb-shepherd-service (match-lambda (($ <mongodb-configuration> mongodb config-file data-directory) (shepherd-service (provision '(mongodb)) (documentation "Run the Mongodb daemon.") (requirement '(user-processes loopback)) (start #~(make-forkexec-constructor `(,(string-append #$mongodb "/bin/mongod") "--config" ,#$config-file) #:user "mongodb" #:group "mongodb" #:pid-file "/var/run/mongodb/pid" #:log-file "/var/log/mongodb.log")) (stop #~(make-kill-destructor)))))) (define mongodb-service-type (service-type (name 'mongodb) (description "Run the MongoDB document database server.") (extensions (list (service-extension shepherd-root-service-type (compose list mongodb-shepherd-service)) (service-extension activation-service-type mongodb-activation) (service-extension account-service-type (const %mongodb-accounts)))) (default-value (mongodb-configuration)))) ;;; ;;; MySQL. ;;; (define-record-type* <mysql-configuration> mysql-configuration make-mysql-configuration mysql-configuration? (mysql mysql-configuration-mysql (default mariadb)) (port mysql-configuration-port (default 3306))) (define %mysql-accounts (list (user-group (name "mysql") (system? #t)) (user-account (name "mysql") (group "mysql") (system? #t) (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define mysql-configuration-file (match-lambda (($ <mysql-configuration> mysql port) (mixed-text-file "my.cnf" "[mysqld] datadir=/var/lib/mysql socket=/run/mysqld/mysqld.sock port=" (number->string port) " ")))) (define (%mysql-activation config) "Return an activation gexp for the MySQL or MariaDB database server." (let ((mysql (mysql-configuration-mysql config)) (my.cnf (mysql-configuration-file config))) #~(begin (use-modules (ice-9 popen) (guix build utils)) (let* ((mysqld (string-append #$mysql "/bin/mysqld")) (user (getpwnam "mysql")) (uid (passwd:uid user)) (gid (passwd:gid user)) (datadir "/var/lib/mysql") (rundir "/run/mysqld")) (mkdir-p datadir) (chown datadir uid gid) (mkdir-p rundir) (chown rundir uid gid) ;; Initialize the database when it doesn't exist. (when (not (file-exists? (string-append datadir "/mysql"))) (if (string-prefix? "mysql-" (strip-store-file-name #$mysql)) ;; For MySQL. (system* mysqld (string-append "--defaults-file=" #$my.cnf) "--initialize" "--user=mysql") ;; For MariaDB. ;; XXX: The 'mysql_install_db' script doesn't work directly ;; due to missing 'mkdir' in PATH. (let ((p (open-pipe* OPEN_WRITE mysqld (string-append "--defaults-file=" #$my.cnf) "--bootstrap" "--user=mysql"))) ;; Create the system database, as does by 'mysql_install_db'. (display "create database mysql;\n" p) (display "use mysql;\n" p) (for-each (lambda (sql) (call-with-input-file (string-append #$mysql "/share/mysql/" sql) (lambda (in) (dump-port in p)))) '("mysql_system_tables.sql" "mysql_performance_tables.sql" "mysql_system_tables_data.sql" "fill_help_tables.sql")) ;; Remove the anonymous user and disable root access from ;; remote machines, as does by 'mysql_secure_installation'. (display " DELETE FROM user WHERE User=''; DELETE FROM user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); FLUSH PRIVILEGES; " p) (close-pipe p)))))))) (define (mysql-shepherd-service config) (list (shepherd-service (provision '(mysql)) (documentation "Run the MySQL server.") (start (let ((mysql (mysql-configuration-mysql config)) (my.cnf (mysql-configuration-file config))) #~(make-forkexec-constructor (list (string-append #$mysql "/bin/mysqld") (string-append "--defaults-file=" #$my.cnf)) #:user "mysql" #:group "mysql"))) (stop #~(make-kill-destructor))))) (define mysql-service-type (service-type (name 'mysql) (extensions (list (service-extension account-service-type (const %mysql-accounts)) (service-extension activation-service-type %mysql-activation) (service-extension shepherd-root-service-type mysql-shepherd-service))) (default-value (mysql-configuration)))) (define* (mysql-service #:key (config (mysql-configuration))) "Return a service that runs @command{mysqld}, the MySQL or MariaDB database server. The optional @var{config} argument specifies the configuration for @command{mysqld}, which should be a @code{<mysql-configuration>} object." (service mysql-service-type config)) ;;; ;;; Redis ;;; (define-record-type* <redis-configuration> redis-configuration make-redis-configuration redis-configuration? (redis redis-configuration-redis ;<package> (default redis)) (bind redis-configuration-bind (default "127.0.0.1")) (port redis-configuration-port (default 6379)) (working-directory redis-configuration-working-directory (default "/var/lib/redis")) (config-file redis-configuration-config-file (default #f))) (define (default-redis.conf bind port working-directory) (mixed-text-file "redis.conf" "bind " bind "\n" "port " (number->string port) "\n" "dir " working-directory "\n" "daemonize no\n")) (define %redis-accounts (list (user-group (name "redis") (system? #t)) (user-account (name "redis") (group "redis") (system? #t) (comment "Redis server user") (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define redis-activation (match-lambda (($ <redis-configuration> redis bind port working-directory config-file) #~(begin (use-modules (guix build utils) (ice-9 match)) (let ((user (getpwnam "redis"))) (mkdir-p #$working-directory) (chown #$working-directory (passwd:uid user) (passwd:gid user))))))) (define redis-shepherd-service (match-lambda (($ <redis-configuration> redis bind port working-directory config-file) (let ((config-file (or config-file (default-redis.conf bind port working-directory)))) (list (shepherd-service (provision '(redis)) (documentation "Run the Redis daemon.") (requirement '(user-processes syslogd)) (start #~(make-forkexec-constructor '(#$(file-append redis "/bin/redis-server") #$config-file) #:user "redis" #:group "redis")) (stop #~(make-kill-destructor)))))))) (define redis-service-type (service-type (name 'redis) (extensions (list (service-extension shepherd-root-service-type redis-shepherd-service) (service-extension activation-service-type redis-activation) (service-extension account-service-type (const %redis-accounts)))) (default-value (redis-configuration))))