From e797e94bf5298ed03a6677055d87bb6a9662d0d1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 3 Oct 2017 14:48:09 +0200 Subject: doc: Explain why synopses/descriptions must be literal strings. Suggested by Dave Love . * doc/guix.texi (Synopses and Descriptions): Recommend literal strings. --- doc/guix.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index c57c0bab63..9e301d0072 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19147,6 +19147,18 @@ Translation Project} so that as many users as possible can read them in their native language. User interfaces search them and display them in the language specified by the current locale. +To allow @command{xgettext} to extract them as translatable strings, +synopses and descriptions @emph{must be literal strings}. This means +that you cannot use @code{string-append} or @code{format} to construct +these strings: + +@lisp +(package + ;; @dots{} + (synopsis "This is translatable") + (description (string-append "This is " "*not*" " translatable."))) +@end lisp + Translation is a lot of work so, as a packager, please pay even more attention to your synopses and descriptions as every change may entail additional work for translators. In order to help them, it is possible -- cgit v1.2.3 From 032a2760eef6dc64fa36f2fb3a211b755d5124bb Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Tue, 3 Oct 2017 10:36:35 +0300 Subject: gnu: services: Add cgit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/version-control.scm (, ): New record types. (cgit-configuration-robots-string, cgit-activation, cgit-configuration-nginx-config): New procedures. (%cgit-configuration-nginx, cgit-service-type): New variables. * gnu/tests/version-control.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Version Control): Document the cgit service. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 65 +++++++++++++++ gnu/local.mk | 1 + gnu/services/version-control.scm | 119 +++++++++++++++++++++++++- gnu/tests/version-control.scm | 176 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 gnu/tests/version-control.scm (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 9e301d0072..b9d127c47c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17000,6 +17000,71 @@ Extra options will be passed to @code{git daemon}, please run @end table @end deftp +@subsubheading Cgit Service + +@cindex Cgit service +@cindex Git, web interface +@uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git +repositories written in C. + +The following example will configure the service with default values. +By default, Cgit can be accessed on port 80 (@code{http://localhost:80}). + +@example +(service nginx-service-type) +(service fcgiwrap-service-type) +(service cgit-service-type) +@end example + +@deftp {Data Type} cgit-configuration +Data type representing the configuration of Cgit. +This type has the following parameters: + +@table @asis +@item @code{config-file} (default: @code{(cgit-configuration-file)}) +The configuration file to use for Cgit. This can be set to a +@dfn{cgit-configuration-file} record value, or any gexp +(@pxref{G-Expressions}). + +For example, to instead use a local file, the @code{local-file} function +can be used: + +@example +(service cgit-service-type + (cgit-configuration + (config-file (local-file "./my-cgitrc.conf")))) +@end example + +@item @code{package} (default: @code{cgit}) +The Cgit package to use. + +@end table +@end deftp + +@deftp {Data Type} cgit-configuration-file +Data type representing the configuration options for Cgit. +This type has the following parameters: + +@table @asis +@item @code{css} (default: @code{"/share/cgit/cgit.css"}) +URL which specifies the css document to include in all Cgit pages. + +@item @code{logo} (default: @code{"/share/cgit/cgit.png"}) +URL which specifies the source of an image which will be used as a logo +on all Cgit pages. + +@item @code{virtual-root} (default: @code{"/"}) +URL which, if specified, will be used as root for all Cgit links. + +@item @code{repository-directory} (default: @code{"/srv/git"}) +Name of the directory to scan for repositories. + +@item @code{robots} (default: @code{(list "noindex" "nofollow")}) +Text used as content for the ``robots'' meta-tag. + +@end table +@end deftp + @node Setuid Programs @subsection Setuid Programs diff --git a/gnu/local.mk b/gnu/local.mk index edd6d8237e..cceada5ae6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -501,6 +501,7 @@ GNU_SYSTEM_MODULES = \ %D%/tests/networking.scm \ %D%/tests/rsync.scm \ %D%/tests/ssh.scm \ + %D%/tests/version-control.scm \ %D%/tests/virtualization.scm \ %D%/tests/web.scm diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm index 107bc8e77a..e39f4411fd 100644 --- a/gnu/services/version-control.scm +++ b/gnu/services/version-control.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 ng0 ;;; Copyright © 2016 Sou Bunnbu +;;; Copyright © 2017 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,18 +22,40 @@ #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services shepherd) + #:use-module (gnu services web) #:use-module (gnu system shadow) #:use-module (gnu packages version-control) #:use-module (gnu packages admin) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (guix store) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (git-daemon-service git-daemon-service-type git-daemon-configuration - git-daemon-configuration?)) + git-daemon-configuration? + + + cgit-configuration-file + cgit-configuration-file? + cgit-configuration-file-css + cgit-configuration-file-logo + cgit-configuration-file-robots + cgit-configuration-file-virtual-root + cgit-configuration-file-repository-directory + + + cgit-configuration + cgit-configuration? + cgit-configuration-config-file + cgit-configuration-package + + %cgit-configuration-nginx + cgit-configuration-nginx-config + + cgit-service-type)) ;;; Commentary: ;;; @@ -139,3 +162,97 @@ The optional @var{config} argument should be a @code{} object, by default it allows read-only access to exported repositories under @file{/srv/git}." (service git-daemon-service-type config)) + + +;;; +;;; Cgit +;;; + +(define-record-type* + cgit-configuration-file + make-cgit-configuration-file + cgit-configuration-file? + (css cgit-configuration-file-css ; string + (default "/share/cgit/cgit.css")) + (logo cgit-configuration-file-logo ; string + (default "/share/cgit/cgit.png")) + (robots cgit-configuration-file-robots ; list + (default '("noindex" "nofollow"))) + (virtual-root cgit-configuration-file-virtual-root ; string + (default "/")) + (repository-directory cgit-configuration-file-repository-directory ; string + (default "/srv/git"))) + +(define (cgit-configuration-robots-string robots) + (string-join robots ", ")) + +(define-gexp-compiler (cgit-configuration-file-compiler + (file ) system target) + (match file + (($ css logo + robots virtual-root repository-directory) + (apply text-file* "cgitrc" + (letrec-syntax ((option (syntax-rules () + ((_ key value) + (if value + `(,key "=" ,value "\n") + '())))) + (key/value (syntax-rules () + ((_ (key value) rest ...) + (append (option key value) + (key/value rest ...))) + ((_) + '())))) + (key/value ("css" css) + ("logo" logo) + ("robots" (cgit-configuration-robots-string robots)) + ("virtual-root" virtual-root) + ("scan-path" repository-directory))))))) + +(define %cgit-configuration-nginx + (list + (nginx-server-configuration + (root cgit) + (locations + (list + (nginx-location-configuration + (uri "@cgit") + (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cgit.cgi;" + "fastcgi_param PATH_INFO $uri;" + "fastcgi_param QUERY_STRING $args;" + "fastcgi_param HTTP_HOST $server_name;" + "fastcgi_pass 127.0.0.1:9000;"))))) + (try-files (list "$uri" "@cgit")) + (https-port #f) + (ssl-certificate #f) + (ssl-certificate-key #f)))) + +(define-record-type* + cgit-configuration make-cgit-configuration + cgit-configuration? + (config-file cgit-configuration-config-file + (default (cgit-configuration-file))) + (package cgit-configuration-package + (default cgit)) + (nginx cgit-configuration-nginx + (default %cgit-configuration-nginx))) + +(define (cgit-activation config) + ;; Cgit compiled with default configuration path + #~(begin + (use-modules (guix build utils)) + (mkdir-p "/var/cache/cgit") + (copy-file #$(cgit-configuration-config-file config) "/etc/cgitrc"))) + +(define (cgit-configuration-nginx-config config) + (cgit-configuration-nginx config)) + +(define cgit-service-type + (service-type + (name 'cgit) + (extensions + (list (service-extension activation-service-type + cgit-activation) + (service-extension nginx-service-type + cgit-configuration-nginx-config))) + (default-value (cgit-configuration)))) diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm new file mode 100644 index 0000000000..5a3937cfed --- /dev/null +++ b/gnu/tests/version-control.scm @@ -0,0 +1,176 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Oleg Pykhalov +;;; Copyright © 2017 Ludovic Courtès +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu tests version-control) + #:use-module (gnu tests) + #:use-module (gnu system) + #:use-module (gnu system file-systems) + #:use-module (gnu system shadow) + #:use-module (gnu system vm) + #:use-module (gnu services) + #:use-module (gnu services version-control) + #:use-module (gnu services web) + #:use-module (gnu services networking) + #:use-module (gnu packages version-control) + #:use-module (guix gexp) + #:use-module (guix store) + #:export (%test-cgit)) + +(define %make-git-repository + ;; Create Git repository in /srv/git/test. + #~(begin + (mkdir-p "/srv/git/test") + (system* (string-append #$git "/bin/git") "-C" "/srv/git/test" + "init" "--bare"))) + +(define %cgit-configuration-nginx + (list + (nginx-server-configuration + (root cgit) + (locations + (list + (nginx-location-configuration + (uri "@cgit") + (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cgit.cgi;" + "fastcgi_param PATH_INFO $uri;" + "fastcgi_param QUERY_STRING $args;" + "fastcgi_param HTTP_HOST $server_name;" + "fastcgi_pass 127.0.0.1:9000;"))))) + (try-files (list "$uri" "@cgit")) + (http-port 19418) + (https-port #f) + (ssl-certificate #f) + (ssl-certificate-key #f)))) + +(define %cgit-os + ;; Operating system under test. + (let ((base-os + (simple-operating-system + (dhcp-client-service) + (service nginx-service-type) + (service fcgiwrap-service-type) + (service cgit-service-type + (cgit-configuration + (nginx %cgit-configuration-nginx))) + (simple-service 'make-git-repository activation-service-type + %make-git-repository)))) + (operating-system + (inherit base-os) + (packages (cons* git + (operating-system-packages base-os)))))) + +(define* (run-cgit-test #:optional (http-port 19418)) + "Run tests in %CGIT-OS, which has nginx running and listening on +HTTP-PORT." + (define os + (marionette-operating-system + %cgit-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (port-forwardings `((8080 . ,http-port))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (gnu build marionette) + (web uri) + (web client) + (web response)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "cgit") + + ;; Wait for nginx to be up and running. + (test-eq "service running" + 'running! + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'nginx) + 'running!) + marionette)) + + ;; Wait for fcgiwrap to be up and running. + (test-eq "service running" + 'running! + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'fcgiwrap) + 'running!) + marionette)) + + ;; Make sure the PID file is created. + (test-assert "PID file" + (marionette-eval + '(file-exists? "/var/run/nginx/pid") + marionette)) + + ;; Make sure the configuration file is created. + (test-assert "configuration file" + (marionette-eval + '(file-exists? "/etc/cgitrc") + marionette)) + + ;; Make sure Git test repository is created. + (test-assert "Git test repository" + (marionette-eval + '(file-exists? "/srv/git/test") + marionette)) + + ;; Make sure we can access pages that correspond to our repository. + (letrec-syntax ((test-url + (syntax-rules () + ((_ path code) + (test-equal (string-append "GET " path) + code + (let-values (((response body) + (http-get (string-append + "http://localhost:8080" + path)))) + (response-code response)))) + ((_ path) + (test-url path 200))))) + (test-url "/") + (test-url "/test") + (test-url "/test/log") + (test-url "/test/tree") + (test-url "/test/does-not-exist" 404) + (test-url "/does-not-exist" 404)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "cgit-test" test)) + +(define %test-cgit + (system-test + (name "cgit") + (description "Connect to a running Cgit server.") + (value (run-cgit-test)))) -- cgit v1.2.3 From 8df1faa047870c51954275664e8e7efc94e6fc56 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 5 Sep 2017 19:04:38 +0200 Subject: guix: ant-build-system: Add main-class support. * guix/build-system/ant.scm: New #:main-class argument * guix/build/ant-build-system.scm: Generate a manifest file with additional properties. * doc/guix.texi (Build Systems): Document it. --- doc/guix.texi | 4 ++++ guix/build-system/ant.scm | 2 ++ guix/build/ant-build-system.scm | 27 ++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 5 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index b9d127c47c..312f5e7822 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3479,6 +3479,10 @@ build file @file{build.xml} with tasks to build the specified jar archive. In this case the parameter @code{#:source-dir} can be used to specify the source sub-directory, defaulting to ``src''. +The @code{#:main-class} parameter can be used with the minimal ant +buildfile to specify the main class of the resulting jar. This makes the +jar file executable. + The parameter @code{#:build-target} can be used to specify the Ant task that should be run during the @code{build} phase. By default the ``jar'' task will be run. diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index e0870a605c..a700230ece 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -99,6 +99,7 @@ (make-flags ''()) (build-target "jar") (jar-name #f) + (main-class #f) (source-dir "src") (test-dir "src/test") (phases '(@ (guix build ant-build-system) @@ -130,6 +131,7 @@ #:test-target ,test-target #:build-target ,build-target #:jar-name ,jar-name + #:main-class ,main-class #:source-dir ,source-dir #:test-dir ,test-dir #:phases ,phases diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index 4042630a10..727d3a3b25 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -36,7 +36,7 @@ ;; Code: (define* (default-build.xml jar-name prefix #:optional - (source-dir ".") (test-dir "./test")) + (source-dir ".") (test-dir "./test") (main-class #f)) "Create a simple build.xml with standard targets for Ant." (call-with-output-file "build.xml" (lambda (port) @@ -44,6 +44,10 @@ `(project (@ (basedir ".")) (property (@ (name "classes.dir") (value "${basedir}/build/classes"))) + (property (@ (name "manifest.dir") + (value "${basedir}/build/manifest"))) + (property (@ (name "manifest.file") + (value "${manifest.dir}/MANIFEST.MF"))) (property (@ (name "jar.dir") (value "${basedir}/build/jar"))) (property (@ (name "dist.dir") @@ -60,6 +64,17 @@ (path (@ (id "classpath")) (pathelement (@ (location "${env.CLASSPATH}")))) + (target (@ (name "manifest")) + (mkdir (@ (dir "${manifest.dir}"))) + (echo (@ (file "${manifest.file}") + (message ,(string-append + (if main-class + (string-append + "Main-Class: " main-class + "${line.separator}") + "") + ""))))) + (target (@ (name "compile")) (mkdir (@ (dir "${classes.dir}"))) (javac (@ (includeantruntime "false") @@ -97,10 +112,11 @@ (include (@ (name "**/*Test.java" ))))))) (target (@ (name "jar") - (depends "compile")) + (depends "compile, manifest")) (mkdir (@ (dir "${jar.dir}"))) (exec (@ (executable "jar")) - (arg (@ (line ,(string-append "-cf ${jar.dir}/" jar-name + (arg (@ (line ,(string-append "-cmf ${manifest.file} " + "${jar.dir}/" jar-name " -C ${classes.dir} .")))))) (target (@ (name "install")) @@ -133,12 +149,13 @@ to the default GNU unpack strategy." (define* (configure #:key inputs outputs (jar-name #f) (source-dir "src") - (test-dir "src/test") #:allow-other-keys) + (test-dir "src/test") + (main-class #f) #:allow-other-keys) (when jar-name (default-build.xml jar-name (string-append (assoc-ref outputs "out") "/share/java") - source-dir test-dir)) + source-dir test-dir main-class)) (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "CLASSPATH" (generate-classpath inputs))) -- cgit v1.2.3 From f403d7abdf28d2d6e4446a2989e0d37d023b6b53 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 5 Sep 2017 22:14:11 +0200 Subject: guix: ant-build-system: Add #:test-include and #:test-exclude arguments. * guix/build-system/ant.scm: Add #:test-include and #:test-exclude arguments. * guix/build/ant-build-system.scm: Generate test list from arguments. * doc/guix.texi (Build Systems): Document it. --- doc/guix.texi | 6 +++++- guix/build-system/ant.scm | 4 ++++ guix/build/ant-build-system.scm | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 312f5e7822..f0a59a6b4b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3481,7 +3481,11 @@ specify the source sub-directory, defaulting to ``src''. The @code{#:main-class} parameter can be used with the minimal ant buildfile to specify the main class of the resulting jar. This makes the -jar file executable. +jar file executable. The @code{#:test-include} parameter can be used to +specify the list of junit tests to run. It defaults to +@code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to +disable some tests. It defaults to @code{(list "**/Abstract*.java")}, +because abstract classes cannot be run as tests. The parameter @code{#:build-target} can be used to specify the Ant task that should be run during the @code{build} phase. By default the diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index a700230ece..b5626bd42d 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -100,6 +100,8 @@ (build-target "jar") (jar-name #f) (main-class #f) + (test-include (list "**/*Test.java")) + (test-exclude (list "**/Abstract*.java")) (source-dir "src") (test-dir "src/test") (phases '(@ (guix build ant-build-system) @@ -132,6 +134,8 @@ #:build-target ,build-target #:jar-name ,jar-name #:main-class ,main-class + #:test-include (list ,@test-include) + #:test-exclude (list ,@test-exclude) #:source-dir ,source-dir #:test-dir ,test-dir #:phases ,phases diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index 727d3a3b25..a440daf054 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -36,7 +36,9 @@ ;; Code: (define* (default-build.xml jar-name prefix #:optional - (source-dir ".") (test-dir "./test") (main-class #f)) + (source-dir ".") (test-dir "./test") (main-class #f) + (test-include '("**/*Test.java")) + (test-exclude '("**/Abstract*Test.java"))) "Create a simple build.xml with standard targets for Ant." (call-with-output-file "build.xml" (lambda (port) @@ -109,7 +111,12 @@ (batchtest (@ (fork "yes") (todir "${test.home}/test-reports")) (fileset (@ (dir "${test.home}/java")) - (include (@ (name "**/*Test.java" ))))))) + ,@(map (lambda (file) + `(include (@ (name ,file)))) + test-include) + ,@(map (lambda (file) + `(exclude (@ (name ,file)))) + test-exclude))))) (target (@ (name "jar") (depends "compile, manifest")) @@ -150,12 +157,14 @@ to the default GNU unpack strategy." (define* (configure #:key inputs outputs (jar-name #f) (source-dir "src") (test-dir "src/test") - (main-class #f) #:allow-other-keys) + (main-class #f) + (test-include '("**/*Test.java")) + (test-exclude '("**/Abstract*.java")) #:allow-other-keys) (when jar-name (default-build.xml jar-name (string-append (assoc-ref outputs "out") "/share/java") - source-dir test-dir main-class)) + source-dir test-dir main-class test-include test-exclude)) (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "CLASSPATH" (generate-classpath inputs))) -- cgit v1.2.3 From 5266ff719e274056cb3e2b9740183f0063177255 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 6 Oct 2017 21:24:30 +0100 Subject: services: Add MongoDB. * gnu/services/databases.scm (%default-mongodb-configuration-file, %mongodb-accounts, mongodb-service-type): New variables. (): New record type. (mongodb-activation, mongodb-shepherd-service): New procedures. * gnu/tests/databases.scm (%test-mongodb): New variable. * doc/guix.texi (Database Services): Add MongoDB documentation. --- doc/guix.texi | 26 ++++++++++++++ gnu/services/databases.scm | 89 ++++++++++++++++++++++++++++++++++++++++++++++ gnu/tests/databases.scm | 86 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 200 insertions(+), 1 deletion(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index f0a59a6b4b..c10fc649d1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12120,6 +12120,32 @@ Additional command line options to pass to @code{memcached}. @end table @end deftp +@defvr {Scheme Variable} mongodb-service-type +This is the service type for @uref{https://www.mongodb.com/, MongoDB}. +The value for the service type is a @code{mongodb-configuration} object. +@end defvr + +@example +(service mongodb-service-type) +@end example + +@deftp {Data Type} mongodb-configuration +Data type representing the configuration of mongodb. + +@table @asis +@item @code{mongodb} (default: @code{mongodb}) +The MongoDB package to use. + +@item @code{config-file} (default: @code{%default-mongodb-configuration-file}) +The configuration file for MongoDB. + +@item @code{data-directory} (default: @code{"/var/lib/mongodb"}) +This value is used to create the directory, so that it exists and is +owned by the mongodb user. It should match the data-directory which +MongoDB is configured to use through the configuration file. +@end table +@end deftp + @defvr {Scheme Variable} redis-service-type This is the service type for the @uref{https://redis.io/, Redis} key/value store, whose value is a @code{redis-configuration} object. diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index de1f6b8411..6a01cb1ce6 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -44,6 +44,14 @@ memcached-configuration-udp-port memcached-configuration-additional-options + + 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 @@ -262,6 +270,87 @@ and stores the database cluster in @var{data-directory}." (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 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 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 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. diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index 9d9a753747..9e335b27c6 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -25,9 +25,11 @@ #:use-module (gnu services) #:use-module (gnu services databases) #:use-module (gnu services networking) + #:use-module (gnu packages databases) #:use-module (guix gexp) #:use-module (guix store) - #:export (%test-memcached)) + #:export (%test-memcached + %test-mongodb)) (define %memcached-os (simple-operating-system @@ -121,3 +123,85 @@ (name "memcached") (description "Connect to a running MEMCACHED server.") (value (run-memcached-test)))) + +(define %mongodb-os + (operating-system + (inherit + (simple-operating-system + (dhcp-client-service) + (service mongodb-service-type))) + (packages (cons* mongodb + %base-packages)))) + +(define* (run-mongodb-test #:optional (port 27017)) + "Run tests in %MONGODB-OS, forwarding PORT." + (define os + (marionette-operating-system + %mongodb-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (memory-size 1024) + (disk-image-size (* 1024 (expt 2 20))) + (port-forwardings `((27017 . ,port))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (gnu build marionette) + (ice-9 popen) + (ice-9 rdelim)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "mongodb") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (match (start-service 'mongodb) + (#f #f) + (('service response-parts ...) + (match (assq-ref response-parts 'running) + ((pid) (number? pid)))))) + marionette)) + + (test-eq "test insert" + 0 + (system* (string-append #$mongodb "/bin/mongo") + "test" + "--eval" + "db.testCollection.insert({data: 'test-data'})")) + + (test-equal "test find" + "test-data" + (let* ((port (open-pipe* + OPEN_READ + (string-append #$mongodb "/bin/mongo") + "test" + "--quiet" + "--eval" + "db.testCollection.findOne().data")) + (output (read-line port)) + (status (close-pipe port))) + output)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "mongodb-test" test)) + +(define %test-mongodb + (system-test + (name "mongodb") + (description "Connect to a running MONGODB server.") + (value (run-mongodb-test)))) -- cgit v1.2.3 From cca6941feed56b6bcd767c2619b99cd619e91f0c Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Wed, 4 Oct 2017 12:01:41 +0300 Subject: pull: Add GUIX_PULL_URL environment variable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/pull.scm (%repository-url): Add GUIX_PULL_URL environment variable. * doc/guix.texi (Invoking guix pull): Mention GUIX_PULL_URL. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 4 +++- guix/scripts/pull.scm | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index c10fc649d1..7b5b711793 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2532,8 +2532,10 @@ Produce verbose output, writing build logs to the standard error output. @item --url=@var{url} Download Guix from the Git repository at @var{url}. +@vindex GUIX_PULL_URL By default, the source is taken from its canonical Git repository at -@code{gnu.org}, for the stable branch of Guix. +@code{gnu.org}, for the stable branch of Guix. To use a different source, +set the @code{GUIX_PULL_URL} environment variable. @item --commit=@var{commit} Deploy @var{commit}, a valid Git commit ID represented as a hexadecimal diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index b1c87c870e..2400198000 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -82,7 +82,7 @@ Install it by running: (resolve-interface '(git)))) (define %repository-url - "https://git.savannah.gnu.org/git/guix.git") + (or (getenv "GUIX_PULL_URL") "https://git.savannah.gnu.org/git/guix.git")) ;;; -- cgit v1.2.3