aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu tests cups)
  #:use-module (gnu tests)
  #:use-module (gnu system)
  #:use-module (gnu system vm)
  #:use-module (gnu services)
  #:use-module (gnu services cups)
  #:use-module (gnu services networking)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:use-module (guix monads)
  #:export (%test-cups))

;;;
;;; Test the Common Unix Printing System.
;;;

(define* (run-cups-test os-configuration #:optional (cups-port 631))
  (define os
    (marionette-operating-system os-configuration
                                 #:imported-modules '((gnu services herd))))

  (define forwarded-port 8080)

  (define vm
    (virtual-machine
     (operating-system os)
     (port-forwardings `((,forwarded-port . ,cups-port)))))

  (define test
    (with-imported-modules '((gnu build marionette))
      #~(begin
          (use-modules (gnu build marionette)
                       (srfi srfi-11) (srfi srfi-64)
                       (web client) (web response))

          (define marionette
            (make-marionette (list #$vm)))

          (test-runner-current (system-test-runner #$output))
          (test-begin "cups")

          ;; Wait for the web interface to become ready.
          (wait-for-tcp-port #$cups-port marionette)

          (test-equal "http-get default page"
            200
            (let-values
                (((response text)
                  (http-get #$(simple-format
                               #f "http://localhost:~A/" forwarded-port)
                            #:decode-body? #t)))
              (response-code response)))

          (test-equal "http-get admin page"
            200
            (let-values
                (((response text)
                  (http-get #$(simple-format
                               #f "http://localhost:~A/admin" forwarded-port)
                            #:decode-body? #t)))
              (response-code response)))

          (test-end))))

  (gexp->derivation "cups-test" test))

(define %cups-os
  (simple-operating-system
   (service dhcp-client-service-type)
   (service cups-service-type
            (cups-configuration
             (web-interface? #t)
             ;; Listen on all interfaces instead of just localhost so we
             ;; can access the web interface "remotely".
             (listen '("*:631" "/var/run/cups/cups.sock"))
             ;; Add access controls for the Qemu-managed network.
             (location-access-controls
              (list (location-access-control
                     (path "/")
                     (access-controls '("Order allow,deny"
                                        "Allow from 10.0.0.0/8")))
                    (location-access-control
                     (path "/admin")
                     (access-controls '("Order allow,deny"
                                        "Allow from 10.0.0.0/8")))
                    (location-access-control
                     (path "/admin/conf")
                     (access-controls '("Order allow,deny"
                                        "AuthType Basic"
                                        "Require user @SYSTEM"
                                        "Allow localhost")))))))))

(define %test-cups
  (system-test
   (name "cups")
   (description "Test the CUPS print server")
   (value (run-cups-test %cups-os))))

gent-configuration): Document the GROUP field as 'string'. * doc/guix.texi (Monitoring Services): Adjust accordingly. 2022-11-17Fix problems initially introduced in commit 543d971ed2, now reinstated.Maxim Cournoyer Commit 543d971ed2 ("services: configuration: Re-order generated record fields") introduced two regressions, one in guix home and another one in the zabbix service. * gnu/home/services/shells.scm (home-bash-extensions): Remove the first pattern in the match, which used to be to ignore %location. * gnu/services/monitoring.scm (zabbix-front-end-nginx-extension): Likewise. 2022-11-17Revert "services: configuration: Revert to a working ‘guix home’."Maxim Cournoyer This reverts commit 39e4e00f75be8055300cb0afffb8bd4b4d35f2cc, with fixes for the guix home issues reported and another one found while reconfiguring berlin in the subsequent commit. 2022-11-13services: configuration: Revert to a working ‘guix home’.Tobias Geerinckx-Rice This reverts commit 543d971ed2a1d9eb934af1f51930741d7cc4e7ef, and its dependent commit 9b21cd2e9a614f1937769caf3917a791b151d841, which appear to have triggered a recent wave of ‘guix home’ regressions involving (services (list (service home-bash-service-type))): In gnu/home/services/shells.scm: 504:7 3 (home-bash-extensions #<<home-bash-configuration> package: #<package bash@5.1.8 gnu/packages/ba…> …) In unknown file: 2 (append #<<location> file: "…" line: 14 column: 12> ()) In ice-9/boot-9.scm: 1685:16 1 (raise-exception _ #:continuable? _) 1685:16 0 (raise-exception _ #:continuable? _) ice-9/boot-9.scm:1685:16: In procedure raise-exception: In procedure append: Wrong type argument in position 1 (expecting empty list): #<<location> file: "…" line: 14 column: 12> I should love to dive in & fix this rather than revert, but urgently need sleep. 2022-11-15services: configuration: Re-order generated record fields.Maxim Cournoyer This is so that the first field of the generated record matches the first one declared, which makes 'define-configuration' record API compatible with define-record-type* ones. * gnu/services/configuration.scm (define-configuration-helper): Move the %location field below the ones declared by the user. * gnu/services/monitoring.scm (zabbix-front-end-config): Adjust match pattern accordingly. 2022-04-29services: Add missing 'description' fields.Ludovic Courtès * gnu/services/databases.scm (postgresql-service-type)[description]: New field. (memcached-service-type)[description]: New field. (mysql-service-type)[description]: New field. (redis-service-type)[description]: New field. * gnu/services/desktop.scm (geoclue-service-type)[description]: New field. (udisks-service-type)[description]: New field. (elogind-service-type)[description]: New field. (account-service-type)[description]: New field. * gnu/services/kerberos.scm (krb5-service-type)[description]: New field. (pam-krb5-service-type)[description]: New field. * gnu/services/lirc.scm (lirc-service-type)[description]: New field. * gnu/services/mail.scm (dovecot-service-type)[description]: New field. (opensmtpd-service-type)[description]: New field. (mail-aliases-service-type)[description]: New field. (exim-service-type)[description]: New field. * gnu/services/monitoring.scm (zabbix-server-service-type)[description]: New field. (zabbix-agent-service-type)[description]: New field. * gnu/services/nfs.scm (rpcbind-service-type)[description]: New field. (pipefs-service-type)[description]: New field. (gss-service-type)[description]: New field. (idmap-service-type)[description]: New field. * gnu/services/spice.scm (spice-vdagent-service-type)[description]: New field. * gnu/services/sysctl.scm (sysctl-service-type)[description]: New field. * gnu/services/virtualization.scm (libvirt-service-type)[description]: New field. (virtlog-service-type)[description]: New field. * gnu/services/vpn.scm (openvpn-server-service-type)[description]: New field. (openvpn-client-service-type)[description]: New field. (wireguard-service-type)[description]: New field. * gnu/services/web.scm (httpd-service-type)[description]: New field. (fcgiwrap-service-type)[description]: New field. (agate-service-type)[description]: New field. [name]: Fix. 2022-02-17services: zabbix: Add requirement on 'user-processes'.Marius Bakke This ensures the services does not start before mounts are up. Reported by rekado on #guix. * gnu/services/monitoring.scm (zabbix-server-shepherd-service, zabbix-agent-shepherd-service)[requirement]: New field. 2022-02-13doc: Zabbix: Improvide description.Marius Bakke * doc/guix.texi (Monitoring Services): Document the various 'zabbix-*' service types, and expand description of all Zabbix services. Use less marketing terms. (Web Services): Add subsubheading for PHP-FPM, and anchors for cross-referencing. * gnu/services/monitoring.scm (zabbix-front-end-configuration): Use @ref instead of @pxref for cross-referencing. 2022-02-07services: zabbix-frontend: Restore correct variable name.Marius Bakke This is a follow-up to 326e08bf0f55409f040612001f73a2cc4091c159, et.al. * gnu/services/monitoring.scm (%zabbix-front-end-nginx-configuration): Rename to ... (%zabbix-front-end-configuration-nginx): ... this. (zabbix-front-end-nginx-extension): Adjust accordingly. 2022-02-07services: monitoring: Remove unused procedure.Marius Bakke This is a follow-up to commit 326e08bf0f55409f040612001f73a2cc4091c159. * gnu/services/monitoring.scm (zabbix-front-end-nginx-configuration): Remove variable. 2022-02-07services: zabbix-front-end: Restore backwards compatibility.Marius Bakke Commit e301f1a8ed11f9eacb2b7f525a7446dc00621a8b removed the NGINX argument entirely, but users may rely on and override it. Reported by rekado on #guix. * gnu/services/monitoring.scm (%zabbix-front-end-nginx-configuration): Restore exported variable. (zabbix-front-end-nginx-extension): New procedure. (zabbix-front-end-configuration): Remove FASTCGI-PARAMS field. Restore NGINX field, but default to the empty list. (zabbix-front-end-service-type): Extend NGINX-SERVICE-TYPE by ZABBIX-FRONT-END-NGINX-EXTENSION. * doc/guix.texi (Monitoring Services): Regenerate documentation. 2022-02-01services: zabbix-frontend: Support custom server package.Marius Bakke * gnu/services/monitoring.scm (%zabbix-front-end-configuration-nginx): Rename to ... (zabbix-front-end-nginx-configuration): ... this. Take server package and FastCGI parameters from ... (zabbix-front-end-configuration): ... here. Add PACKAGE and FASTCGI-PARAMS fields, remove NGINX. (zabbix-front-end-service-type): Adjust for renamed procedure. * doc/guix.texi (Monitoring Services)[Zabbix front-end]: Regenerate documentation. 2022-01-30services: zabbix: Support gexps in configuration serializer.Marius Bakke This makes it possible to do e.g. (include-files (list (local-file "foo.conf"))). * gnu/services/monitoring.scm (serialize-field, serialize-list, serialize-include-files, serialize-extra-options): Rewrite as gexps. (zabbix-server-config-file, zabbix-agent-config-file): Simplify builders by using FORMAT. 2022-01-29services: zabbix-agent: Set the PATH variable.Marius Bakke * gnu/services/monitoring.scm (zabbix-agent-shepherd-service)[start]: Set the PATH variable to the common values. 2022-01-29services: zabbix-frontend: Adjust indentation.Marius Bakke * gnu/services/monitoring.scm (zabbix-front-end-activation): Reindent. 2022-01-29services: zabbix-frontend: Enable IEEE754-compatible history values.Marius Bakke * gnu/services/monitoring.scm (zabbix-front-end-config): Specify $DB['DOUBLE_IEEE754'] in the configuration file, as per current example. 2022-01-29services: zabbix-server: Add shepherd actions for runtime control commands.Marius Bakke * gnu/services/monitoring.scm (zabbix-server-runtime-control-procedure, zabbix-server-actions): New variables. (zabbix-server-shepherd-service)[actions]: New field. Let-bind variables common between actions and the start procedure. 2022-01-29services: zabbix-frontend: Fix configuration file for hard coded passwords.Marius Bakke This is a follow-up to commit 078f5bfae7ee174177791defcfd350117a503a6d. * gnu/services/monitoring.scm (zabbix-front-end-config): When DB-PASSWORD is set, enclose the password with quotes in the configuration file. 2022-01-26services: zabbix-server: Do not write database password to the store.Marius Bakke * gnu/services/monitoring.scm (zabbix-front-end-config): Read the secret file from zabbix.conf.php at runtime instead of embedding the contents. 2022-01-26services: zabbix-agent: Respect user and group configuration.Marius Bakke * gnu/services/monitoring.scm (zabbix-agent-account): Look up user and group from CONFIG instead of hard-coded values. 2021-11-30services: Accept <inferior-package>s in lieu of <package>s.Tobias Geerinckx-Rice * gnu/services/authentication.scm (fprintd-configuration) (nslcd-configuration): Substitute file-like objects for package ones. * gnu/services/cgit.scm (cgit-configuration, opaque-cgit-configuration): Likewise. * gnu/services/cups.scm (package-list?, cups-configuration): Likewise. * gnu/services/dns.scm (verify-knot-configuration) (ddclient-configuration): Likewise. * gnu/services/docker.scm (docker-configuration): Likewise. * gnu/services/file-sharing.scm (transmission-daemon-configuration): Likewise. * gnu/services/getmail.scm (getmail-configuration): Likewise. * gnu/services/mail.scm (dovecot-configuration) (opaque-dovecot-configuration): Likewise. * gnu/services/messaging.scm (prosody-configuration) (opaque-prosody-configuration): Likewise. * gnu/services/monitoring.scm (zabbix-server-configuration) (zabbix-agent-configuration): Likewise. * gnu/services/networking.scm (opendht-configuration): Likewise. * gnu/services/pm.scm (tlp-configuration): Likewise. * gnu/services/telephony.scm (jami-configuration): Likewise. * gnu/services/virtualization.scm (libvirt-configuration) (qemu-guest-agent-configuration): Likewise. * gnu/services/vpn.scm (openvpn-client-configuration): Likewise. 2020-12-07prometheus-node-exporter: Support extra options.Christopher Baines There are plenty of options supported that the Guix configuration record doesn't help you with, so add this field to allow users to do their own thing. * gnu/services/monitoring.scm (<prometheus-node-exporter-configuration>): Add extra-options field. (prometheus-node-exporter-shepherd-service): Handle the extra options. * doc/guix.texi (Prometheus Node Exporter Service): Document this. 2020-12-07prometheus-node-exporter: Enable the textfile collector.Christopher Baines * gnu/services/monitoring.scm (<prometheus-node-exporter-configuration>): Add textfile-directory. (prometheus-node-exporter-textfile-directory, prometheus-node-exporter-activation): New procedures. (prometheus-node-exporter-shepherd-service): Pass --collector.textfile.directoryto the service. (prometheus-node-exporter-service-type): Extend the activation service type. * doc/guix.texi (Prometheus Node Exporter Service): Document. 2020-12-07services: prometheus-node-exporter: Use a log file.Christopher Baines This makes the logs easier to find and read. * gnu/services/monitoring.scm (prometheus-node-exporter-shepherd-service): Pass #:log-file to make-forkexec-constructor. 2020-12-07prometheus-node-exporter: Add user and group.Christopher Baines So it doesn't run as root, and because this will help with the textfile exporter. * gnu/services/monitoring.scm (%prometheus-node-exporter-accounts): New variable. (prometheus-node-exporter-shepherd-service): Use the relevant user and group. (prometheus-node-exporter-service-type): Extend the account service type. 2020-12-07services: prometheus-node-exporter: Neaten up.Christopher Baines Add relevant exports, as well as a comment to better indicate where the relevant code starts. * gnu/services/monitoring.scm (prometheus-node-exporter-service-type): Capitalise Prometheus. 2020-11-29services: zabbix-agent: Delete not mandatory hostname configuration.Oleg Pykhalov * gnu/services/monitoring.scm (zabbix-agent-configuration)[hostname]: Set to empty string. 2020-11-05services: Remove imports of (ice-9 …) modules.Ludovic Courtès * gnu/services/monitoring.scm (zabbix-server-activation): Remove (ice-9 rdelim) from the imported modules. (zabbix-agent-activation): Likewise. * gnu/tests/mail.scm (run-exim-test)[test]: Remove (ice-9 ftw) from the imported modules.