From 6b1c4179e2596d860b1c49dea8021bc39d28da67 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 29 Nov 2018 20:22:41 +0300 Subject: services: monitoring: Add 'zabbix-server'. * gnu/services/monitoring.scm (uglify-field-name, serialize-field, serialize-number, serialize-list, serialize-string, group?, serialize-group, include-files?, serialize-include-files, zabbix-server-account, zabbix-server-config-file, zabbix-server-activation, zabbix-server-shepherd-service, generate-zabbix-server-documentation, extra-options, serialize-extra-options): New procedures. (zabbix-server-service-type): New variable. * gnu/tests/monitoring.scm (%psql-user-create-zabbix, %psql-db-zabbix-create-script, %psql-db-create-zabbix, %psql-db-import-zabbix, %zabbix-os, %test-zabbix): New variables. (run-zabbix-server-test): New procedure. * doc/guix.texi (Monitoring Services): Document 'zabbix-server'. squash! services: monitoring: Add 'zabbix-server'. --- doc/guix.texi | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 20b5013fd9..005ff83080 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16662,6 +16662,147 @@ Bind the web interface to the specified address. @end table @end deftp +@subsubheading Zabbix server +@cindex zabbix zabbix-server +Zabbix provides monitoring metrics, among others network utilization, CPU load +and disk space consumption: + +@itemize +@item High performance, high capacity (able to monitor hundreds of thousands of devices). +@item Auto-discovery of servers and network devices and interfaces. +@item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others. +@item Distributed monitoring with centralized web administration. +@item Native high performance agents. +@item SLA, and ITIL KPI metrics on reporting. +@item High-level (business) view of monitored resources through user-defined visual console screens and dashboards. +@item Remote command execution through Zabbix proxies. +@end itemize + +@c %start of fragment + +Available @code{zabbix-server-configuration} fields are: + +@deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server +The zabbix-server package. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string user +User who will run the Zabbix server. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} group group +Group who will run the Zabbix server. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-host +Database host name. + +Defaults to @samp{"127.0.0.1"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-name +Database name. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-user +Database user. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-password +Database password. Please, use @code{include-files} with +@code{DBPassword=SECRET} inside a specified file instead. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} number db-port +Database port. + +Defaults to @samp{5432}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string log-type +Specifies where log messages are written to: + +@itemize @bullet +@item +@code{system} - syslog. + +@item +@code{file} - file specified with @code{log-file} parameter. + +@item +@code{console} - standard output. + +@end itemize + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string log-file +Log file name for @code{log-type} @code{file} parameter. + +Defaults to @samp{"/var/log/zabbix/server.log"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string pid-file +Name of PID file. + +Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location +The location of certificate authority (CA) files for SSL server +certificate verification. + +Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location +Location of SSL client certificates. + +Defaults to @samp{"/etc/ssl/certs"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string extra-options +Extra options will be appended to Zabbix server configuration file. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files +You may include individual files or all files in a directory in the +configuration file. + +Defaults to @samp{()}. + +@end deftypevr + + +@c %end of fragment + @node Kerberos Services @subsubsection Kerberos Services @cindex Kerberos -- cgit v1.2.3 From 6106d7cae49fb6686a237b53d465c89211ecad8f Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 29 Nov 2018 20:30:49 +0300 Subject: services: monitoring: Add 'zabbix-agent'. * gnu/services/monitoring.scm (zabbix-server-service-type, zabbix-agent-account, zabbix-agent-activation, zabbix-agent-config-file, zabbix-agent-shepherd-service, generate-zabbix-agent-documentation): New procedures. (zabbix-agent-service-type): New 'service-type'. * gnu/tests/monitoring.scm (run-zabbix-server-test): Test 'zabbix-agent'. (%zabbix-os): Add 'zabbix-agent' service. * doc/guix.texi (Monitoring Services): Document 'zabbix-agent'. --- doc/guix.texi | 103 ++++++++++++++++++++++++++++++++++ gnu/services/monitoring.scm | 133 +++++++++++++++++++++++++++++++++++++++++++- gnu/tests/monitoring.scm | 18 +++++- 3 files changed, 252 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 005ff83080..02778588ca 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16800,6 +16800,109 @@ Defaults to @samp{()}. @end deftypevr +@c %end of fragment + +@subsubheading Zabbix agent +@cindex zabbix zabbix-agent + +Zabbix agent gathers information for Zabbix server. + +@c %start of fragment + +Available @code{zabbix-agent-configuration} fields are: + +@deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent +The zabbix-agent package. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string user +User who will run the Zabbix agent. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} group group +Group who will run the Zabbix agent. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string hostname +Unique, case sensitive hostname which is required for active checks and +must match hostname as configured on the server. + +Defaults to @samp{"Zabbix server"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string log-type +Specifies where log messages are written to: + +@itemize @bullet +@item +@code{system} - syslog. + +@item +@code{file} - file specified with @code{log-file} parameter. + +@item +@code{console} - standard output. + +@end itemize + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string log-file +Log file name for @code{log-type} @code{file} parameter. + +Defaults to @samp{"/var/log/zabbix/agent.log"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file +Name of PID file. + +Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} list server +List of IP addresses, optionally in CIDR notation, or hostnames of +Zabbix servers and Zabbix proxies. Incoming connections will be +accepted only from the hosts listed here. + +Defaults to @samp{("127.0.0.1")}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} list server-active +List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix +proxies for active checks. If port is not specified, default port is +used. If this parameter is not specified, active checks are disabled. + +Defaults to @samp{("127.0.0.1")}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options +Extra options will be appended to Zabbix server configuration file. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files +You may include individual files or all files in a directory in the +configuration file. + +Defaults to @samp{()}. + +@end deftypevr @c %end of fragment diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index cb1f71ebff..323c0ace56 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -36,7 +36,9 @@ prometheus-node-exporter-service-type zabbix-server-configuration - zabbix-server-service-type)) + zabbix-server-service-type + zabbix-agent-configuration + zabbix-agent-service-type)) ;;; @@ -314,3 +316,132 @@ configuration file.")) `((zabbix-server-configuration ,zabbix-server-configuration-fields)) 'zabbix-server-configuration)) + +(define-configuration zabbix-agent-configuration + (zabbix-agent + (package zabbix-agentd) + "The zabbix-agent package.") + (user + (string "zabbix") + "User who will run the Zabbix agent.") + (group + (group "zabbix") + "Group who will run the Zabbix agent.") + (hostname + (string "Zabbix server") + "Unique, case sensitive hostname which is required for active checks and +must match hostname as configured on the server.") + (log-type + (string "") + "Specifies where log messages are written to: +@itemize +@item @code{system} - syslog. +@item @code{file} - file specified with @code{log-file} parameter. +@item @code{console} - standard output. +@end itemize\n") + (log-file + (string "/var/log/zabbix/agent.log") + "Log file name for @code{log-type} @code{file} parameter.") + (pid-file + (string "/var/run/zabbix/zabbix_agent.pid") + "Name of PID file.") + (server + (list '("127.0.0.1")) + "List of IP addresses, optionally in CIDR notation, or hostnames of Zabbix +servers and Zabbix proxies. Incoming connections will be accepted only from +the hosts listed here.") + (server-active + (list '("127.0.0.1")) + "List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix +proxies for active checks. If port is not specified, default port is used. +If this parameter is not specified, active checks are disabled.") + (extra-options + (string "") + "Extra options will be appended to Zabbix server configuration file.") + (include-files + (include-files '()) + "You may include individual files or all files in a directory in the +configuration file.")) + +(define (zabbix-agent-account config) + "Return the user accounts and user groups for CONFIG." + (let ((zabbix-user "zabbix") + (zabbix-group "zabbix")) + (list (user-group (name zabbix-group) (system? #t)) + (user-account + (name zabbix-user) + (system? #t) + (group zabbix-group) + (comment "zabbix privilege separation user") + (home-directory (string-append "/var/run/" zabbix-user)) + (shell #~(string-append #$shadow "/sbin/nologin")))))) + +(define (zabbix-agent-activation config) + "Return the activation gexp for CONFIG." + (with-imported-modules '((guix build utils) + (ice-9 rdelim)) + #~(begin + (use-modules (guix build utils) + (ice-9 rdelim)) + (let ((user + (getpw #$(zabbix-agent-configuration-user config)))) + (for-each (lambda (file) + (let ((directory (dirname file))) + (mkdir-p directory) + (chown directory (passwd:uid user) (passwd:gid user)) + (chmod directory #o755))) + (list #$(zabbix-agent-configuration-log-file config) + #$(zabbix-agent-configuration-pid-file config))))))) + +(define (zabbix-agent-config-file config) + "Return the zabbix-agent configuration file corresponding to CONFIG." + (computed-file + "zabbix_agent.conf" + #~(begin + (call-with-output-file #$output + (lambda (port) + (display "# Generated by 'zabbix-agent-service'.\n" port) + (display #$(with-output-to-string + (lambda () + (serialize-configuration + config zabbix-agent-configuration-fields))) + port) + #t))))) + +(define (zabbix-agent-shepherd-service config) + "Return a for Zabbix agent with CONFIG." + (list (shepherd-service + (provision '(zabbix-agent)) + (documentation "Run Zabbix agent daemon.") + (start #~(make-forkexec-constructor + (list #$(file-append (zabbix-agent-configuration-zabbix-agent config) + "/sbin/zabbix_agentd") + "--config" #$(zabbix-agent-config-file config) + "--foreground") + #:user #$(zabbix-agent-configuration-user config) + #:group #$(zabbix-agent-configuration-group config) + #:pid-file #$(zabbix-agent-configuration-pid-file config) + #:environment-variables + (list "SSL_CERT_DIR=/run/current-system/profile\ +/etc/ssl/certs" + "SSL_CERT_FILE=/run/current-system/profile\ +/etc/ssl/certs/ca-certificates.crt"))) + (stop #~(make-kill-destructor))))) + +(define zabbix-agent-service-type + (service-type + (name 'zabbix-agent) + (extensions + (list (service-extension shepherd-root-service-type + zabbix-agent-shepherd-service) + (service-extension account-service-type + zabbix-agent-account) + (service-extension activation-service-type + zabbix-agent-activation))) + (default-value (zabbix-agent-configuration)))) + +(define (generate-zabbix-agent-documentation) + (generate-documentation + `((zabbix-agent-configuration + ,zabbix-agent-configuration-fields)) + 'zabbix-agent-configuration)) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index edc41c4a30..76a2d3e946 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -235,6 +235,20 @@ zabbix||{} '(file-exists? "/var/run/zabbix/zabbix_server.pid") marionette)) + ;; Wait for zabbix-agent to be up and running. + (test-assert "zabbix-agent running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'zabbix-agent)) + marionette)) + + ;; Make sure the PID file is created. + (test-assert "zabbix-agent PID file" + (marionette-eval + '(file-exists? "/var/run/zabbix/zabbix_agent.pid") + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) @@ -250,7 +264,9 @@ zabbix||{} (service zabbix-server-service-type (zabbix-server-configuration (db-password "zabbix") - (log-type "console")))))) + (log-type "console"))) + + (service zabbix-agent-service-type)))) (operating-system (inherit base-os) (packages (cons* postgresql (operating-system-packages base-os)))))) -- cgit v1.2.3 From e517161d6b0ee544dab94477c9ffbad59cc1834b Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 29 Nov 2018 20:37:55 +0300 Subject: services: php-fpm: Add 'timezone' configuration. * gnu/services/web.scm: ()[timezone]: New record field. (default-php-fpm-config, php-fpm-shepherd-service, php-fpm-activation): Use this. * doc/guix.texi (Web Services): Document this. --- doc/guix.texi | 2 ++ gnu/services/web.scm | 48 ++++++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 02778588ca..7304cf5f13 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17658,6 +17658,8 @@ Determines whether php errors and warning should be sent to clients and displayed in their browsers. This is useful for local php development, but a security risk for public sites, as error messages can reveal passwords and personal data. +@item @code{timezone} (default @code{#f}) +Specifies @code{php_admin_value[date.timezone]} parameter. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")}) This file will log the @code{stderr} outputs of php worker processes. Can be set to @code{#f} to disable logging. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index fcf453c248..d71fed20ed 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -142,6 +142,7 @@ php-fpm-configuration-log-file php-fpm-configuration-process-manager php-fpm-configuration-display-errors + php-fpm-configuration-timezone php-fpm-configuration-workers-log-file php-fpm-configuration-file @@ -773,6 +774,8 @@ of index files." (default (php-fpm-dynamic-process-manager-configuration))) (display-errors php-fpm-configuration-display-errors (default #f)) + (timezone php-fpm-configuration-timezone + (default #f)) (workers-log-file php-fpm-configuration-workers-log-file (default (string-append "/var/log/php" (version-major (package-version php)) @@ -827,7 +830,7 @@ of index files." (shell (file-append shadow "/sbin/nologin"))))))) (define (default-php-fpm-config socket user group socket-user socket-group - pid-file log-file pm display-errors workers-log-file) + pid-file log-file pm display-errors timezone workers-log-file) (apply mixed-text-file "php-fpm.conf" (flatten "[global]\n" @@ -840,6 +843,10 @@ of index files." "listen.owner =" socket-user "\n" "listen.group =" socket-group "\n" + (if timezone + (string-append "php_admin_value[date.timezone] = \"" timezone "\"\n") + "") + (match pm (($ pm.max-children @@ -879,7 +886,8 @@ of index files." (define php-fpm-shepherd-service (match-lambda (($ php socket user group socket-user socket-group - pid-file log-file pm display-errors workers-log-file file) + pid-file log-file pm display-errors + timezone workers-log-file file) (list (shepherd-service (provision '(php-fpm)) (documentation "Run the php-fpm daemon.") @@ -890,27 +898,27 @@ of index files." #$(or file (default-php-fpm-config socket user group socket-user socket-group pid-file log-file - pm display-errors workers-log-file))) + pm display-errors timezone workers-log-file))) #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))))) -(define php-fpm-activation - (match-lambda - (($ _ _ user _ _ _ _ log-file _ _ workers-log-file _) - #~(begin - (use-modules (guix build utils)) - (let* ((user (getpwnam #$user)) - (touch (lambda (file-name) - (call-with-output-file file-name (const #t)))) - (init-log-file - (lambda (file-name) - (when #$workers-log-file - (when (not (file-exists? file-name)) - (touch file-name)) - (chown file-name (passwd:uid user) (passwd:gid user)) - (chmod file-name #o660))))) - (init-log-file #$log-file) - (init-log-file #$workers-log-file)))))) +(define (php-fpm-activation config) + #~(begin + (use-modules (guix build utils)) + (let* ((user (getpwnam #$(php-fpm-configuration-user config))) + (touch (lambda (file-name) + (call-with-output-file file-name (const #t)))) + (workers-log-file + #$(php-fpm-configuration-workers-log-file config)) + (init-log-file + (lambda (file-name) + (when workers-log-file + (when (not (file-exists? file-name)) + (touch file-name)) + (chown file-name (passwd:uid user) (passwd:gid user)) + (chmod file-name #o660))))) + (init-log-file #$(php-fpm-configuration-log-file config)) + (init-log-file workers-log-file)))) (define php-fpm-service-type -- cgit v1.2.3 From 85c07cff9cd2197a16c2d3544e4930e278513cf7 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 29 Nov 2018 20:41:40 +0300 Subject: services: monitoring: Add 'zabbix-front-end'. * gnu/services/monitoring.scm (nginx-server-configuration-list?, serialize-nginx-server-configuration-list, zabbix-front-end-configuration, zabbix-front-end-config, zabbix-front-end-activation, generate-zabbix-front-end-documentation): New procedures. (%zabbix-front-end-configuration-nginx, %maintenance.inc.php, zabbix-front-end-service-type): New variables. * doc/guix.texi (Monitoring Services): Document this. --- doc/guix.texi | 75 ++++++++++++++++++++++ gnu/services/monitoring.scm | 148 +++++++++++++++++++++++++++++++++++++++++++- gnu/tests/monitoring.scm | 49 +++++++++++++++ 3 files changed, 270 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 7304cf5f13..338ff45c39 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16904,6 +16904,81 @@ Defaults to @samp{()}. @end deftypevr +@c %end of fragment + +@subsubheading Zabbix front-end +@cindex zabbix zabbix-front-end + +This service provides a WEB interface to Zabbix server. + +@c %start of fragment + +Available @code{zabbix-front-end-configuration} fields are: + +@deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx +NGINX configuration. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host +Database host name. + +Defaults to @samp{"localhost"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port +Database port. + +Defaults to @samp{5432}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name +Database name. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user +Database user. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password +Database password. Please, use @code{db-secret-file} instead. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file +Secret file which will be appended to @file{zabbix.conf.php} file. This +file contains credentials for use by Zabbix front-end. You are expected +to create it manually. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host +Zabbix server hostname. + +Defaults to @samp{"localhost"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port +Zabbix server port. + +Defaults to @samp{10051}. + +@end deftypevr + + @c %end of fragment @node Kerberos Services diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 323c0ace56..18413096e4 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -22,6 +22,7 @@ #:use-module (gnu services) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) + #:use-module (gnu services web) #:use-module (gnu packages admin) #:use-module (gnu packages monitoring) #:use-module (gnu system shadow) @@ -29,6 +30,7 @@ #:use-module (guix packages) #:use-module (guix records) #:use-module (ice-9 match) + #:use-module (ice-9 rdelim) #:use-module (srfi srfi-26) #:export (darkstat-configuration prometheus-node-exporter-configuration @@ -38,7 +40,10 @@ zabbix-server-configuration zabbix-server-service-type zabbix-agent-configuration - zabbix-agent-service-type)) + zabbix-agent-service-type + zabbix-front-end-configuration + zabbix-front-end-service-type + %zabbix-front-end-configuration-nginx)) ;;; @@ -179,6 +184,12 @@ prometheus.") (define (serialize-extra-options field-name val) (if (null? val) "" (display val))) +(define (nginx-server-configuration-list? val) + (and (list? val) (and-map nginx-server-configuration? val))) + +(define (serialize-nginx-server-configuration-list field-name val) + "") + (define-configuration zabbix-server-configuration (zabbix-server (package zabbix-server) @@ -356,7 +367,7 @@ the hosts listed here.") proxies for active checks. If port is not specified, default port is used. If this parameter is not specified, active checks are disabled.") (extra-options - (string "") + (extra-options "") "Extra options will be appended to Zabbix server configuration file.") (include-files (include-files '()) @@ -445,3 +456,136 @@ configuration file.")) `((zabbix-agent-configuration ,zabbix-agent-configuration-fields)) 'zabbix-agent-configuration)) + +(define %zabbix-front-end-configuration-nginx + (nginx-server-configuration + (root #~(string-append #$zabbix-server:front-end "/share/zabbix/php")) + (index '("index.php")) + (locations + (let ((php-location (nginx-php-location))) + (list (nginx-location-configuration + (inherit php-location) + (body (append (nginx-location-configuration-body php-location) + (list " +fastcgi_param PHP_VALUE \"post_max_size = 16M + max_execution_time = 300\"; +"))))))))) + +(define-configuration zabbix-front-end-configuration + ;; TODO: Specify zabbix front-end package. + ;; (zabbix- + ;; (package zabbix-front-end) + ;; "The zabbix-front-end package.") + (nginx + (nginx-server-configuration-list + (list %zabbix-front-end-configuration-nginx)) + "NGINX configuration.") + (db-host + (string "localhost") + "Database host name.") + (db-port + (number 5432) + "Database port.") + (db-name + (string "zabbix") + "Database name.") + (db-user + (string "zabbix") + "Database user.") + (db-password + (string "") + "Database password. Please, use @code{db-secret-file} instead.") + (db-secret-file + (string "") + "Secret file which will be appended to @file{zabbix.conf.php} file. This +file contains credentials for use by Zabbix front-end. You are expected to +create it manually.") + (zabbix-host + (string "localhost") + "Zabbix server hostname.") + (zabbix-port + (number 10051) + "Zabbix server port.")) + +(define zabbix-front-end-config + (match-lambda + (($ + _ db-host db-port db-name db-user db-password db-secret-file + zabbix-host zabbix-port) + (mixed-text-file "zabbix.conf.php" + "\ +string db-port) "'; +$DB['DATABASE'] = '" db-name "'; +$DB['USER'] = '" db-user "'; +$DB['PASSWORD'] = '" (if (string-null? db-password) + (if (string-null? db-secret-file) + (display "Provide a `db-secret-file' \ +or `db-password' field. +" + (current-error-port)) + (string-trim-both + (with-input-from-file db-secret-file + read-string))) + (begin + (display " +Hint: Consider use `db-secret-file' instead of `db-password' and unset +`db-password' for security in `zabbix-front-end-configuration'. +") + db-password)) "'; + +// Schema name. Used for IBM DB2 and PostgreSQL. +$DB['SCHEMA'] = ''; + +$ZBX_SERVER = '" zabbix-host "'; +$ZBX_SERVER_PORT = '" (number->string zabbix-port) "'; +$ZBX_SERVER_NAME = ''; + +$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; +")))) + +(define %maintenance.inc.php + ;; Empty php file to allow us move zabbix-frontend configs to ‘/etc/zabbix’ + ;; directory. See ‘install-front-end’ phase in + ;; (@ (gnu packages monitoring) zabbix-server) package. + "\ + Date: Sun, 16 Dec 2018 23:52:06 +0100 Subject: services: udev: Add 'rules' action. * gnu/services/base.scm (udev-shepherd-service): Add 'actions' field. * doc/guix.texi (Base Services): Move "@end deffn" after 'udev-service' definition. Mention 'herd rules udev'. --- doc/guix.texi | 5 ++++- gnu/services/base.scm | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 338ff45c39..1c26dc5a89 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11308,6 +11308,7 @@ Run @var{udev}, which populates the @file{/dev} directory dynamically. udev rules can be provided as a list of files through the @var{rules} variable. The procedures @var{udev-rule} and @var{file->udev-rule} from @code{(gnu services base)} simplify the creation of such rule files. +@end deffn @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}] Return a udev-rule file named @var{file-name} containing the rules @@ -11325,6 +11326,9 @@ upon detecting a USB device with a given product identifier. "ATTR@{product@}==\"Example\", " "RUN+=\"/path/to/script\""))) @end example + +The @command{herd rules udev} command, as root, returns the name of the +directory containing all the active udev rules. @end deffn Here we show how the default @var{udev-service} can be extended with it. @@ -11406,7 +11410,6 @@ well as in the @var{groups} field of the @var{operating-system} record. (rules (cons* android-udev-rules (udev-configuration-rules config)))))))) @end example -@end deffn @defvr {Scheme Variable} urandom-seed-service-type Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} diff --git a/gnu/services/base.scm b/gnu/services/base.scm index b10f5cbaf1..67bdaef18c 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1967,7 +1967,15 @@ item of @var{packages}." (respawn? #f) ;; We need additional modules. (modules `((gnu build linux-boot) - ,@%default-modules)))))))) + ,@%default-modules)) + + (actions (list (shepherd-action + (name 'rules) + (documentation "Display the directory containing +the udev rules in use.") + (procedure #~(lambda (_) + (display #$rules) + (newline)))))))))))) (define udev-service-type (service-type (name 'udev) -- cgit v1.2.3 From a93c1606312e41ffe509977502ce6055f40bc629 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 17 Dec 2018 22:47:44 +0100 Subject: environment: Support package transformation options. Fixes . Reported by Adrien Guilbaud . * guix/scripts/environment.scm (show-help): Add call to 'show-transformation-options-help'. (%options): Add %TRANSFORMATION-OPTIONS. (options/resolve-packages): Add 'store' parameter. [transform, package->manifest-entry*]: New procedures. Use 'package->manifest-entry*' instead of 'package->manifest-entry'. (guix-environment): Move definition of 'manifest' within 'with-store'. * tests/guix-environment.sh: Add test. --- doc/guix.texi | 3 ++- guix/scripts/environment.scm | 24 ++++++++++++++++++------ tests/guix-environment.sh | 14 +++++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 1c26dc5a89..3ee65116b6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8350,7 +8350,8 @@ guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile @command{guix environment} also supports all of the common build options that @command{guix -build} supports (@pxref{Common Build Options}). +build} supports (@pxref{Common Build Options}) as well as package +transformation options (@pxref{Package Transformation Options}). @node Invoking guix publish diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 5965e3426e..7733fbcae4 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -162,6 +162,8 @@ COMMAND or an interactive shell in that environment.\n")) (newline) (show-build-options-help) (newline) + (show-transformation-options-help) + (newline) (display (G_ " -h, --help display this help and exit")) (display (G_ " @@ -261,7 +263,9 @@ COMMAND or an interactive shell in that environment.\n")) (option '("bootstrap") #f #f (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) - %standard-build-options)) + + (append %transformation-options + %standard-build-options))) (define (pick-all alist key) "Return a list of values in ALIST associated with KEY." @@ -274,7 +278,7 @@ COMMAND or an interactive shell in that environment.\n")) (_ memo))) '() alist)) -(define (options/resolve-packages opts) +(define (options/resolve-packages store opts) "Return OPTS with package specification strings replaced by manifest entries for the corresponding packages." (define (manifest-entry=? e1 e2) @@ -282,15 +286,21 @@ for the corresponding packages." (string=? (manifest-entry-output e1) (manifest-entry-output e2)))) + (define transform + (cut (options->transformation opts) store <>)) + + (define* (package->manifest-entry* package #:optional (output "out")) + (package->manifest-entry (transform package) output)) + (define (packages->outputs packages mode) (match packages ((? package? package) (if (eq? mode 'ad-hoc-package) - (list (package->manifest-entry package)) + (list (package->manifest-entry* package)) (package-environment-inputs package))) (((? package? package) (? string? output)) (if (eq? mode 'ad-hoc-package) - (list (package->manifest-entry package output)) + (list (package->manifest-entry* package output)) (package-environment-inputs package))) ((lst ...) (append-map (cut packages->outputs <> mode) lst)))) @@ -301,7 +311,7 @@ for the corresponding packages." (('package 'ad-hoc-package (? string? spec)) (let-values (((package output) (specification->package+output spec))) - (list (package->manifest-entry package output)))) + (list (package->manifest-entry* package output)))) (('package 'package (? string? spec)) (package-environment-inputs (specification->package+output spec))) @@ -654,7 +664,6 @@ message if any test fails." ;; within the container. '("/bin/sh") (list %default-shell)))) - (manifest (options/resolve-packages opts)) (mappings (pick-all opts 'file-system-mapping))) (when container? (assert-container-features)) @@ -666,6 +675,9 @@ message if any test fails." (with-store store (with-status-report print-build-event + (define manifest + (options/resolve-packages store opts)) + (set-build-options-from-command-line store opts) ;; Use the bootstrap Guile when requested. diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh index b44aca099d..30b21028aa 100644 --- a/tests/guix-environment.sh +++ b/tests/guix-environment.sh @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2015, 2016, 2017 Ludovic Courtès +# Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès # # This file is part of GNU Guix. # @@ -118,6 +118,18 @@ fi # in its profile (e.g., for 'gzip'), but we have to accept them. guix environment guix --bootstrap -n +# Try program transformation options. +mkdir "$tmpdir/emacs-36.8" +drv="`guix environment --ad-hoc emacs -n 2>&1 | grep 'emacs.*\.drv'`" +transformed_drv="`guix environment --ad-hoc emacs --with-source="$tmpdir/emacs-36.8" -n 2>&1 | grep 'emacs.*\.drv'`" +test -n "$drv" +test "$drv" != "$transformed_drv" +case "$transformed_drv" in + *-emacs-36.8.drv) true;; + *) false;; +esac +rmdir "$tmpdir/emacs-36.8" + if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null then # Compute the build environment for the initial GNU Make. -- cgit v1.2.3 From b8d5fbd86f814cabf68c9804068e74f042e0d1a3 Mon Sep 17 00:00:00 2001 From: Jelle Licht Date: Tue, 18 Dec 2018 14:43:54 +0100 Subject: doc: Replace 'https-port' with 'listen' in nginx php example. * doc/guix.texi (Web Services): Update accordingly. --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 3ee65116b6..0d8f1757a3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17805,7 +17805,7 @@ A simple services setup for nginx with php can look like this: (root "/srv/http/") (locations (list (nginx-php-location))) - (https-port #f) + (listen '("80")) (ssl-certificate #f) (ssl-certificate-key #f))) %base-services)) -- cgit v1.2.3 From 4d55431d89f0209d764af811fc1ed0e48335ee39 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 18 Dec 2018 11:51:02 +0100 Subject: doc: Fix typo in '.guix-channel' example. * doc/guix.texi (Channels): Remove extra quote in '.guix-channel' example. --- doc/guix.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 0d8f1757a3..8fb4bf1a45 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3053,10 +3053,10 @@ The meta-data file should contain a simple S-expression like this: (version 0) (dependencies (channel - (name 'some-collection) + (name some-collection) (url "https://example.org/first-collection.git")) (channel - (name 'some-other-collection) + (name some-other-collection) (url "https://example.org/second-collection.git") (branch "testing")))) @end lisp -- cgit v1.2.3 From bd5a81f9b8eafc4721d64a53738e4da06eac2fa0 Mon Sep 17 00:00:00 2001 From: swedebugia Date: Fri, 14 Dec 2018 19:41:41 +0100 Subject: guix system: Clarify the three strategies available. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/system.scm (show-help): Clarify the three choices. * doc/guix.texi (Invoking guix system): Add 3 @cindex to make on-error=strategy easier to find. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 3 +++ guix/scripts/system.scm | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 8fb4bf1a45..8611b61026 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22953,6 +22953,9 @@ appear in the @code{operating-system} declaration actually exist needed at boot time are listed in @code{initrd-modules} (@pxref{Initial RAM Disk}). Passing this option skips these tests altogether. +@cindex on-error +@cindex on-error strategy +@cindex error strategy @item --on-error=@var{strategy} Apply @var{strategy} when an error occurs when reading @var{file}. @var{strategy} may be one of the following: diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 8eb32c62bc..6cda3ccbd6 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -993,7 +993,8 @@ Some ACTIONS support additional ARGS.\n")) instead of reading FILE, when applicable")) (display (G_ " --on-error=STRATEGY - apply STRATEGY when an error occurs while reading FILE")) + apply STRATEGY (one of nothing-special, backtrace, + or debug) when an error occurs while reading FILE")) (display (G_ " --file-system-type=TYPE for 'disk-image', produce a root file system of TYPE -- cgit v1.2.3 From 65c8a043709e9e13f814211bba98c57eb00d9620 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 18 Dec 2018 11:59:39 +0100 Subject: doc: Remove stale reference to 'hydra.gnu.org'. Reported by Thomas Schmitt . * doc/guix.texi (Binary Installation): Refer to SUBSTITUTE-SERVER, not to 'hydra.gnu.org'. --- doc/guix.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 8611b61026..6c5324ee0b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -585,12 +585,12 @@ Info search path.) @item @cindex substitutes, authorization thereof -To use substitutes from @code{hydra.gnu.org} or one of its mirrors +To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors (@pxref{Substitutes}), authorize them: @example # guix archive --authorize < \ - ~root/.config/guix/current/share/guix/hydra.gnu.org.pub + ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub @end example @item -- cgit v1.2.3 From 6e8986c8388e889eb74509999aea826fd440dcc4 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 18 Dec 2018 21:43:53 +0100 Subject: build: Add dune-build-system. * guix/build/dune-build-system.scm, guix/build-system/dune.scm: New files. * Makefile.am (MODULES): Add them. * doc/guix.texi (Build Systems): Document dune-build-system. * guix/build-system/ocaml.scm (lower, default-findlib, default-ocaml): Export them. (package-with-explicit-ocaml): Also transform packages built with dune-build-system. --- Makefile.am | 2 + doc/guix.texi | 21 ++++++ guix/build-system/dune.scm | 159 +++++++++++++++++++++++++++++++++++++++ guix/build-system/ocaml.scm | 16 +++- guix/build/dune-build-system.scm | 69 +++++++++++++++++ 5 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 guix/build-system/dune.scm create mode 100644 guix/build/dune-build-system.scm (limited to 'doc/guix.texi') diff --git a/Makefile.am b/Makefile.am index 4a190c4095..0e5ca02ed3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -107,6 +107,7 @@ MODULES = \ guix/build-system/clojure.scm \ guix/build-system/cmake.scm \ guix/build-system/dub.scm \ + guix/build-system/dune.scm \ guix/build-system/emacs.scm \ guix/build-system/font.scm \ guix/build-system/go.scm \ @@ -144,6 +145,7 @@ MODULES = \ guix/build/cargo-build-system.scm \ guix/build/cmake-build-system.scm \ guix/build/dub-build-system.scm \ + guix/build/dune-build-system.scm \ guix/build/emacs-build-system.scm \ guix/build/meson-build-system.scm \ guix/build/minify-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 6c5324ee0b..8f6a8b3ed2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4512,6 +4512,27 @@ debugging information''), which roughly means that code is compiled with @code{-O2 -g}, as is the case for Autoconf-based packages by default. @end defvr +@defvr {Scheme Variable} dune-build-system +This variable is exported by @code{(guix build-system dune)}. It +supports builds of packages using @uref{https://dune.build/, Dune}, a build +tool for the OCaml programming language. It is implemented as an extension +of the @code{ocaml-build-system} which is described below. As such, the +@code{#:ocaml} and @code{#:findlib} parameters can be passed to this build +system. + +It automatically adds the @code{dune} package to the set of inputs. +Which package is used can be specified with the @code{#:dune} +parameter. + +There is no @code{configure} phase because dune packages typically don't +need to be configured. The @code{#:build-flags} parameter is taken as a +list of flags passed to the @code{dune} command during the build. + +The @code{#:jbuild?} parameter can be passed to use the @code{jbuild} +command instead of the more recent @code{dune} command while building +a package. Its default value is @code{#f}. +@end defvr + @defvr {Scheme Variable} go-build-system This variable is exported by @code{(guix build-system go)}. It implements a build procedure for Go packages using the standard diff --git a/guix/build-system/dune.scm b/guix/build-system/dune.scm new file mode 100644 index 0000000000..8bd41c89f0 --- /dev/null +++ b/guix/build-system/dune.scm @@ -0,0 +1,159 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016, 2017, 2018 Julien Lepiller +;;; Copyright © 2017 Ben Woodcroft +;;; +;;; 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 (guix build-system dune) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module ((guix build-system gnu) #:prefix gnu:) + #:use-module ((guix build-system ocaml) #:prefix ocaml:) + #:use-module (guix packages) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:export (%dune-build-system-modules + dune-build + dune-build-system)) + +;; Commentary: +;; +;; Standard build procedure for packages using dune. This is implemented as an +;; extension of `ocaml-build-system'. +;; +;; Code: + +(define %dune-build-system-modules + ;; Build-side modules imported by default. + `((guix build dune-build-system) + ,@ocaml:%ocaml-build-system-modules)) + +(define (default-dune) + "Return the default OCaml package." + + ;; Do not use `@' to avoid introducing circular dependencies. + (let ((module (resolve-interface '(gnu packages ocaml)))) + (module-ref module 'dune))) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (dune (default-dune)) + (ocaml (ocaml:default-ocaml)) + (findlib (ocaml:default-findlib)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:dune #:findlib #:ocaml #:inputs #:native-inputs)) + + (and (not target) ;XXX: no cross-compilation + (let ((base (ocaml:lower name + #:source source + #:inputs inputs + #:native-inputs native-inputs + #:outputs outputs + #:system system + #:target target + #:ocaml ocaml + #:findlib findlib + arguments))) + (bag + (inherit base) + (build-inputs `(("dune" ,dune) + ,@(bag-build-inputs base))) + (build dune-build) + (arguments (strip-keyword-arguments private-keywords arguments)))))) + +(define* (dune-build store name inputs + #:key (guile #f) + (outputs '("out")) + (search-paths '()) + (build-flags ''()) + (out-of-source? #t) + (jbuild? #f) + (tests? #t) + (test-flags ''()) + (test-target "test") + (install-target "install") + (validate-runpath? #t) + (patch-shebangs? #t) + (strip-binaries? #t) + (strip-flags ''("--strip-debug")) + (strip-directories ''("lib" "lib64" "libexec" + "bin" "sbin")) + (phases '(@ (guix build dune-build-system) + %standard-phases)) + (system (%current-system)) + (imported-modules %dune-build-system-modules) + (modules '((guix build dune-build-system) + (guix build utils)))) + "Build SOURCE using OCAML, and with INPUTS. This assumes that SOURCE +provides a 'setup.ml' file as its build system." + (define builder + `(begin + (use-modules ,@modules) + (dune-build #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:system ,system + #:outputs %outputs + #:inputs %build-inputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:phases ,phases + #:test-flags ,test-flags + #:build-flags ,build-flags + #:out-of-source? ,out-of-source? + #:jbuild? ,jbuild? + #:tests? ,tests? + #:test-target ,test-target + #:install-target ,install-target + #:validate-runpath? ,validate-runpath? + #:patch-shebangs? ,patch-shebangs? + #:strip-binaries? ,strip-binaries? + #:strip-flags ,strip-flags + #:strip-directories ,strip-directories))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:system system + #:inputs inputs + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define dune-build-system + (build-system + (name 'dune) + (description "The standard Dune build system") + (lower lower))) + +;;; dune.scm ends here diff --git a/guix/build-system/ocaml.scm b/guix/build-system/ocaml.scm index e5b715f55d..07c69fac76 100644 --- a/guix/build-system/ocaml.scm +++ b/guix/build-system/ocaml.scm @@ -31,6 +31,9 @@ package-with-ocaml4.02 strip-ocaml4.01-variant strip-ocaml4.02-variant + default-findlib + default-ocaml + lower ocaml-build ocaml-build-system)) @@ -76,6 +79,13 @@ (let ((module (resolve-interface '(gnu packages ocaml)))) (module-ref module 'ocaml-findlib))) +(define (default-dune-build-system) + "Return the dune-build-system." + + ;; Do not use `@' to avoid introducing circular dependencies. + (let ((module (resolve-interface '(guix build-system dune)))) + (module-ref module 'dune-build-system))) + (define (default-ocaml4.01) (let ((ocaml (resolve-interface '(gnu packages ocaml)))) (module-ref ocaml 'ocaml-4.01))) @@ -119,7 +129,8 @@ pre-defined variants." => force) ;; Otherwise build the new package object graph. - ((eq? (package-build-system p) ocaml-build-system) + ((or (eq? (package-build-system p) ocaml-build-system) + (eq? (package-build-system p) (default-dune-build-system))) (package (inherit p) (location (package-location p)) @@ -138,7 +149,8 @@ pre-defined variants." (else p))) (define (cut? p) - (or (not (eq? (package-build-system p) ocaml-build-system)) + (or (not (or (eq? (package-build-system p) ocaml-build-system) + (eq? (package-build-system p) (default-dune-build-system)))) (package-variant p))) (package-mapping transform cut?)) diff --git a/guix/build/dune-build-system.scm b/guix/build/dune-build-system.scm new file mode 100644 index 0000000000..fcc2d6567d --- /dev/null +++ b/guix/build/dune-build-system.scm @@ -0,0 +1,69 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Julien Lepiller +;;; +;;; 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 (guix build dune-build-system) + #:use-module ((guix build ocaml-build-system) #:prefix ocaml:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:export (%standard-phases + dune-build)) + +;; Commentary: +;; +;; Builder-side code of the standard dune build procedure. +;; +;; Code: + +(define* (build #:key (build-flags '()) (jbuild? #f) + (use-make? #f) #:allow-other-keys) + "Build the given package." + (let ((program (if jbuild? "jbuilder" "dune"))) + (apply invoke program "build" "@install" build-flags)) + #t) + +(define* (check #:key (test-flags '()) (test-target "test") tests? + (jbuild? #f) #:allow-other-keys) + "Test the given package." + (when tests? + (let ((program (if jbuild? "jbuilder" "dune"))) + (apply invoke program "runtest" test-target test-flags))) + #t) + +(define* (install #:key outputs (install-target "install") (jbuild? #f) + #:allow-other-keys) + "Install the given package." + (let ((out (assoc-ref outputs "out")) + (program (if jbuild? "jbuilder" "dune"))) + (invoke program install-target "--prefix" out)) + #t) + +(define %standard-phases + ;; Everything is as with the GNU Build System except for the `configure' + ;; , `build', `check' and `install' phases. + (modify-phases ocaml:%standard-phases + (delete 'configure) + (replace 'build build) + (replace 'check check) + (replace 'install install))) + +(define* (dune-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given package, applying all of PHASES in order." + (apply ocaml:ocaml-build #:inputs inputs #:phases phases args)) + +;;; dune-build-system.scm ends here -- cgit v1.2.3 From 295430f0cfdff1ca517cfa74136b550fecf6efcb Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 21 Dec 2018 22:02:16 +0100 Subject: doc: '--search' is case-insensitive. Suggested by Chris Marusich . * doc/guix.texi (Invoking guix package): Mention that --search is case-insensitive. --- doc/guix.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'doc/guix.texi') diff --git a/doc/guix.texi b/doc/guix.texi index 8f6a8b3ed2..e254b38597 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2120,7 +2120,8 @@ availability of packages: @itemx -s @var{regexp} @cindex searching for packages List the available packages whose name, synopsis, or description matches -@var{regexp}, sorted by relevance. Print all the metadata of matching packages in +@var{regexp} (in a case-insensitive fashion), sorted by relevance. +Print all the metadata of matching packages in @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}). -- cgit v1.2.3