From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: cups-service v2 Date: Wed, 23 Mar 2016 10:07:54 +0100 Message-ID: <20160323100754.3798241b@scratchpost.org> References: <20160312191233.48a661ca@scratchpost.org> <8737ruuj0l.fsf@gnu.org> <20160315210512.23989245@scratchpost.org> <20160315221931.16abe3dc@scratchpost.org> <87vb4mygw4.fsf@igalia.com> <87mvpyyfon.fsf@igalia.com> <20160320011904.50131806@scratchpost.org> <20160321230700.452ca6c1@scratchpost.org> <87r3f2ud9x.fsf@igalia.com> <20160322113001.52af072b@scratchpost.org> <87egb2u6gd.fsf@igalia.com> <20160322201207.790bd384@scratchpost.org> <20160323005101.62b537c9@scratchpost.org> <20160323014033.42a019e1@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aieln-0005bH-L8 for guix-devel@gnu.org; Wed, 23 Mar 2016 05:08:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aielk-0004xf-FV for guix-devel@gnu.org; Wed, 23 Mar 2016 05:08:03 -0400 Received: from dd1012.kasserver.com ([85.13.128.8]:44984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aielk-0004xL-5s for guix-devel@gnu.org; Wed, 23 Mar 2016 05:08:00 -0400 In-Reply-To: <20160323014033.42a019e1@scratchpost.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Andy Wingo Cc: guix-devel@gnu.org I think I have most of the parts now. Not sure how to tie them together, th= ough: diff --git a/gnu/services/printing.scm b/gnu/services/printing.scm new file mode 100644 index 0000000..d8f6924 --- /dev/null +++ b/gnu/services/printing.scm @@ -0,0 +1,147 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2013, 2014, 2015 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 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)) + +(define (default-cups-files-config data-dir) + ;; generate cups-files.conf [for cupsd -s ...], especially dynamically s= et 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/1= h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0/share/cups + (string-append "DocumentRoot " /gnu/store/1h53jmsx7gm7b= 2sfk0h0k6bgmp8fhv0i-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" ; FIX= ME + "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 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 th= ere; auth in general? +; TODO support scanners and hpaio thing as sane dll + +;=20 +;=20 +;=20 +; 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 + (($ printers provision cups) + (let ((loopback? (memq 'loopback provision))) + (list + (shepherd-service + (requirement '(udev networking)) ; TODO check actual config and r= educe + (documentation "Bring up printing services.") + (provision provision) + (start #~(make-forkexec-constructor + (list (string-append #$cups "/sbin/cupsd") + "-s" (default-cups-files-config "/tmp") ; FIXME m= erged 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)))) +