]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/aubergine/printing.nix
aubergine: anki-sync-server: enable
[julm/julm-nix.git] / hosts / aubergine / printing.nix
1 {
2 pkgs,
3 lib,
4 config,
5 ...
6 }:
7 {
8 imports = [
9 ../../nixos/profiles/printing.nix
10 ../../nixos/profiles/hardware/HP_Deskjet_1510.nix
11 ];
12 services.printing = {
13 listenAddresses = [ "*:631" ];
14 defaultShared = true;
15 webInterface = true;
16 allowFrom = [ "all" ];
17 openFirewall = true;
18 browsing = true;
19 extraConf = ''
20 DefaultEncryption IfRequested
21 ServerAlias *
22 '';
23 };
24 # DebugNote: SANE_DEBUG_NET=128 SANE_NET_HOSTS=aubergine.local scanimage -L
25 # DebugNote: SANE_DEBUG_NET=128 SANE_NET_HOSTS=aubergine.local scanimage --dev=net:aubergine.local:hpaio:/usb/Deskjet_1510_series?serial=CN53P2F1N105YR --mode Color --resolution 100 --progress --format jpeg --compression JPEG >out100.jpg
26 services.saned = {
27 enable = true;
28 extraConfig = ''
29 data_portrange = 40000 - 40100
30 0.0.0.0/0
31 '';
32 };
33 systemd.services."saned@" = {
34 #environment.SANE_DEBUG_HPAIO = "128";
35 #environment.SANE_DEBUG_NET = "128";
36 };
37 networking.nftables.ruleset =
38 lib.optionalString config.services.printing.openFirewall ''
39 table inet filter {
40 chain input-lan {
41 tcp dport ipp counter accept comment "cupsd: IPP"
42 }
43 }
44 ''
45 + lib.optionalString config.services.saned.enable ''
46 table inet filter {
47 ct helper conntrack-sane {
48 type "sane" protocol tcp;
49 }
50 chain prerouting {
51 # This will track saned's data port for `ct related`
52 tcp dport sane-port counter ct helper set "conntrack-sane"
53 }
54 chain input-lan {
55 tcp dport sane-port counter accept comment "saned: control port"
56 # NoticeNote: not actually useful because there is a rule `ct related accept` before
57 ct helper "sane" counter accept comment "saned: data ports"
58 }
59 }
60 '';
61 }