;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès ;;; Copyright © 2015 Mark H Weaver ;;; ;;; 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 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)) ; TODO or just fetch the one from cups and modify it a bit. (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 )) (define-record-type* cups make-cups cups? (printers cups-printers) (provision cups-provision)) ; TODO cupsd -c /etc/cupsd.conf -s /etc/cups-files.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 ; FIXME extensions (list (service-extension ... ; FIXME compose concatenate ; FIXME extend (lambda (config actions) ; 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. ; TODO merge: /lib/cups/filter ; TODO merge: /lib/cups/backend ; TODO merge: mime.types ; TODO merge: /share/applications ; TODO merge: /usr/share/ppd/HP via DRV? ; TODO merge: drv into DataDir (define cups-service-type (shepherd-service-type 'cups (match-lambda (($ printers provision) (let ((loopback? (memq 'loopback provision))) (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 "/sbin/cupsd") ; FIXME #$cups "-s" (default-cups-files-config "/tmp") ; FIXME pass merged datadir ; FIXME "-c" cups config "-f"))) (stop #~(make-kill-destructor)))))))) (define* (cups-service #:key printers (provision '(printing)) ) "Return a printing service that starts cups." (service cups-service-type (cups (printers printers) (provision provision))))