unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob eca9d54527b1d4d2566a72738df39f3af7d46009 5714 bytes (raw)
name: gnu/services/printing.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;;
;;; 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 services printing)
  #:use-module (gnu services)
  #:use-module (gnu services shepherd)
  #:use-module (gnu packages cups)
  #:use-module (guix gexp)
  #:use-module (guix records)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-9)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 match)
  #:export (cups-service))

(define (default-cups-files-config data-dir)
  ;; generate cups-files.conf [for cupsd -s ...], especially dynamically set DataDir.
  (mixed-text-file "cups-files.conf"
                   "AccessLog syslog\n"
                   "ErrorLog syslog\n"
                   "PageLog syslog\n"
                   "FatalErrors all\n"
                   "SyncOnClose Yes\n"
                   "User nobody\n"
                   "Group lp\n"
                   ; FIXME SystemGroup lpadmin sys system root
                   ; FIXME ConfigFilePerm
                   ;; DataDir /var/lib/cupsd/data
                   (string-append "DataDir " data-dir "\n") ; /gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0/share/cups
                   (string-append "DocumentRoot " /gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0 "/share/doc/cups\n")
                   "CacheDir /var/cache/cups\n"
                   "StateDir /var/run/cups\n"
                   ; FIXME FontPath /zzz
                   "Printcap /etc/printcap\n"
                   "PrintcapFormat bsd\n"
                   "RequestRoot /var/spool/cups\n"
                   ;;/gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0/lib/cups
                   "ServerBin /home/dannym/.guix-profile/lib/cups\n" ; FIXME
                   "ServerRoot /etc/cups\n" ; FIXME
))

;; TODO same with /usr/lib/cups
(define (data-directory packages)
  "Return a directory containing
     @file{banners}
     @file{charsets}
     @file{drv} (most important)
     @file{fonts}
     @file{ipptool}
     @file{locale}
     @file{mime}
     @file{model} (empty)
     @file{ppdc}
     @file{ppd-updaters}
     @file{profiles} (empty)
     @file{templates}
     @file{usb}
   merged from the packages
  "
  (computed-file "usr-share-cups"
    #~(begin
        (use-modules (guix build union) (srfi srfi-26))
        (union-build #$output
                     (map (cut string-append <> "/share/cups")
                          (list #$@packages))))
    #:modules '((guix build union))))

(define-record-type* <cups-configuration>
  cups-configuration make-cups-configuration
  cups-configuration?
  (printers cups-configuration-printers)
  (provision cups-configuration-provision)
  (cups cups-configuration-cups (default cups))
  (actions cups-configuration-actions (default '()))) ; package list

; TODO cupsd -c /etc/cupsd.conf -F
; TODO what user should cupsd run as? (Debian: root)
; TODO cups-browsed (Debian: also as root)
; TODO list of printers; paper size, printer vendor and model, interface (if necessary).
; TODO binding to network interface; running the config html page; auth there; auth in general?
; TODO support scanners and hpaio thing as sane dll

; 
; 
; 
; merge: /var/lib/hp ? no
; merge: /etc/hp ? no
; merge: /usr/share/hal/fdi ? useless.
; merge: /etc/udev/rules.d ? done.
; merge: /lib/systemd/system ? useless.
; merge: /lib/cups/filter
; merge: /lib/cups/backend
; merge: mime.types
; merge: /share/applications
; merge: /usr/share/ppd/HP via DRV into DataDir.
; merge: drv into DataDir

(define cups-shepherd-service
   (match-lambda
     (($ <cups-configuration> printers provision cups)
      (let ((loopback? (memq 'loopback provision)))
       (list
        (shepherd-service
         (requirement '(udev networking)) ; TODO check actual config and reduce
         (documentation "Bring up printing services.")
         (provision provision)
         (start #~(make-forkexec-constructor
                   (list (string-append #$cups "/sbin/cupsd")
                         "-s" (default-cups-files-config "/tmp") ; FIXME merged datadir
                         ; FIXME "-c" cups config
                         "-f")))
         (stop #~(make-kill-destructor))))))))

(define cups-service-type
  (service-type (name 'cups)
                (extensions
                 (list (service-extension shepherd-root-service-type cups-shepherd-service)))
                (compose concatenate)
                (extend (lambda (config actions)
                          (cups-configuration
                           (inherit config)
                           (actions
                            (append (cups-configuration-actions config)
                                    actions)))))))

(define* (cups-service #:key printers (provision '(printing)) )
  "Return a printing service that starts cups."
  (service cups-service-type
           (cups-configuration (printers printers)
                               (provision provision))))


debug log:

solving d8f6924 ...
found d8f6924 in https://yhetil.org/guix-devel/20160323100754.3798241b@scratchpost.org/

applying [1/1] https://yhetil.org/guix-devel/20160323100754.3798241b@scratchpost.org/
diff --git a/gnu/services/printing.scm b/gnu/services/printing.scm
new file mode 100644
index 0000000..d8f6924

1:105: trailing whitespace.
; 
1:106: trailing whitespace.
; 
1:107: trailing whitespace.
; 
Checking patch gnu/services/printing.scm...
1:153: new blank line at EOF.
+
Applied patch gnu/services/printing.scm cleanly.
warning: 4 lines add whitespace errors.

index at:
100644 eca9d54527b1d4d2566a72738df39f3af7d46009	gnu/services/printing.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).