1 { config, lib, pkgs, ... }:
6 cfg = config.services.stubby;
7 settingsFormat = pkgs.formats.yaml { };
8 confFile = settingsFormat.generate "stubby.yml" cfg.settings;
11 (mkRemovedOptionModule [ "stubby" "debugLogging" ] "Use services.stubby.logLevel = \"debug\"; instead.")
13 (mkRemovedOptionModule [ "services" "stubby" x ]
14 "Stubby configuration moved to services.stubby.settings.")) [
19 "queryPaddingBlocksize"
28 enable = mkEnableOption "Stubby DNS resolver";
31 type = types.attrsOf settingsFormat.type;
32 example = lib.literalExpression ''
33 pkgs.stubby.passthru.settingsExample // {
34 upstream_recursive_servers = [{
35 address_data = "158.64.1.29";
36 tls_auth_name = "kaitain.restena.lu";
37 tls_pubkey_pinset = [{
39 value = "7ftvIkA+UeN/ktVkovd/7rPZ6mbkhVI7/8HnFJIiLa4=";
45 Content of the Stubby configuration file. All Stubby settings may be set or queried
46 here. The default settings are available at
47 `pkgs.stubby.passthru.settingsExample`. See
48 <https://dnsprivacy.org/wiki/display/DP/Configuring+Stubby>.
49 A list of the public recursive servers can be found here:
50 <https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Test+Servers>.
67 type = types.nullOr (types.enum (attrNames logLevels ++ attrValues logLevels));
68 apply = v: if isString v then logLevels.${v} else v;
69 description = "Log verbosity (syslog keyword or level).";
75 config = mkIf cfg.enable {
78 (cfg.settings.resolution_type or "") == "GETDNS_RESOLUTION_STUB";
80 services.stubby.settings.resolution_type must be set to "GETDNS_RESOLUTION_STUB".
81 Is services.stubby.settings unset?
85 services.stubby.settings.appdata_dir = "/var/cache/stubby";
87 systemd.services.stubby = {
88 description = "Stubby local DNS resolver";
89 after = [ "network.target" ];
90 before = [ "nss-lookup.target" ];
91 wantedBy = [ "multi-user.target" ];
95 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
96 CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
97 ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString (cfg.logLevel != null) "-v ${toString cfg.logLevel}"}";
99 CacheDirectory = "stubby";