diff options
Diffstat (limited to 'hosts/vidhar')
-rw-r--r-- | hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml | 19 | ||||
-rw-r--r-- | hosts/vidhar/audiobookshelf/default.nix | 21 | ||||
-rw-r--r-- | hosts/vidhar/default.nix | 4 | ||||
-rw-r--r-- | hosts/vidhar/hledger/default.nix | 83 | ||||
-rw-r--r-- | hosts/vidhar/hledger/htpasswd | 24 | ||||
-rw-r--r-- | hosts/vidhar/immich.nix | 10 | ||||
-rw-r--r-- | hosts/vidhar/kimai/default.nix | 89 | ||||
-rw-r--r-- | hosts/vidhar/kimai/ruleset.nft | 149 | ||||
-rw-r--r-- | hosts/vidhar/network/default.nix | 9 | ||||
-rw-r--r-- | hosts/vidhar/network/dhcp/default.nix | 221 | ||||
-rw-r--r-- | hosts/vidhar/network/ruleset.nft | 31 | ||||
-rw-r--r-- | hosts/vidhar/paperless/default.nix | 25 | ||||
-rw-r--r-- | hosts/vidhar/paperless/rootpw | 24 | ||||
-rw-r--r-- | hosts/vidhar/pgbackrest/default.nix | 9 | ||||
-rw-r--r-- | hosts/vidhar/postgresql.nix | 36 | ||||
-rw-r--r-- | hosts/vidhar/prometheus/default.nix | 3 | ||||
-rw-r--r-- | hosts/vidhar/zfs.nix | 2 |
17 files changed, 698 insertions, 61 deletions
diff --git a/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml b/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml new file mode 100644 index 00000000..a5319e38 --- /dev/null +++ b/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml | |||
@@ -0,0 +1,19 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:60OmHwuLC7RJVNNn8lsCFjIFrtDlmmT3yAm3DYn/K2b8OJB/lzKBhMUCyPpoI2lfMm6y47/DMwXI3ExH3QwfgGRf4i/Tcv7p6FCkjFgDc0RhAM7cXNSnh1gKTff8QYtPoNIzmycFCThNr7iZsPsf2/1npVaVHTnt9nTc+cmDLc+lELlvjSE00JOXch/if7KPwFww9K83XlrFmoRvwybfXR0unJqxK2XLvj+dQuKD4Bhyb88iSgu4dX1yw2uBSZBD16S4Io0DaZ+as5Yw4Kon7WMj3Jd5kz8ZxK+0NCy1CVJHOfJIwgYl0SVPp4DpbAPtJO4R/ciXyDQ/XGpoLtHjxnKXaJlJoSiA7FhuSEk+jB/peLHrYV1obdIRE5Dstly01S5cydKlfQ+A0TSjxFSWBYMEiD89sD09Br3iSJX5FejOoS8d2IQJ5faVzgQl4T5aBKsxCNNwmYrEe8m9HN7o2eer8nTKMln5IxZi3ZWhnjgJfrJ4QTXFndxCb78jo8HroN3+7VhoM136UZkqH1OMrIgAH/XSlW08G8m9MRamKsAWklq9aVflcEsPWTHmYW7rjAapQYf+jyK6BbfHcYmyKM82TFZ5iNB60Pth6EJgb2V8PZiChGvDzQvFYYOO3p9a/J8bVqsnPZBXXYcIBt42ZuRPvyyUTfM+75V1eYE9ZGFML+QlofwNCAg+/Rnl+RRy4z+8xQxd8Dn06geDpHsr4yND72FRUTKLbjxF5xfbzBRcZEXjGkyFdEAF7rB78I8xIqii+n6Yt8uEURmd4geI9KWXRQnwofTz9pklaAnRbER8zy/BJIiIYy8zecUHJn9v/DPnsnksfL6RRmG4tHaRBDbpAag0kVkCrpO/flK6dZOl/wvoVVVqT2O69a9/RpHLSV2f//ZS6L9s6vaYe4pXL0M6QymgA22sNHaws6XggJlTxVOFGRejMGYrKqVWtC+2UNbnel+/J0N1qj4luWfQaf9+1j+fq7vyLSzXYFCiyOLAznpqOhzKu6VWy2IbR0UnCoL5ZbhIba9e2MXM7Czy9Yee4xc=,iv:M0GbtFFl1XUeq+y9H+MiD+9z/ASB9hsd06KhpPzSwEo=,tag:vTLIIf+CeZN6DU25CSP8tw==,type:str]", | ||
3 | "sops": { | ||
4 | "age": [ | ||
5 | { | ||
6 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
7 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0aE1XNUNCM1Q5V0d3R2JG\nbjJZTmdvQ21JbmtyR0ZmODFMdVBGejRoam1vCjMzMGdTb3BReDVCa2JJU0JrSHFP\ndTdicU5TRjIrTWpteDMzeGtDT0xaelkKLS0tIFhaSlFrbzFDUjRZV0lGR0cydVdZ\nY2xma0VSVXlTM1JucFJUSys4dlRvdEUK9gQNQEdKDDf1ikWzd6uTlE50WsfO/EB0\nGH2Ono6oNWbKWTyl/wRO8NzXx0nudwqq66s0oBLIdTMQOpIBBNI0XQ==\n-----END AGE ENCRYPTED FILE-----\n" | ||
8 | }, | ||
9 | { | ||
10 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBiRWFqSHNlY1IvMkkwaEto\ncHZHa2p1Y25SakFkS2JYMlRFcFhnZGY1dVRFCkxSWmxvcHZMampQKzdKRHI0ZVMx\nUTFtR0pHbzFaQ0xQUFA2ZERDSWpwS0UKLS0tIFBaSGczY3VWdy9TKzRDZWZ2SElY\nbVQ4dDNhQllmVmViWGs5c3V4TmNscjQKeugevQJFAN/8JrzeAm4hm2JsQGb26BCb\n3dKYnN1kJU7oVHr1aVfXwMpELNYt9poX6WTY2h9lsdHuRlqoFXAA5Q==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | } | ||
13 | ], | ||
14 | "lastmodified": "2025-05-10T10:25:15Z", | ||
15 | "mac": "ENC[AES256_GCM,data:dhj7e+vF3uiR6I22PR5tdNdM8EyrWmGGTIqjj8H7IdNIsZBHzjeHlBDFOwN7z/JMO0BVwIi4DmhApg2BSPGsQZGDQZ28UTCC8TDtd1zmfGtSP8R8AFHADYdLK/desMtHg6BZTnLv5tpba34WWdflMNOQpwgWPZsIk/DkLaoXdvk=,iv:qkoAZngTz2sfWdxDs+h8Mb2IrkF8gqnQoR5iRoeKjbY=,tag:zXrkBJmPM4ItJxMnX8IDxQ==,type:str]", | ||
16 | "unencrypted_suffix": "_unencrypted", | ||
17 | "version": "3.10.2" | ||
18 | } | ||
19 | } | ||
diff --git a/hosts/vidhar/audiobookshelf/default.nix b/hosts/vidhar/audiobookshelf/default.nix new file mode 100644 index 00000000..136bcaff --- /dev/null +++ b/hosts/vidhar/audiobookshelf/default.nix | |||
@@ -0,0 +1,21 @@ | |||
1 | { config, pkgs, lib, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | services.audiobookshelf = { | ||
6 | enable = true; | ||
7 | host = "2a03:4000:52:ada:4:1::"; | ||
8 | port = 28982; | ||
9 | }; | ||
10 | |||
11 | users.groups.audiobookshelf.members = [ "gkleen" ]; | ||
12 | |||
13 | services.abs-podcast-autoplaylist = { | ||
14 | gkleen = {}; | ||
15 | }; | ||
16 | sops.secrets.${config.services.abs-podcast-autoplaylist.gkleen.configSecret} = { | ||
17 | format = "binary"; | ||
18 | sopsFile = ./abs-podcast-autoplaylist-gkleen.toml; | ||
19 | }; | ||
20 | }; | ||
21 | } | ||
diff --git a/hosts/vidhar/default.nix b/hosts/vidhar/default.nix index 42a9e80d..7da17e6f 100644 --- a/hosts/vidhar/default.nix +++ b/hosts/vidhar/default.nix | |||
@@ -4,7 +4,7 @@ with lib; | |||
4 | 4 | ||
5 | { | 5 | { |
6 | imports = with flake.nixosModules.systemProfiles; [ | 6 | imports = with flake.nixosModules.systemProfiles; [ |
7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest | 7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest ./postgresql.nix ./immich.nix ./paperless ./hledger ./audiobookshelf ./kimai |
8 | tmpfs-root zfs | 8 | tmpfs-root zfs |
9 | initrd-all-crypto-modules default-locale openssh rebuild-machines | 9 | initrd-all-crypto-modules default-locale openssh rebuild-machines |
10 | build-server | 10 | build-server |
@@ -136,7 +136,7 @@ with lib; | |||
136 | wantedBy = ["basic.target"]; | 136 | wantedBy = ["basic.target"]; |
137 | serviceConfig = { | 137 | serviceConfig = { |
138 | ExecStart = pkgs.writeShellScript "limit-pstate-start" '' | 138 | ExecStart = pkgs.writeShellScript "limit-pstate-start" '' |
139 | echo 60 > /sys/devices/system/cpu/intel_pstate/max_perf_pct | 139 | echo 50 > /sys/devices/system/cpu/intel_pstate/max_perf_pct |
140 | ''; | 140 | ''; |
141 | RemainAfterExit = true; | 141 | RemainAfterExit = true; |
142 | ExecStop = pkgs.writeShellScript "limit-pstate-stop" '' | 142 | ExecStop = pkgs.writeShellScript "limit-pstate-stop" '' |
diff --git a/hosts/vidhar/hledger/default.nix b/hosts/vidhar/hledger/default.nix new file mode 100644 index 00000000..ae080f66 --- /dev/null +++ b/hosts/vidhar/hledger/default.nix | |||
@@ -0,0 +1,83 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | services.hledger-web = { | ||
5 | enable = true; | ||
6 | allow = "view"; | ||
7 | stateDir = "/var/lib/hledger"; | ||
8 | journalFiles = lib.mkForce ["web.journal"]; | ||
9 | baseUrl = "https://hledger.yggdrasil.li"; | ||
10 | extraOptions = [ | ||
11 | "--socket=/run/hledger-web/http.sock" | ||
12 | ]; | ||
13 | }; | ||
14 | users = { | ||
15 | users.hledger.uid = 982; | ||
16 | groups.hledger.gid = 979; | ||
17 | }; | ||
18 | systemd.services.hledger-web = { | ||
19 | serviceConfig = { | ||
20 | UMask = "0002"; | ||
21 | ReadOnlyPaths = [ config.services.hledger-web.stateDir ]; | ||
22 | RuntimeDirectory = [ "hledger-web" ]; | ||
23 | PrivateDevices = true; | ||
24 | StateDirectory = "hledger"; | ||
25 | CapabilityBoundingSet = ""; | ||
26 | AmbientCapabilities = ""; | ||
27 | ProtectSystem = "strict"; | ||
28 | ProtectKernelTunables = true; | ||
29 | ProtectKernelModules = true; | ||
30 | ProtectControlGroups = true; | ||
31 | ProtectClock = true; | ||
32 | ProtectHostname = true; | ||
33 | ProtectHome = "tmpfs"; | ||
34 | ProtectKernelLogs = true; | ||
35 | ProtectProc = "invisible"; | ||
36 | ProcSubset = "pid"; | ||
37 | PrivateNetwork = false; | ||
38 | RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX"; | ||
39 | SystemCallArchitectures = "native"; | ||
40 | SystemCallFilter = [ | ||
41 | "@system-service @resources" | ||
42 | "~@obsolete @privileged" | ||
43 | ]; | ||
44 | RestrictSUIDSGID = true; | ||
45 | RemoveIPC = true; | ||
46 | NoNewPrivileges = true; | ||
47 | RestrictRealtime = true; | ||
48 | RestrictNamespaces = true; | ||
49 | LockPersonality = true; | ||
50 | PrivateUsers = true; | ||
51 | TemporaryFileSystem = [ "/var/lib/hledger/.cache:mode=0750,uid=${toString (config.users.users.hledger.uid)},gid=${toString (config.users.groups.hledger.gid)}" ]; | ||
52 | }; | ||
53 | }; | ||
54 | services.nginx = { | ||
55 | upstreams.hledger = { | ||
56 | servers = { "unix:/run/hledger-web/http.sock" = {}; }; | ||
57 | }; | ||
58 | virtualHosts."hledger.yggdrasil.li" = { | ||
59 | listen = [ | ||
60 | { addr = "[2a03:4000:52:ada:4:1::]"; port = 5000; } | ||
61 | ]; | ||
62 | extraConfig = '' | ||
63 | set_real_ip_from 2a03:4000:52:ada:4::; | ||
64 | auth_basic "hledger"; | ||
65 | auth_basic_user_file "/run/credentials/nginx.service/hledger_users"; | ||
66 | ''; | ||
67 | locations."/" = { | ||
68 | proxyPass = "http://hledger/"; | ||
69 | proxyWebsockets = true; | ||
70 | }; | ||
71 | }; | ||
72 | }; | ||
73 | systemd.services.nginx.serviceConfig = { | ||
74 | SupplementaryGroups = [ "hledger" ]; | ||
75 | LoadCredential = [ "hledger_users:${config.sops.secrets."hledger_users".path}" ]; | ||
76 | }; | ||
77 | sops.secrets."hledger_users" = { | ||
78 | format = "binary"; | ||
79 | sopsFile = ./htpasswd; | ||
80 | reloadUnits = [ "nginx.service" ]; | ||
81 | }; | ||
82 | }; | ||
83 | } | ||
diff --git a/hosts/vidhar/hledger/htpasswd b/hosts/vidhar/hledger/htpasswd new file mode 100644 index 00000000..016cb525 --- /dev/null +++ b/hosts/vidhar/hledger/htpasswd | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:9MNDIAc7ePYk3xQDorX2pU8ybJkJb33RKiJxc2DYauXFNQYxtGwCYhZwod7p7fPh3KqZxBNMRoZXr+/RnV+trsqjAcOOjnXTWLbX6nubq/xm+q0BxEjOPn7FvJF9XOblBeupldo+byGh2CMH9qQv5Fov,iv:3Tym+Mfr48OJet3qDFZPg0XjYr4sNQdNdiu0vUxmzbY=,tag:E0sxRY/jeMVlqH6uAYvD/Q==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA3eFBsOEM2ZUNVT2V3LytC\nTUJvUDdKc0VzMyt2cDFKYU03djBjZVFpeVY4CjByMXhPVXRJVjhKQWZvQ2xuOTE3\ncXdJV1lZaHR3cVl0Z0hQaG00M2dGbjQKLS0tIEIzenVxb3cwM3pXTUl1YUZlSlk2\nbDc3VmE5NkEyZ2tRd01OUGZibmhtUlEKxdesIdvzm8s0SmXU5R+tSbmS5Dj24jrb\nEiMERYy1g8GyHR3d2/mU5iOIdsBegSZReUVzomaMT9L7/TmubgOP3g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBPa2RDZzR6cEFYTFA1QkND\nbndVeHVrMVJ0MWZvRmw5VXRhOHlRYllIRWxRCjU4dks4R25LS1RZMHFnbmpQRVZz\nNXhubkJvZFc2amRwMDVtQlE0NnBKNzQKLS0tIHRyeDUxTEFPMEMzWUVkZURzODdm\nSHdqbUpvNmFTS1QveFRpRHdnWHpHb28KnvdUkMkKGiBVHQD7Yv7n6WZjihCGJAR2\nMKl2WAn4g4jzgcXPwwIAIjUrMGSIdGpwCTUDcDnlKWAbRYO2B6P17A==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-19T17:11:17Z", | ||
19 | "mac": "ENC[AES256_GCM,data:yBIEqHhr4igoMlRcgg2SigKfejqeuNmuleYolsLJo+QOaW4BHITJTvLxRV1JHPpcMVQkF//zx4ZfUUrb8tTN0znGu3Jnpd0JVagbfCVyEuT6d1SB/GzyUVvoQ2GlcA9us+5gjI4oEJTQCfVqnLDBWsw+jXdr3nEIWo6Mvbqo3lI=,iv:I6Swk4wyd+96+tJKRY/FHlS7ZShMDROcbl+l+ZLRxhM=,tag:P1uQvB4NLdkPEKRMI6lLxw==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/vidhar/immich.nix b/hosts/vidhar/immich.nix new file mode 100644 index 00000000..a1f145a8 --- /dev/null +++ b/hosts/vidhar/immich.nix | |||
@@ -0,0 +1,10 @@ | |||
1 | { ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | services.immich = { | ||
6 | enable = true; | ||
7 | host = "2a03:4000:52:ada:4:1::"; | ||
8 | }; | ||
9 | }; | ||
10 | } | ||
diff --git a/hosts/vidhar/kimai/default.nix b/hosts/vidhar/kimai/default.nix new file mode 100644 index 00000000..0258697b --- /dev/null +++ b/hosts/vidhar/kimai/default.nix | |||
@@ -0,0 +1,89 @@ | |||
1 | { flake, config, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | boot.enableContainers = true; | ||
6 | boot.kernel.sysctl = { | ||
7 | "net.netfilter.nf_log_all_netns" = true; | ||
8 | }; | ||
9 | |||
10 | containers."kimai" = { | ||
11 | autoStart = true; | ||
12 | ephemeral = true; | ||
13 | bindMounts = { | ||
14 | "/var/lib/kimai" = { | ||
15 | hostPath = "/var/lib/kimai/state"; | ||
16 | isReadOnly = false; | ||
17 | }; | ||
18 | "/var/lib/mysql" = { | ||
19 | hostPath = "/var/lib/kimai/mysql"; | ||
20 | isReadOnly = false; | ||
21 | }; | ||
22 | }; | ||
23 | privateNetwork = true; | ||
24 | # forwardPorts = [ | ||
25 | # { containerPort = 80; | ||
26 | # hostPort = 28983; | ||
27 | # } | ||
28 | # ]; | ||
29 | hostAddress = "192.168.52.113"; | ||
30 | localAddress = "192.168.52.114"; | ||
31 | hostAddress6 = "2a03:4000:52:ada:6::1"; | ||
32 | localAddress6 = "2a03:4000:52:ada:6::2"; | ||
33 | config = let hostConfig = config; in { config, pkgs, lib, ... }: { | ||
34 | system.stateVersion = lib.mkIf hostConfig.containers."kimai".ephemeral config.system.nixos.release; | ||
35 | system.configurationRevision = lib.mkIf (flake ? rev) flake.rev; | ||
36 | nixpkgs.pkgs = hostConfig.nixpkgs.pkgs; | ||
37 | |||
38 | services.kimai.sites."kimai.yggdrasil.li" = { | ||
39 | database.socket = "/run/mysqld/mysqld.sock"; | ||
40 | }; | ||
41 | |||
42 | networking = { | ||
43 | useDHCP = false; | ||
44 | useNetworkd = true; | ||
45 | useHostResolvConf = false; | ||
46 | firewall.enable = false; | ||
47 | nftables = { | ||
48 | enable = true; | ||
49 | rulesetFile = ./ruleset.nft; | ||
50 | }; | ||
51 | }; | ||
52 | |||
53 | services.resolved.fallbackDns = [ | ||
54 | "9.9.9.10#dns10.quad9.net" | ||
55 | "149.112.112.10#dns10.quad9.net" | ||
56 | "2620:fe::10#dns10.quad9.net" | ||
57 | "2620:fe::fe:10#dns10.quad9.net" | ||
58 | ]; | ||
59 | |||
60 | systemd.network = { | ||
61 | networks.upstream = { | ||
62 | name = "eth0"; | ||
63 | matchConfig = { | ||
64 | Name = "eth0"; | ||
65 | }; | ||
66 | linkConfig = { | ||
67 | RequiredForOnline = true; | ||
68 | }; | ||
69 | networkConfig = { | ||
70 | Address = [ "192.168.52.114/32" "2a03:4000:52:ada:6::2/128" ]; | ||
71 | LLMNR = false; | ||
72 | MulticastDNS = false; | ||
73 | }; | ||
74 | routes = [ | ||
75 | { Destination = "192.168.52.113/32"; } | ||
76 | { Destination = "2a03:4000:52:ada:6::1/128"; } | ||
77 | { Destination = "0.0.0.0/0"; | ||
78 | Gateway = "192.168.52.113"; | ||
79 | } | ||
80 | { Destination = "::/0"; | ||
81 | Gateway = "2a03:4000:52:ada:6::1"; | ||
82 | } | ||
83 | ]; | ||
84 | }; | ||
85 | }; | ||
86 | }; | ||
87 | }; | ||
88 | }; | ||
89 | } | ||
diff --git a/hosts/vidhar/kimai/ruleset.nft b/hosts/vidhar/kimai/ruleset.nft new file mode 100644 index 00000000..ad4db6d5 --- /dev/null +++ b/hosts/vidhar/kimai/ruleset.nft | |||
@@ -0,0 +1,149 @@ | |||
1 | define icmp_protos = {ipv6-icmp, icmp, igmp} | ||
2 | |||
3 | table arp filter { | ||
4 | limit lim_arp { | ||
5 | rate over 50 mbytes/second burst 50 mbytes | ||
6 | } | ||
7 | |||
8 | counter arp-rx {} | ||
9 | counter arp-tx {} | ||
10 | |||
11 | counter arp-ratelimit-rx {} | ||
12 | counter arp-ratelimit-tx {} | ||
13 | |||
14 | chain input { | ||
15 | type filter hook input priority filter | ||
16 | policy accept | ||
17 | |||
18 | limit name lim_arp counter name arp-ratelimit-rx drop | ||
19 | |||
20 | counter name arp-rx | ||
21 | } | ||
22 | |||
23 | chain output { | ||
24 | type filter hook output priority filter | ||
25 | policy accept | ||
26 | |||
27 | limit name lim_arp counter name arp-ratelimit-tx drop | ||
28 | |||
29 | counter name arp-tx | ||
30 | } | ||
31 | } | ||
32 | |||
33 | table inet filter { | ||
34 | limit lim_reject { | ||
35 | rate over 1000/second burst 1000 packets | ||
36 | } | ||
37 | |||
38 | limit lim_icmp { | ||
39 | rate over 50 mbytes/second burst 50 mbytes | ||
40 | } | ||
41 | |||
42 | counter invalid-fw {} | ||
43 | counter fw-lo {} | ||
44 | |||
45 | counter reject-ratelimit-fw {} | ||
46 | counter reject-fw {} | ||
47 | counter reject-tcp-fw {} | ||
48 | counter reject-icmp-fw {} | ||
49 | |||
50 | counter drop-fw {} | ||
51 | |||
52 | counter invalid-rx {} | ||
53 | |||
54 | counter rx-lo {} | ||
55 | counter invalid-local4-rx {} | ||
56 | counter invalid-local6-rx {} | ||
57 | |||
58 | counter icmp-ratelimit-rx {} | ||
59 | counter icmp-rx {} | ||
60 | |||
61 | counter kimai-rx {} | ||
62 | |||
63 | counter established-rx {} | ||
64 | |||
65 | counter reject-ratelimit-rx {} | ||
66 | counter reject-rx {} | ||
67 | counter reject-tcp-rx {} | ||
68 | counter reject-icmp-rx {} | ||
69 | |||
70 | counter drop-rx {} | ||
71 | |||
72 | counter tx-lo {} | ||
73 | |||
74 | counter icmp-ratelimit-tx {} | ||
75 | counter icmp-tx {} | ||
76 | |||
77 | counter kimai-tx {} | ||
78 | |||
79 | counter tx {} | ||
80 | |||
81 | chain forward { | ||
82 | type filter hook forward priority filter | ||
83 | policy drop | ||
84 | |||
85 | |||
86 | ct state invalid log level debug prefix "kimai: drop invalid forward: " counter name invalid-fw drop | ||
87 | |||
88 | |||
89 | iifname lo counter name fw-lo accept | ||
90 | |||
91 | |||
92 | limit name lim_reject log level debug prefix "kimai: drop forward: " counter name reject-ratelimit-fw drop | ||
93 | log level debug prefix "kimai: reject forward: " counter name reject-fw | ||
94 | meta l4proto tcp ct state new counter name reject-tcp-fw reject with tcp reset | ||
95 | ct state new counter name reject-icmp-fw reject | ||
96 | |||
97 | |||
98 | counter name drop-fw | ||
99 | } | ||
100 | |||
101 | chain input { | ||
102 | type filter hook input priority filter | ||
103 | policy drop | ||
104 | |||
105 | |||
106 | ct state invalid log level debug prefix "kimai: drop invalid input: " counter name invalid-rx drop | ||
107 | |||
108 | |||
109 | iifname lo counter name rx-lo accept | ||
110 | iif != lo ip daddr 127.0.0.1/8 counter name invalid-local4-rx reject | ||
111 | iif != lo ip6 daddr ::1/128 counter name invalid-local6-rx reject | ||
112 | |||
113 | |||
114 | meta l4proto $icmp_protos limit name lim_icmp counter name icmp-ratelimit-rx drop | ||
115 | meta l4proto $icmp_protos counter name icmp-rx accept | ||
116 | |||
117 | |||
118 | tcp dport 80 counter name kimai-rx accept | ||
119 | |||
120 | |||
121 | ct state { established, related } counter name established-rx accept | ||
122 | |||
123 | |||
124 | limit name lim_reject log level debug prefix "kimai: drop input: " counter name reject-ratelimit-rx drop | ||
125 | log level debug prefix "kimai: reject input: " counter name reject-rx | ||
126 | meta l4proto tcp ct state new counter name reject-tcp-rx reject with tcp reset | ||
127 | ct state new counter name reject-icmp-rx reject | ||
128 | |||
129 | |||
130 | counter name drop-rx | ||
131 | } | ||
132 | |||
133 | chain output { | ||
134 | type filter hook output priority filter | ||
135 | policy accept | ||
136 | |||
137 | |||
138 | oifname lo counter name tx-lo accept | ||
139 | |||
140 | meta l4proto $icmp_protos limit name lim_icmp counter name icmp-ratelimit-tx drop | ||
141 | meta l4proto $icmp_protos counter name icmp-tx accept | ||
142 | |||
143 | |||
144 | tcp sport 80 counter name kimai-tx | ||
145 | |||
146 | |||
147 | counter name tx | ||
148 | } | ||
149 | } | ||
diff --git a/hosts/vidhar/network/default.nix b/hosts/vidhar/network/default.nix index 0643f0bb..92d755f3 100644 --- a/hosts/vidhar/network/default.nix +++ b/hosts/vidhar/network/default.nix | |||
@@ -103,7 +103,14 @@ with lib; | |||
103 | /srv/nfs/nix-store 10.141.0.0/24(ro,async,root_squash) 2a03:4000:52:ada:1::/80(ro,async,root_squash) | 103 | /srv/nfs/nix-store 10.141.0.0/24(ro,async,root_squash) 2a03:4000:52:ada:1::/80(ro,async,root_squash) |
104 | ''; | 104 | ''; |
105 | }; | 105 | }; |
106 | settings.nfsd.vers3 = false; | 106 | settings.nfsd = { |
107 | rdma = true; | ||
108 | vers3 = false; | ||
109 | vers4 = true; | ||
110 | "vers4.0" = false; | ||
111 | "vers4.1" = false; | ||
112 | "vers4.2" = true; | ||
113 | }; | ||
107 | }; | 114 | }; |
108 | 115 | ||
109 | fileSystems = { | 116 | fileSystems = { |
diff --git a/hosts/vidhar/network/dhcp/default.nix b/hosts/vidhar/network/dhcp/default.nix index 07a83351..11460393 100644 --- a/hosts/vidhar/network/dhcp/default.nix +++ b/hosts/vidhar/network/dhcp/default.nix | |||
@@ -1,8 +1,33 @@ | |||
1 | { flake, config, pkgs, lib, ... }: | 1 | { flake, config, pkgs, lib, sources, ... }: |
2 | 2 | ||
3 | with lib; | 3 | with lib; |
4 | 4 | ||
5 | { | 5 | let |
6 | nfsrootBaseUrl = "http://nfsroot.vidhar.yggdrasil"; | ||
7 | tftpIp = "10.141.0.1"; | ||
8 | nfsIp = tftpIp; | ||
9 | ipxe = pkgs.ipxe.override { | ||
10 | additionalTargets = { | ||
11 | "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; | ||
12 | }; | ||
13 | additionalOptions = [ | ||
14 | "NSLOOKUP_CMD" | ||
15 | "PING_CMD" | ||
16 | "CONSOLE_CMD" | ||
17 | ]; | ||
18 | embedScript = pkgs.writeText "yggdrasil.ipxe" '' | ||
19 | #!ipxe | ||
20 | |||
21 | cpair --background 9 1 | ||
22 | cpair --background 9 3 | ||
23 | cpair --background 9 6 | ||
24 | |||
25 | set user-class iPXE-yggdrasil | ||
26 | |||
27 | autoboot | ||
28 | ''; | ||
29 | }; | ||
30 | in { | ||
6 | config = { | 31 | config = { |
7 | services.kea = { | 32 | services.kea = { |
8 | dhcp4 = { | 33 | dhcp4 = { |
@@ -23,41 +48,67 @@ with lib; | |||
23 | }; | 48 | }; |
24 | 49 | ||
25 | client-classes = [ | 50 | client-classes = [ |
26 | { name = "eostre-ipxe"; | 51 | { name = "ipxe-eostre"; |
27 | test = "hexstring(pkt4.mac, ':') == '00:d8:61:79:c5:40' and option[77].hex == 'iPXE'"; | 52 | test = "hexstring(pkt4.mac, ':') == '00:d8:61:79:c5:40' and option[77].hex == 'iPXE-yggdrasil'"; |
28 | next-server = "10.141.0.1"; | 53 | next-server = tftpIp; |
29 | boot-file-name = "http://nfsroot.vidhar.yggdrasil/eostre/netboot.ipxe"; | 54 | boot-file-name = "${nfsrootBaseUrl}/eostre.menu.ipxe"; |
55 | only-if-required = true; | ||
56 | } | ||
57 | { name = "ipxe-yggdrasil"; | ||
58 | test = "option[77].hex == 'iPXE-yggdrasil'"; | ||
59 | next-server = tftpIp; | ||
60 | boot-file-name = "${nfsrootBaseUrl}/installer-x86_64-linux.menu.ipxe"; | ||
61 | only-if-required = true; | ||
62 | } | ||
63 | |||
64 | { name = "uefi-http"; | ||
65 | test = "option[client-system].hex == 0x0010"; | ||
66 | option-data = [ | ||
67 | { name = "vendor-class-identifier"; data = "HTTPClient"; } | ||
68 | ]; | ||
69 | boot-file-name = "${nfsrootBaseUrl}/ipxe.efi"; | ||
70 | only-if-required = true; | ||
71 | } | ||
72 | |||
73 | { name = "ipxe-uefi-64"; | ||
74 | test = "option[77].hex == 'iPXE' and (substring(option[60].hex,0,20) == 'PXEClient:Arch:00007' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00008' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00009')"; | ||
75 | boot-file-name = "${nfsrootBaseUrl}/ipxe.efi"; | ||
76 | only-if-required = true; | ||
77 | } | ||
78 | { name = "ipxe-uefi-32"; | ||
79 | test = "option[77].hex == 'iPXE' and (substring(option[60].hex,0,20) == 'PXEClient:Arch:00002' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00006')"; | ||
80 | boot-file-name = "${nfsrootBaseUrl}/i386-ipxe.efi"; | ||
30 | only-if-required = true; | 81 | only-if-required = true; |
31 | } | 82 | } |
32 | { name = "ipxe"; | 83 | { name = "ipxe-legacy"; |
33 | test = "option[77].hex == 'iPXE'"; | 84 | test = "option[77].hex == 'iPXE' and substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'"; |
34 | next-server = "10.141.0.1"; | 85 | boot-file-name = "${nfsrootBaseUrl}/ipxe.lkrn"; |
35 | boot-file-name = "http://nfsroot.vidhar.yggdrasil/installer-x86_64-linux/netboot.ipxe"; | ||
36 | only-if-required = true; | 86 | only-if-required = true; |
37 | } | 87 | } |
88 | |||
38 | { name = "uefi-64"; | 89 | { name = "uefi-64"; |
39 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00007' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00008' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00009'"; | 90 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00007' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00008' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00009'"; |
40 | only-if-required = true; | ||
41 | option-data = [ | 91 | option-data = [ |
42 | { name = "tftp-server-name"; data = "10.141.0.1"; } | 92 | { name = "tftp-server-name"; data = tftpIp; } |
43 | ]; | 93 | ]; |
44 | boot-file-name = "ipxe.efi"; | 94 | boot-file-name = "ipxe.efi"; |
95 | only-if-required = true; | ||
45 | } | 96 | } |
46 | { name = "uefi-32"; | 97 | { name = "uefi-32"; |
47 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00002' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00006'"; | 98 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00002' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00006'"; |
48 | only-if-required = true; | ||
49 | option-data = [ | 99 | option-data = [ |
50 | { name = "tftp-server-name"; data = "10.141.0.1"; } | 100 | { name = "tftp-server-name"; data = tftpIp; } |
51 | ]; | 101 | ]; |
52 | boot-file-name = "i386-ipxe.efi"; | 102 | boot-file-name = "i386-ipxe.efi"; |
103 | only-if-required = true; | ||
53 | } | 104 | } |
54 | { name = "legacy"; | 105 | { name = "legacy"; |
55 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'"; | 106 | test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'"; |
56 | only-if-required = true; | ||
57 | option-data = [ | 107 | option-data = [ |
58 | { name = "tftp-server-name"; data = "10.141.0.1"; } | 108 | { name = "tftp-server-name"; data = tftpIp; } |
59 | ]; | 109 | ]; |
60 | boot-file-name = "undionly.kpxe"; | 110 | boot-file-name = "ipxe.lkrn"; |
111 | only-if-required = true; | ||
61 | } | 112 | } |
62 | ]; | 113 | ]; |
63 | 114 | ||
@@ -252,34 +303,78 @@ with lib; | |||
252 | name = "nfsroot.vidhar.yggdrasil"; | 303 | name = "nfsroot.vidhar.yggdrasil"; |
253 | paths = | 304 | paths = |
254 | (map (system: | 305 | (map (system: |
255 | let | 306 | pkgs.symlinkJoin { |
256 | installerBuild = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { | 307 | name = "installer-${system}"; |
257 | modules = [ | 308 | paths = [ |
258 | ({ ... }: { | 309 | (builtins.addErrorContext "while evaluating installer-${system}-nfsroot" (let |
259 | config.nfsroot.storeDevice = "10.141.0.1:nix-store"; | 310 | installerBuild' = (flake.nixosConfigurations.${"installer-${system}-nfsroot"}.extendModules { |
260 | config.nfsroot.registrationUrl = "http://nfsroot.vidhar.yggdrasil/installer-${system}/registration"; | 311 | modules = [ |
261 | }) | 312 | ({ ... }: { |
262 | ]; | 313 | config.nfsroot.storeDevice = "${nfsIp}:nix-store"; |
263 | }).config.system.build; | 314 | config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/installer-${system}/registration"; |
264 | in builtins.toPath (pkgs.runCommandLocal "install-${system}" {} '' | 315 | config.system.nixos.label = "installer-${system}"; |
265 | mkdir -p $out/installer-${system} | 316 | }) |
266 | install -m 0444 -t $out/installer-${system} \ | 317 | ]; |
267 | ${installerBuild.initialRamdisk}/initrd \ | 318 | }); |
268 | ${installerBuild.kernel}/bzImage \ | 319 | installerBuild = installerBuild'.config.system.build; |
269 | ${installerBuild.netbootIpxeScript}/netboot.ipxe \ | 320 | in builtins.toPath (pkgs.runCommandLocal "installer-${system}" {} '' |
270 | ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration | 321 | mkdir -p $out/installer-${system} |
271 | '') | 322 | install -m 0444 -t $out/installer-${system} \ |
272 | ) ["x86_64-linux"] | 323 | ${installerBuild.initialRamdisk}/initrd \ |
324 | ${installerBuild.kernel}/bzImage \ | ||
325 | ${installerBuild.netbootIpxeScript}/netboot.ipxe \ | ||
326 | ${pkgs.closureInfo { rootPaths = installerBuild.storeContents; }}/registration | ||
327 | install -m 0444 ${pkgs.writeText "installer-${system}.menu.ipxe" '' | ||
328 | #!ipxe | ||
329 | |||
330 | :start | ||
331 | menu iPXE boot menu for installer-${system} | ||
332 | item installer ${with installerBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"} | ||
333 | item memtest memtest86plus | ||
334 | item netboot netboot.xyz | ||
335 | item shell iPXE shell | ||
336 | choose --timeout 0 --default installer selected || goto shell | ||
337 | goto ''${selected} | ||
338 | |||
339 | :shell | ||
340 | shell | ||
341 | goto start | ||
342 | |||
343 | :installer | ||
344 | chain installer-${system}/netboot.ipxe | ||
345 | goto start | ||
346 | |||
347 | :netboot | ||
348 | iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn | ||
349 | goto start | ||
350 | |||
351 | :memtest | ||
352 | iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin | ||
353 | goto start | ||
354 | ''} $out/installer-${system}.menu.ipxe | ||
355 | ''))) | ||
356 | ]; | ||
357 | }) ["x86_64-linux"] | ||
273 | ) ++ [ | 358 | ) ++ [ |
274 | (let | 359 | (pkgs.runCommandLocal "utils" {} '' |
275 | eostreBuild = (flake.nixosConfigurations.eostre.extendModules { | 360 | mkdir $out |
361 | install -m 0444 -t $out \ | ||
362 | ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} \ | ||
363 | ${pkgs.memtest86plus}/{memtest.efi,memtest.bin} | ||
364 | install -m 0444 ${sources.netbootxyz-efi.src} $out/netboot.xyz.efi | ||
365 | install -m 0444 ${sources.netbootxyz-lkrn.src} $out/netboot.xyz.lkrn | ||
366 | '') | ||
367 | (builtins.addErrorContext "while evaluating eostre" (let | ||
368 | eostreBuild' = (flake.nixosConfigurations.eostre.extendModules { | ||
276 | modules = [ | 369 | modules = [ |
277 | ({ ... }: { | 370 | ({ ... }: { |
278 | config.nfsroot.storeDevice = "10.141.0.1:nix-store"; | 371 | config.nfsroot.storeDevice = "${nfsIp}:nix-store"; |
279 | config.nfsroot.registrationUrl = "http://nfsroot.vidhar.yggdrasil/eostre/registration"; | 372 | config.nfsroot.registrationUrl = "${nfsrootBaseUrl}/eostre/registration"; |
373 | config.system.nixos.label = "eostre"; | ||
280 | }) | 374 | }) |
281 | ]; | 375 | ]; |
282 | }).config.system.build; | 376 | }); |
377 | eostreBuild = eostreBuild'.config.system.build; | ||
283 | in builtins.toPath (pkgs.runCommandLocal "eostre" {} '' | 378 | in builtins.toPath (pkgs.runCommandLocal "eostre" {} '' |
284 | mkdir -p $out/eostre | 379 | mkdir -p $out/eostre |
285 | install -m 0444 -t $out/eostre \ | 380 | install -m 0444 -t $out/eostre \ |
@@ -287,7 +382,39 @@ with lib; | |||
287 | ${eostreBuild.kernel}/bzImage \ | 382 | ${eostreBuild.kernel}/bzImage \ |
288 | ${eostreBuild.netbootIpxeScript}/netboot.ipxe \ | 383 | ${eostreBuild.netbootIpxeScript}/netboot.ipxe \ |
289 | ${pkgs.closureInfo { rootPaths = eostreBuild.storeContents; }}/registration | 384 | ${pkgs.closureInfo { rootPaths = eostreBuild.storeContents; }}/registration |
290 | '')) | 385 | install -m 0444 ${pkgs.writeText "eostre.menu.ipxe" '' |
386 | #!ipxe | ||
387 | |||
388 | set menu-timeout 5000 | ||
389 | |||
390 | :start | ||
391 | menu iPXE boot menu for eostre | ||
392 | item eostre ${with eostreBuild'; "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} (Linux ${config.boot.kernelPackages.kernel.modDirVersion})"} | ||
393 | item memtest memtest86plus | ||
394 | item netboot netboot.xyz | ||
395 | item shell iPXE shell | ||
396 | choose --timeout ''${menu-timeout} --default eostre selected || goto shell | ||
397 | set menu-timeout 0 | ||
398 | goto ''${selected} | ||
399 | |||
400 | :shell | ||
401 | set menu-timeout 0 | ||
402 | shell | ||
403 | goto start | ||
404 | |||
405 | :eostre | ||
406 | chain eostre/netboot.ipxe | ||
407 | goto start | ||
408 | |||
409 | :netboot | ||
410 | iseq ''${platform} efi && chain --autofree netboot.xyz.efi || chain --autofree netboot.xyz.lkrn | ||
411 | goto start | ||
412 | |||
413 | :memtest | ||
414 | iseq ''${platform} efi && chain --autofree memtest.efi || chain --autofree memtest.bin | ||
415 | goto start | ||
416 | ''} $out/eostre.menu.ipxe | ||
417 | ''))) | ||
291 | ]; | 418 | ]; |
292 | }; | 419 | }; |
293 | }; | 420 | }; |
@@ -298,20 +425,12 @@ with lib; | |||
298 | after = [ "network.target" ]; | 425 | after = [ "network.target" ]; |
299 | wantedBy = [ "multi-user.target" ]; | 426 | wantedBy = [ "multi-user.target" ]; |
300 | serviceConfig.ExecStart = let | 427 | serviceConfig.ExecStart = let |
301 | ipxe = pkgs.ipxe.override { | ||
302 | additionalTargets = { | ||
303 | "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; | ||
304 | }; | ||
305 | additionalOptions = [ | ||
306 | "NSLOOKUP_CMD" | ||
307 | ]; | ||
308 | }; | ||
309 | tftpRoot = pkgs.runCommandLocal "netboot" {} '' | 428 | tftpRoot = pkgs.runCommandLocal "netboot" {} '' |
310 | mkdir -p $out | 429 | mkdir -p $out |
311 | install -m 0444 -t $out \ | 430 | install -m 0444 -t $out \ |
312 | ${ipxe}/ipxe.efi ${ipxe}/i386-ipxe.efi ${ipxe}/undionly.kpxe | 431 | ${ipxe}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} |
313 | ''; | 432 | ''; |
314 | in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=10.141.0.1 ${tftpRoot}"; | 433 | in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=${tftpIp} ${tftpRoot}"; |
315 | }; | 434 | }; |
316 | }; | 435 | }; |
317 | } | 436 | } |
diff --git a/hosts/vidhar/network/ruleset.nft b/hosts/vidhar/network/ruleset.nft index 9f519302..7897fb3d 100644 --- a/hosts/vidhar/network/ruleset.nft +++ b/hosts/vidhar/network/ruleset.nft | |||
@@ -1,4 +1,5 @@ | |||
1 | define icmp_protos = { ipv6-icmp, icmp, igmp } | 1 | define icmp_protos = { ipv6-icmp, icmp, igmp } |
2 | define bifrost_surtr = 2a03:4000:52:ada:4::/128 | ||
2 | 3 | ||
3 | table arp filter { | 4 | table arp filter { |
4 | limit lim_arp_local { | 5 | limit lim_arp_local { |
@@ -59,6 +60,7 @@ table inet filter { | |||
59 | counter fw-lo {} | 60 | counter fw-lo {} |
60 | counter fw-lan {} | 61 | counter fw-lan {} |
61 | counter fw-gpon {} | 62 | counter fw-gpon {} |
63 | counter fw-kimai {} | ||
62 | 64 | ||
63 | counter fw-cups {} | 65 | counter fw-cups {} |
64 | 66 | ||
@@ -90,6 +92,11 @@ table inet filter { | |||
90 | counter http-rx {} | 92 | counter http-rx {} |
91 | counter tftp-rx {} | 93 | counter tftp-rx {} |
92 | counter pgbackrest-rx {} | 94 | counter pgbackrest-rx {} |
95 | counter immich-rx {} | ||
96 | counter paperless-rx {} | ||
97 | counter hledger-rx {} | ||
98 | counter audiobookshelf-rx {} | ||
99 | counter kimai-rx {} | ||
93 | 100 | ||
94 | counter established-rx {} | 101 | counter established-rx {} |
95 | 102 | ||
@@ -118,6 +125,11 @@ table inet filter { | |||
118 | counter http-tx {} | 125 | counter http-tx {} |
119 | counter tftp-tx {} | 126 | counter tftp-tx {} |
120 | counter pgbackrest-tx {} | 127 | counter pgbackrest-tx {} |
128 | counter immich-tx {} | ||
129 | counter paperless-tx {} | ||
130 | counter hledger-tx {} | ||
131 | counter audiobookshelf-tx {} | ||
132 | counter kimai-tx {} | ||
121 | 133 | ||
122 | counter tx {} | 134 | counter tx {} |
123 | 135 | ||
@@ -141,8 +153,13 @@ table inet filter { | |||
141 | 153 | ||
142 | oifname { lan, gpon, bifrost } meta l4proto $icmp_protos jump forward_icmp_accept | 154 | oifname { lan, gpon, bifrost } meta l4proto $icmp_protos jump forward_icmp_accept |
143 | iifname lan oifname { gpon, bifrost } counter name fw-lan accept | 155 | iifname lan oifname { gpon, bifrost } counter name fw-lan accept |
156 | iifname ve-kimai oifname gpon counter name fw-kimai accept | ||
144 | 157 | ||
145 | iifname gpon oifname lan ct state { established, related } counter name fw-gpon accept | 158 | iifname gpon oifname lan ct state { established, related } counter name fw-gpon accept |
159 | iifname gpon oifname ve-kimai ct state { established, related } counter name fw-kimai accept | ||
160 | |||
161 | iifname bifrost oifname ve-kimai tcp dport 80 ip6 saddr $bifrost_surtr ip6 daddr 2a03:4000:52:ada:6::2 counter name kimai-rx accept | ||
162 | iifname ve-kimai oifname bifrost tcp sport 80 ip6 saddr 2a03:4000:52:ada:6::2 ip6 daddr $bifrost_surtr counter name kimai-tx accept | ||
146 | 163 | ||
147 | 164 | ||
148 | limit name lim_reject log level debug prefix "drop forward: " counter name reject-ratelimit-fw drop | 165 | limit name lim_reject log level debug prefix "drop forward: " counter name reject-ratelimit-fw drop |
@@ -193,6 +210,11 @@ table inet filter { | |||
193 | 210 | ||
194 | tcp dport 8432 counter name pgbackrest-rx accept | 211 | tcp dport 8432 counter name pgbackrest-rx accept |
195 | 212 | ||
213 | iifname bifrost tcp dport 2283 ip6 saddr $bifrost_surtr counter name immich-rx accept | ||
214 | iifname bifrost tcp dport 28981 ip6 saddr $bifrost_surtr counter name paperless-rx accept | ||
215 | iifname bifrost tcp dport 5000 ip6 saddr $bifrost_surtr counter name hledger-rx accept | ||
216 | iifname bifrost tcp dport 28982 ip6 saddr $bifrost_surtr counter name audiobookshelf-rx accept | ||
217 | |||
196 | ct state { established, related } counter name established-rx accept | 218 | ct state { established, related } counter name established-rx accept |
197 | 219 | ||
198 | 220 | ||
@@ -240,6 +262,11 @@ table inet filter { | |||
240 | 262 | ||
241 | tcp sport 8432 counter name pgbackrest-tx accept | 263 | tcp sport 8432 counter name pgbackrest-tx accept |
242 | 264 | ||
265 | iifname bifrost tcp sport 2283 ip6 daddr $bifrost_surtr counter name immich-tx accept | ||
266 | iifname bifrost tcp sport 28981 ip6 daddr $bifrost_surtr counter name paperless-tx accept | ||
267 | iifname bifrost tcp sport 5000 ip6 daddr $bifrost_surtr counter name hledger-tx accept | ||
268 | iifname bifrost tcp sport 28982 ip6 daddr $bifrost_surtr counter name audiobookshelf-tx accept | ||
269 | |||
243 | 270 | ||
244 | counter name tx | 271 | counter name tx |
245 | } | 272 | } |
@@ -247,7 +274,7 @@ table inet filter { | |||
247 | 274 | ||
248 | table inet nat { | 275 | table inet nat { |
249 | counter gpon-nat {} | 276 | counter gpon-nat {} |
250 | # counter container-nat {} | 277 | counter kimai-nat {} |
251 | 278 | ||
252 | chain postrouting { | 279 | chain postrouting { |
253 | type nat hook postrouting priority srcnat | 280 | type nat hook postrouting priority srcnat |
@@ -255,7 +282,7 @@ table inet nat { | |||
255 | 282 | ||
256 | 283 | ||
257 | meta nfproto ipv4 oifname gpon counter name gpon-nat masquerade | 284 | meta nfproto ipv4 oifname gpon counter name gpon-nat masquerade |
258 | # iifname ve-* oifname gpon counter name container-nat masquerade | 285 | iifname ve-kimai oifname gpon counter name kimai-nat masquerade |
259 | } | 286 | } |
260 | } | 287 | } |
261 | 288 | ||
diff --git a/hosts/vidhar/paperless/default.nix b/hosts/vidhar/paperless/default.nix new file mode 100644 index 00000000..dd02da38 --- /dev/null +++ b/hosts/vidhar/paperless/default.nix | |||
@@ -0,0 +1,25 @@ | |||
1 | { config, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | services.paperless = { | ||
6 | enable = true; | ||
7 | address = "2a03:4000:52:ada:4:1::"; | ||
8 | passwordFile = config.sops.secrets."paperless-rootpw".path; | ||
9 | settings = { | ||
10 | PAPERLESS_OCR_LANGUAGE = "deu+eng"; | ||
11 | PAPERLESS_URL = "https://paperless.yggdrasil.li"; | ||
12 | PAPERLESS_FILENAME_FORMAT = "{{ created_year }}/{{ document_type }}/{{ correspondent }}/{{ created }}_{{ doc_pk }}_{{ title }}"; | ||
13 | PAPERLESS_FILENAME_FORMAT_REMOVE_NONE = "true"; | ||
14 | PAPERLESS_TASK_WORKERS = "3"; | ||
15 | PAPERLESS_THREADS_PER_WORKER = "4"; | ||
16 | }; | ||
17 | database.createLocally = true; | ||
18 | }; | ||
19 | |||
20 | sops.secrets."paperless-rootpw" = { | ||
21 | format = "binary"; | ||
22 | sopsFile = ./rootpw; | ||
23 | }; | ||
24 | }; | ||
25 | } | ||
diff --git a/hosts/vidhar/paperless/rootpw b/hosts/vidhar/paperless/rootpw new file mode 100644 index 00000000..11f48fcb --- /dev/null +++ b/hosts/vidhar/paperless/rootpw | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:Bsns3bLs7aA++eTf2Vh4g2iAXhmrMRTF,iv:zQ6hgXEvgHAloN6UMW54f2nYCvEhHPXQSBVSihHFiC0=,tag:uiGTEs07dpx12PcAjmbr9Q==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlVUJjdEdIZGd6UDJBRXlL\nODFyWDhHOU9oTEVCVlFiUXVXNm9XZmVuampVCkJ0YkFXTlZXVnRldmtlVkJaR3R2\nMFhpaHB5M3pLeDFkUkkzMUFydGNnOFEKLS0tIEJtNWc0V2JaaWYvQlp6TGxVdVZO\neVpzQzB5Um82TUZOeHBHeE50MGlqNWsKj1P54Fc+c5n35+Og9DwBWkvW947hgFsp\ni/G2QcaLHHJMTexTCZYsr1naSVa/cMBAbrZmtjz0HV4Q1kCJtvlrIg==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1UG1QSWtXcFZoQVRBOC9D\nT2VnTW9pcTRCMForcHdZVld0c1NmNFZpWUNBCkRkMERKUVliYXRqb25saWxyb2JN\nbC9YL2ZQbytRM0ZjNmlQOTlTZTQrV2sKLS0tIFZyUWtRcXNqZUZxMGN5d0tHUng2\nVXNSdFEwMmtIVEdVRVlWeVU1YmJVSkUKRJa42k551QtiC6S0tmMv7eVN7GRqpXWz\nvzNh+BM9TOJNaTMmVesr4vXNDLOSFS3PxYv95xuOBzVg3zOHuai72g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-13T19:20:33Z", | ||
19 | "mac": "ENC[AES256_GCM,data:mG6AC3L8MMeZ0Ajr7zV1mzPcHviQw2adtGjSbrbPRw1xqN7siu6svoybv8xkahP2Grq/xKAiyfXFOFo7Uyc3ub5fSovAEolNazqybZYsyam5vHpeC23dXcEkZUJSPJ9/CSB5uI9nX3NPC64QUjCxHZ7qfH5gcXT9D12H8LSqKlQ=,iv:4Skdj8l9jlTX9Unc2xE2hCKVawHBnHR8L4kZA6H8xNw=,tag:zJsJ3S//faAn7AGwLefNoA==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/vidhar/pgbackrest/default.nix b/hosts/vidhar/pgbackrest/default.nix index ffb149f5..1e0828ce 100644 --- a/hosts/vidhar/pgbackrest/default.nix +++ b/hosts/vidhar/pgbackrest/default.nix | |||
@@ -130,8 +130,9 @@ in { | |||
130 | }; | 130 | }; |
131 | 131 | ||
132 | systemd.tmpfiles.rules = [ | 132 | systemd.tmpfiles.rules = [ |
133 | "d /var/lib/pgbackrest 0750 pgbackrest pgbackrest - -" | 133 | "d /var/lib/pgbackrest 0770 pgbackrest pgbackrest - -" |
134 | "d /var/spool/pgbackrest 0750 pgbackrest pgbackrest - -" | 134 | "d /var/spool/pgbackrest 0770 pgbackrest pgbackrest - -" |
135 | "d /tmp/pgbackrest 0770 pgbackrest pgbackrest - -" | ||
135 | ]; | 136 | ]; |
136 | 137 | ||
137 | users = { | 138 | users = { |
@@ -141,7 +142,9 @@ in { | |||
141 | isSystemUser = true; | 142 | isSystemUser = true; |
142 | home = "/var/lib/pgbackrest"; | 143 | home = "/var/lib/pgbackrest"; |
143 | }; | 144 | }; |
144 | groups.pgbackrest = {}; | 145 | groups.pgbackrest = { |
146 | members = [ "postgres" ]; | ||
147 | }; | ||
145 | }; | 148 | }; |
146 | 149 | ||
147 | systemd.services."pgbackrest-tls-server".serviceConfig = { | 150 | systemd.services."pgbackrest-tls-server".serviceConfig = { |
diff --git a/hosts/vidhar/postgresql.nix b/hosts/vidhar/postgresql.nix new file mode 100644 index 00000000..7e44e69f --- /dev/null +++ b/hosts/vidhar/postgresql.nix | |||
@@ -0,0 +1,36 @@ | |||
1 | { pkgs, config, flake, flakeInputs, ... }: | ||
2 | |||
3 | let | ||
4 | nixpkgs-pgbackrest = import (flakeInputs.nixpkgs-pgbackrest.outPath + "/pkgs/top-level") { | ||
5 | overlays = [ flake.overlays.libdscp ]; | ||
6 | localSystem = config.nixpkgs.system; | ||
7 | }; | ||
8 | in { | ||
9 | config = { | ||
10 | services.postgresql = { | ||
11 | enable = true; | ||
12 | package = pkgs.postgresql_15; | ||
13 | }; | ||
14 | |||
15 | services.pgbackrest = { | ||
16 | settings."vidhar" = { | ||
17 | pg1-path = config.services.postgresql.dataDir; | ||
18 | |||
19 | repo1-path = "/var/lib/pgbackrest"; | ||
20 | repo1-retention-full-type = "time"; | ||
21 | repo1-retention-full = 14; | ||
22 | repo1-retention-archive = 7; | ||
23 | }; | ||
24 | |||
25 | backups."vidhar-daily" = { | ||
26 | stanza = "vidhar"; | ||
27 | repo = "1"; | ||
28 | timerConfig.OnCalendar = "daily"; | ||
29 | }; | ||
30 | }; | ||
31 | |||
32 | systemd.services.postgresql.serviceConfig = { | ||
33 | ReadWritePaths = [ "/var/spool/pgbackrest" "/var/lib/pgbackrest/archive/vidhar" ]; | ||
34 | }; | ||
35 | }; | ||
36 | } | ||
diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix index d368ad52..094f9f7a 100644 --- a/hosts/vidhar/prometheus/default.nix +++ b/hosts/vidhar/prometheus/default.nix | |||
@@ -26,7 +26,8 @@ in { | |||
26 | enable = true; | 26 | enable = true; |
27 | 27 | ||
28 | extraFlags = [ | 28 | extraFlags = [ |
29 | "--enable-feature=remote-write-receiver" | 29 | "--web.enable-remote-write-receiver" |
30 | "--storage.tsdb.retention.size=35GB" | ||
30 | ]; | 31 | ]; |
31 | 32 | ||
32 | exporters = { | 33 | exporters = { |
diff --git a/hosts/vidhar/zfs.nix b/hosts/vidhar/zfs.nix index 518c3287..9d667fd6 100644 --- a/hosts/vidhar/zfs.nix +++ b/hosts/vidhar/zfs.nix | |||
@@ -34,7 +34,7 @@ with lib; | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | "/etc/zfs/zfs-list.cache" = | 36 | "/etc/zfs/zfs-list.cache" = |
37 | { device = "ssd-raid1/local/zfs-zfs--list.cache"; | 37 | { device = "ssd-raid1/local/etc-zfs-zfs--list.cache"; |
38 | fsType = "zfs"; | 38 | fsType = "zfs"; |
39 | neededForBoot = true; | 39 | neededForBoot = true; |
40 | }; | 40 | }; |