1 { config, lib, pkgs, ... }:
6 cfg = config.services.stubby;
7 settingsFormat = pkgs.formats.yaml { };
8 confFile = settingsFormat.generate "stubby.yml" cfg.settings;
11 (mkRemovedOptionModule [ "services" "stubby" x ]
12 "Stubby configuration moved to services.stubby.settings.")) [
17 "queryPaddingBlocksize"
26 enable = mkEnableOption (lib.mdDoc "Stubby DNS resolver");
29 type = types.attrsOf settingsFormat.type;
30 example = lib.literalExpression ''
31 pkgs.stubby.passthru.settingsExample // {
32 upstream_recursive_servers = [{
33 address_data = "158.64.1.29";
34 tls_auth_name = "kaitain.restena.lu";
35 tls_pubkey_pinset = [{
37 value = "7ftvIkA+UeN/ktVkovd/7rPZ6mbkhVI7/8HnFJIiLa4=";
42 description = lib.mdDoc ''
43 Content of the Stubby configuration file. All Stubby settings may be set or queried
44 here. The default settings are available at
45 `pkgs.stubby.passthru.settingsExample`. See
46 <https://dnsprivacy.org/wiki/display/DP/Configuring+Stubby>.
47 A list of the public recursive servers can be found here:
48 <https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Test+Servers>.
52 debugLogging = mkOption {
55 description = lib.mdDoc "Enable or disable debug level logging.";
61 config = mkIf cfg.enable {
64 (cfg.settings.resolution_type or "") == "GETDNS_RESOLUTION_STUB";
66 services.stubby.settings.resolution_type must be set to "GETDNS_RESOLUTION_STUB".
67 Is services.stubby.settings unset?
71 services.stubby.settings.appdata_dir = "/var/cache/stubby";
73 systemd.services.stubby = {
74 description = "Stubby local DNS resolver";
75 after = [ "network.target" ];
76 before = [ "nss-lookup.target" ];
77 wantedBy = [ "multi-user.target" ];
81 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
82 CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
83 ExecStart = "${pkgs.stubby}/bin/stubby -C ${confFile} ${optionalString cfg.debugLogging "-l"}";
85 CacheDirectory = "stubby";