{ pkgs, config, lib, ... }: let inherit (config.grimmShared) enable tooling network ; inherit (lib) concatLines getExe' mkIf ; local_network = [ "192.168.0.0/16" "10.0.0.0/8" "172.16.0.0/12" "fc00::/7" ]; local_ips = pkgs.writeTextDir "local_ips.list" (concatLines local_network); created = "1970-01-01T00:00:00.0+00:00"; in { config = mkIf (enable && tooling.enable && network) { services.opensnitch.rules = { avahi = mkIf (config.services.avahi.enable) { name = "avahi"; enabled = true; action = "allow"; duration = "always"; inherit created; operator = { type = "list"; operand = "list"; list = [ { type = "simple"; sensitive = false; operand = "process.path"; data = getExe' config.services.avahi.package "avahi-daemon"; } { type = "regexp"; operand = "dest.port"; data = "5353|53"; } { type = "simple"; operand = "user.id"; data = "996"; } ]; }; }; cups-filters = mkIf (config.services.printing.enable) { name = "cups-filters"; enabled = true; action = "allow"; duration = "always"; inherit created; operator = { type = "list"; operand = "list"; list = [ { type = "simple"; sensitive = false; operand = "process.path"; data = getExe' pkgs.cups-filters "cups-browsed"; } { type = "regexp"; operand = "dest.port"; data = "53|631|80"; } { type = "lists"; operand = "lists.nets"; data = local_ips; } ]; }; }; }; }; }