-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
ipp-usb.nix
63 lines (59 loc) · 2.07 KB
/
ipp-usb.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ config, lib, pkgs, ... }: {
options = {
services.ipp-usb = {
enable = lib.mkEnableOption (lib.mdDoc "ipp-usb, a daemon to turn an USB printer/scanner supporting IPP everywhere (aka AirPrint, WSD, AirScan) into a locally accessible network printer/scanner");
};
};
config = lib.mkIf config.services.ipp-usb.enable {
systemd.services.ipp-usb = {
description = "Daemon for IPP over USB printer support";
after = [ "cups.service" "avahi-daemon.service" ];
wants = [ "avahi-daemon.service" ];
serviceConfig = {
ExecStart = [ "${pkgs.ipp-usb}/bin/ipp-usb" ];
Type = "simple";
Restart = "on-failure";
StateDirectory = "ipp-usb";
LogsDirectory = "ipp-usb";
# hardening.
ProtectHome = true;
PrivateTmp = true;
PrivateUsers = true;
ProtectControlGroups = true;
MemoryDenyWriteExecute = true;
# breaks the daemon, presumably because it messes with DeviceAllow
ProtectClock = false;
ProtectKernelTunables = true;
ProtectKernelLogs = true;
ProtectSystem = "strict";
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
PrivateMounts = true;
ProtectHostname = true;
ProtectKernelModules = true;
RemoveIPC = true;
RestrictNamespaces = true;
AmbientCapabilities = "";
CapabilityBoundingSet = "";
NoNewPrivileges = true;
RestrictAddressFamilies = [ "AF_UNIX" "AF_NETLINK" "AF_INET" "AF_INET6" ];
ProtectProc = "noaccess";
};
};
# starts the systemd service
services.udev.packages = [ pkgs.ipp-usb ];
services.avahi = {
enable = true;
publish = {
enable = true;
userServices = true;
};
};
# enable printing and scanning by default, but not required.
services.printing.enable = lib.mkDefault true;
hardware.sane.enable = lib.mkDefault true;
# so that sane discovers scanners
hardware.sane.extraBackends = [ pkgs.sane-airscan ];
};
}