1 { config, lib, pkgs, ... }: {
4 enable = lib.mkEnableOption "ipp-usb, a daemon to turn an USB printer/scanner supporting IPP everywhere (aka AirPrint, WSD, AirScan) into a locally accessible network printer/scanner";
7 config = lib.mkIf config.services.ipp-usb.enable {
8 systemd.services.ipp-usb = {
9 description = "Daemon for IPP over USB printer support";
10 after = [ "cups.service" "avahi-daemon.service" ];
11 wants = [ "avahi-daemon.service" ];
13 ExecStart = [ "${pkgs.ipp-usb}/bin/ipp-usb" ];
15 Restart = "on-failure";
16 StateDirectory = "ipp-usb";
17 LogsDirectory = "ipp-usb";
23 ProtectControlGroups = true;
24 MemoryDenyWriteExecute = true;
25 # breaks the daemon, presumably because it messes with DeviceAllow
27 ProtectKernelTunables = true;
28 ProtectKernelLogs = true;
29 ProtectSystem = "strict";
30 RestrictRealtime = true;
31 RestrictSUIDSGID = true;
32 SystemCallArchitectures = "native";
34 ProtectHostname = true;
35 ProtectKernelModules = true;
37 RestrictNamespaces = true;
38 AmbientCapabilities = "";
39 CapabilityBoundingSet = "";
40 NoNewPrivileges = true;
41 RestrictAddressFamilies = [ "AF_UNIX" "AF_NETLINK" "AF_INET" "AF_INET6" ];
42 ProtectProc = "noaccess";
46 # starts the systemd service
47 services.udev.packages = [ pkgs.ipp-usb ];
55 # enable printing and scanning by default, but not required.
56 services.printing.enable = lib.mkDefault true;
57 hardware.sane.enable = lib.mkDefault true;
58 # so that sane discovers scanners
59 hardware.sane.extraBackends = [ pkgs.sane-airscan ];