10 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";
13 config = lib.mkIf config.services.ipp-usb.enable {
14 systemd.services.ipp-usb = {
15 description = "Daemon for IPP over USB printer support";
18 "avahi-daemon.service"
20 wants = [ "avahi-daemon.service" ];
22 ExecStart = [ "${pkgs.ipp-usb}/bin/ipp-usb" ];
24 Restart = "on-failure";
25 StateDirectory = "ipp-usb";
26 LogsDirectory = "ipp-usb";
32 ProtectControlGroups = true;
33 MemoryDenyWriteExecute = true;
34 # breaks the daemon, presumably because it messes with DeviceAllow
36 ProtectKernelTunables = true;
37 ProtectKernelLogs = true;
38 ProtectSystem = "strict";
39 RestrictRealtime = true;
40 RestrictSUIDSGID = true;
41 SystemCallArchitectures = "native";
43 ProtectHostname = true;
44 ProtectKernelModules = true;
46 RestrictNamespaces = true;
47 AmbientCapabilities = "";
48 CapabilityBoundingSet = "";
49 NoNewPrivileges = true;
50 RestrictAddressFamilies = [
56 ProtectProc = "noaccess";
60 # starts the systemd service
61 services.udev.packages = [ pkgs.ipp-usb ];
69 # enable printing and scanning by default, but not required.
70 services.printing.enable = lib.mkDefault true;
71 hardware.sane.enable = lib.mkDefault true;
72 # so that sane discovers scanners
73 hardware.sane.extraBackends = [ pkgs.sane-airscan ];