services: postgresql: Use "/tmp" host directory.
[jackhill/guix/guix.git] / gnu / services / cups.scm
index e77c43b..20e3917 100644 (file)
@@ -4,6 +4,7 @@
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,8 +32,9 @@
   #:use-module (guix packages)
   #:use-module (guix records)
   #:use-module (guix gexp)
+  #:use-module (guix modules)
   #:use-module (ice-9 match)
-  #:use-module ((srfi srfi-1) #:select (append-map))
+  #:use-module ((srfi srfi-1) #:select (append-map find))
   #:export (cups-service-type
             cups-configuration
             opaque-cups-configuration
 ;;; Code:
 
 (define %cups-accounts
-  (list (user-group (name "lp") (system? #t))
+  (list (or
+         ;; The "lp" group should already exist; try to reuse it.
+         (find (lambda (group)
+                 (and (user-group? group)
+                      (string=? (user-group-name group) "lp")))
+               %base-groups)
+         (user-group (name "lp") (system? #t)))
         (user-group (name "lpadmin") (system? #t))
         (user-account
          (name "lp")
 (define (serialize-multiline-string-list field-name val)
   (for-each (lambda (str) (serialize-field field-name str)) val))
 
+(define (comma-separated-string-list? val)
+  (and (list? val)
+       (and-map (lambda (x)
+                  (and (string? x) (not (string-index x #\,))))
+                val)))
+(define (serialize-comma-separated-string-list field-name val)
+  (serialize-field field-name (string-join val ",")))
+
 (define (space-separated-string-list? val)
   (and (list? val)
        (and-map (lambda (x)
 (define-enumerated-field-type default-encryption
   (Never IfRequested Required))
 (define-enumerated-field-type error-policy
-  (abort-job retry-job retry-this-job stop-printer))
+  (abort-job retry-job retry-current-job stop-printer))
 (define-enumerated-field-type log-level
   (none emerg alert crit error warn notice info debug debug2))
 (define-enumerated-field-type log-time-format
@@ -450,7 +466,10 @@ or state files.")
   (user
    (string "lp")
    "Specifies the user name or ID that is used when running external
-programs."))
+programs.")
+  (set-env
+   (string "variable value")
+   "Set the specified environment variable to be passed to child processes."))
 
 (define (serialize-files-configuration field-name val)
   #f)
@@ -471,7 +490,8 @@ programs."))
    (package cups)
    "The CUPS package.")
   (extensions
-   (package-list (list cups-filters))
+   (package-list (list brlaser cups-filters epson-inkjet-printer-escpr
+                       foomatic-filters hplip-minimal splix))
    "Drivers and other extensions to the CUPS package.")
   (files-configuration
    (files-configuration (files-configuration))
@@ -489,6 +509,11 @@ requests.")
    (boolean #f)
    "Specifies whether to purge job history data automatically when it is no
 longer required for quotas.")
+  (browse-dns-sd-sub-types
+   (comma-separated-string-list (list "_cups"))
+   "Specifies a list of DNS-SD sub-types to advertise for each shared printer.
+For example, @samp{\"_cups\" \"_print\"} will tell network clients that both
+CUPS sharing and IPP Everywhere are supported.")
   (browse-local-protocols
    (browse-local-protocols 'dnssd)
    "Specifies which protocols to use for local printer sharing.")
@@ -538,7 +563,7 @@ typically within a few milliseconds.")
    (error-policy 'stop-printer)
    "Specifies what to do when an error occurs.  Possible values are
 @code{abort-job}, which will discard the failed print job; @code{retry-job},
-which will retry the job at a later time; @code{retry-this-job}, which retries
+which will retry the job at a later time; @code{retry-current-job}, which retries
 the failed job immediately; and @code{stop-printer}, which stops the
 printer.")
   (filter-limit
@@ -798,9 +823,6 @@ reports @code{CUPS 2.0}.  @code{Minimal} reports @code{CUPS 2.0.0}.  @code{OS}
 reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is the output of the
 @code{uname} command.  @code{Full} reports @code{CUPS 2.0.0 (@var{uname})
 IPP/2.0}.")
-  (set-env
-   (string "variable value")
-   "Set the specified environment variable to be passed to child processes.")
   (ssl-listen
    (multiline-string-list '())
    "Listens on the specified interfaces for encrypted connections.  Valid
@@ -851,13 +873,11 @@ IPP specifications.")
 
 (define %cups-activation
   ;; Activation gexp.
-  (with-imported-modules '((guix build utils))
+  (with-imported-modules (source-module-closure '((gnu build activation)
+                                                  (guix build utils)))
     #~(begin
-        (use-modules (guix build utils))
-        (define (mkdir-p/perms directory owner perms)
-          (mkdir-p directory)
-          (chown "/var/run/cups" (passwd:uid owner) (passwd:gid owner))
-          (chmod directory perms))
+        (use-modules (gnu build activation)
+                     (guix build utils))
         (define (build-subject parameters)
           (string-concatenate
            (map (lambda (pair)