blob: 30c6962a016b8a648512d30c626028475320b7ef (
plain)
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
|
{ config, lib, ... }:
with lib; let
cfg = config.local.hardware.printing;
inherit (config.local.net) dhcpInterface;
in
{
options.local.hardware.printing = {
enable = mkEnableOption "print and scan services";
users = mkOption {
type = with types; listOf str;
default = [ ];
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = config.local.net.enable;
message = "Printing requires net";
}
];
services.avahi = {
enable = true;
nssmdns4 = true;
# Abre 5353 en todas las interfaces (!!!)
openFirewall = false;
};
hardware.sane.enable = true;
networking.firewall.interfaces = mkIf (dhcpInterface != null) {
${dhcpInterface}.allowedUDPPorts = [ 5353 ];
};
services.printing.enable = true;
users.users = listToAttrs (map
(user: {
name = user;
value.extraGroups = [ "scanner" "lp" ];
})
cfg.users);
};
}
|