feat: mdns-relay

This commit is contained in:
Patrick 2025-01-01 21:20:46 +01:00
parent aeba7c71e4
commit 088d01f032
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
5 changed files with 707 additions and 168 deletions

View file

@ -2,6 +2,7 @@
inputs,
config,
globals,
pkgs,
...
}:
let
@ -42,7 +43,7 @@ in
};
services.idmail = {
package = inputs.idmail.packages."aarch64-linux".default;
package = inputs.idmail.packages.${pkgs.system}.default;
enable = true;
# Stalwart will change permissions due to SQLite implementation.
# Therefore, run as stalwart-mail since we don't allow reading

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixp-meta.url = "git+https://forge.lel.lol/patrick/nixp-meta.git";
mdns.url = "git+https://forge.lel.lol/patrick/mdns-repeater.git";
idmail = {
url = "github:oddlama/idmail/";
inputs.nixpkgs.follows = "nixpkgs";

75
hosts/nucnix/mdns.nix Normal file
View file

@ -0,0 +1,75 @@
{
inputs,
pkgs,
lib,
...
}:
let
cfg = {
interfaces = "lan-.*";
rules = [
{
from = "lan-home";
to = "lan-services";
allow_questions = "(nucnix|elisabeth)";
allow_answers = "";
}
{
from = "lan-services";
to = "lan-home";
allow_questions = "";
allow_answers = "(nucnix|elisabeth)";
}
];
};
in
{
systemd.services.mdns-relay = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
#environment.RUST_LOG = "debug";
serviceConfig = {
Restart = "on-failure";
ExecStart = "${
lib.getExe inputs.mdns.packages.${pkgs.system}.default
} -c ${pkgs.writeText "config.json" (builtins.toJSON cfg)}";
# Hardening
DynamicUser = true;
CapabilityBoundingSet = "";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateUsers = true;
PrivateTmp = true;
PrivateDevices = true;
PrivateMounts = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
RemoveIPC = true;
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_NETLINK"
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged"
];
UMask = "0027";
};
};
}

View file

@ -18,6 +18,7 @@ in
imports = [
./kea.nix
./forwarding.nix
./mdns.nix
];
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
networking.nftables.firewall.zones = mkMerge [