diff --git a/system/options.nix b/system/options.nix index f70abacc359..91cd0c78a7d 100644 --- a/system/options.nix +++ b/system/options.nix @@ -479,18 +479,6 @@ in }; - printing = { - - enable = mkOption { - default = false; - description = " - Whether to enable printing support through the CUPS daemon. - "; - }; - - }; - - udev = { addFirmware = mkOption { @@ -1026,6 +1014,7 @@ in (import ../upstart-jobs/httpd.nix) # Apache httpd (probably this can be removed ?) (import ../upstart-jobs/apache-httpd) # Apache httpd (new style). (import ../upstart-jobs/vsftpd.nix) + (import ../upstart-jobs/cupsd.nix) # CUPS printing daemon # nix (import ../upstart-jobs/nix.nix) # nix options and daemon diff --git a/upstart-jobs/cupsd.nix b/upstart-jobs/cupsd.nix index ced164a1308..7f5529e6f75 100644 --- a/upstart-jobs/cupsd.nix +++ b/upstart-jobs/cupsd.nix @@ -1,4 +1,26 @@ -{config, pkgs, modprobe}: +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption mkIf; + + options = { + services = { + printing = { + + enable = mkOption { + default = false; + description = " + Whether to enable printing support through the CUPS daemon. + "; + }; + + }; + }; + }; +in + +###### implementation let @@ -7,6 +29,8 @@ let inherit (pkgs) cups; + modprobe = config.system.sbin.modprobe; + # Here we can enable additional backends, filters, etc. that are not # part of CUPS itself, e.g. the SMB backend is part of Samba. Since @@ -101,37 +125,45 @@ let in -{ - name = "cupsd"; - extraPath = [cups]; - - extraEtc = [ - # CUPS expects the following files in its ServerRoot. - { source = "${cups}/etc/cups/mime.convs"; - target = "cups/mime.convs"; - } - { source = "${cups}/etc/cups/mime.types"; - target = "cups/mime.types"; - } +mkIf config.services.pulseaudio.enable { + require = [ + options ]; - - job = '' - description "CUPS printing daemon" - start on network-interfaces/started - stop on network-interfaces/stop + services = { + extraJobs = [{ + name = "cupsd"; - start script - mkdir -m 0755 -p ${logDir} - mkdir -m 0700 -p /var/cache/cups - mkdir -m 0700 -p /var/spool/cups + extraPath = [cups]; - # Make USB printers show up. - ${modprobe}/sbin/modprobe usblp || true - end script + extraEtc = [ + # CUPS expects the following files in its ServerRoot. + { source = "${cups}/etc/cups/mime.convs"; + target = "cups/mime.convs"; + } + { source = "${cups}/etc/cups/mime.types"; + target = "cups/mime.types"; + } + ]; + + job = '' + description "CUPS printing daemon" - respawn ${cups}/sbin/cupsd -c ${cupsdConfig} -F - ''; - + start on network-interfaces/started + stop on network-interfaces/stop + + start script + mkdir -m 0755 -p ${logDir} + mkdir -m 0700 -p /var/cache/cups + mkdir -m 0700 -p /var/spool/cups + + # Make USB printers show up. + ${modprobe}/sbin/modprobe usblp || true + end script + + respawn ${cups}/sbin/cupsd -c ${cupsdConfig} -F + ''; + }]; + }; } diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 1ca038c9221..e185b5a444b 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -166,12 +166,6 @@ let inherit (pkgs) glibc samba; }) - # CUPS (printing) daemon. - ++ optional config.services.printing.enable - (import ../upstart-jobs/cupsd.nix { - inherit config pkgs modprobe; - }) - # X Font Server ++ optional config.services.xfs.enable (import ../upstart-jobs/xfs.nix {