1 { config, lib, pkgs, ... }:
16 cfg = config.services.dnsproxy;
18 yaml = pkgs.formats.yaml { };
19 configFile = yaml.generate "config.yaml" cfg.settings;
21 finalFlags = (lists.optional (cfg.settings != { }) "--config-path=${configFile}") ++ cfg.flags;
25 options.services.dnsproxy = {
27 enable = mkEnableOption "dnsproxy";
29 package = mkPackageOption pkgs "dnsproxy" { };
34 example = literalExpression ''
51 Contents of the `config.yaml` config file.
52 The `--config-path` argument will only be passed if this set is not empty.
54 See <https://github.com/AdguardTeam/dnsproxy/blob/master/config.yaml.dist>.
59 type = types.listOf types.str;
61 example = [ "--upstream=1.1.1.1:53" ];
63 A list of extra command-line flags to pass to dnsproxy. For details on the
64 available options, see <https://github.com/AdguardTeam/dnsproxy#usage>.
65 Keep in mind that options passed through command-line flags override
72 config = mkIf cfg.enable {
73 systemd.services.dnsproxy = {
74 description = "Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support";
75 after = [ "network.target" "nss-lookup.target" ];
76 wantedBy = [ "multi-user.target" ];
78 ExecStart = "${getExe cfg.package} ${escapeShellArgs finalFlags}";
83 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
84 LockPersonality = true;
85 MemoryDenyWriteExecute = true;
86 NoNewPrivileges = true;
89 ProtectHostname = true;
90 ProtectKernelLogs = true;
92 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
93 RestrictNamespaces = true;
94 RestrictRealtime = true;
95 RestrictSUIDSGID = true;
96 SystemCallArchitectures = "native";
97 SystemCallErrorNumber = "EPERM";
98 SystemCallFilter = [ "@system-service" "~@privileged @resources" ];
103 meta.maintainers = with maintainers; [ diogotcorreia ];