diff options
Diffstat (limited to 'hosts/vidhar/printing/default.nix')
-rw-r--r-- | hosts/vidhar/printing/default.nix | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/hosts/vidhar/printing/default.nix b/hosts/vidhar/printing/default.nix new file mode 100644 index 00000000..0e0dfcf7 --- /dev/null +++ b/hosts/vidhar/printing/default.nix | |||
@@ -0,0 +1,124 @@ | |||
1 | { config, lib, ... }: | ||
2 | |||
3 | with lib; | ||
4 | |||
5 | let | ||
6 | containerConfig = config.containers.printing.config; | ||
7 | in { | ||
8 | config = { | ||
9 | containers.printing = { | ||
10 | privateNetwork = true; | ||
11 | ephemeral = true; | ||
12 | autoStart = true; | ||
13 | hostAddress = "10.141.4.0"; | ||
14 | hostAddress6 = "2a03:4000:52:ada:4::"; | ||
15 | localAddress = "10.141.4.1"; | ||
16 | localAddress6 = "2a03:4000:52:ada:4::1"; | ||
17 | interfaces = [ "printer" ]; | ||
18 | config = let | ||
19 | hostConfig = config; | ||
20 | in { ... }: { | ||
21 | config = { | ||
22 | services = { | ||
23 | kea = { | ||
24 | dhcp4 = { | ||
25 | enable = true; | ||
26 | settings = { | ||
27 | valid-lifetime = 4000; | ||
28 | rebind-timer = 2000; | ||
29 | renew-timer = 1000; | ||
30 | |||
31 | interfaces-config = { | ||
32 | interfaces = [ "printer" ]; | ||
33 | }; | ||
34 | |||
35 | lease-database = { | ||
36 | name = "/var/lib/kea/dhcp4.leases"; | ||
37 | persist = true; | ||
38 | type = "memfile"; | ||
39 | }; | ||
40 | |||
41 | subnet4 = [ | ||
42 | { subnet = "10.141.3.0/24"; | ||
43 | option-data = [ | ||
44 | { name = "domain-name-servers"; | ||
45 | data = "10.141.4.0"; | ||
46 | } | ||
47 | { name = "ntp-servers"; | ||
48 | data = "10.141.4.0"; | ||
49 | } | ||
50 | { name = "broadcast-address"; | ||
51 | data = "10.141.3.255"; | ||
52 | } | ||
53 | { name = "routers"; | ||
54 | data = "10.141.3.1"; | ||
55 | } | ||
56 | { name = "domain-name"; | ||
57 | data = "yggdrasil"; | ||
58 | } | ||
59 | { name = "domain-search"; | ||
60 | data = "printer.yggdrasil, yggdrasil"; | ||
61 | } | ||
62 | ]; | ||
63 | pools = [ { pool = "10.141.3.128 - 10.141.3.254"; } ]; | ||
64 | reservations = [ | ||
65 | { hostname = "printer"; | ||
66 | hw-address = "30:cd:a7:b0:55:8d"; | ||
67 | ip-address = "10.141.3.2"; | ||
68 | } | ||
69 | ]; | ||
70 | } | ||
71 | ]; | ||
72 | }; | ||
73 | }; | ||
74 | }; | ||
75 | |||
76 | printing = { | ||
77 | enable = true; | ||
78 | listenAddresses = [ | ||
79 | "*:631" | ||
80 | ]; | ||
81 | allowFrom = [ "all" ]; | ||
82 | extraConf = '' | ||
83 | ServerName printing | ||
84 | ServerAlias 10.141.4.1 2a03:4000:52:ada:4::1 printing.vidhar.yggdrasil printing.vidhar.lan.yggdrasil | ||
85 | ''; | ||
86 | }; | ||
87 | |||
88 | resolved.enable = false; | ||
89 | }; | ||
90 | |||
91 | networking = { | ||
92 | firewall.enable = false; | ||
93 | nftables = { | ||
94 | enable = true; | ||
95 | rulesetFile = ./ruleset.nft; | ||
96 | }; | ||
97 | |||
98 | useDHCP = false; | ||
99 | useNetworkd = true; | ||
100 | |||
101 | interfaces."printer" = { | ||
102 | ipv4.addresses = [ | ||
103 | { address = "10.141.3.1"; prefixLength = 24; } | ||
104 | ]; | ||
105 | }; | ||
106 | }; | ||
107 | |||
108 | environment.etc."resolv.conf".text = '' | ||
109 | nameserver ${hostConfig.containers.printing.hostAddress6} | ||
110 | ''; | ||
111 | |||
112 | system.stateVersion = hostConfig.system.stateVersion; | ||
113 | }; | ||
114 | }; | ||
115 | }; | ||
116 | |||
117 | networking = { | ||
118 | vlans.printer = { | ||
119 | id = 5; | ||
120 | interface = "eno2"; | ||
121 | }; | ||
122 | }; | ||
123 | }; | ||
124 | } | ||