at 23.11-pre 1.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.nextdns; 7in { 8 options = { 9 services.nextdns = { 10 enable = mkOption { 11 type = types.bool; 12 default = false; 13 description = lib.mdDoc "Whether to enable the NextDNS DNS/53 to DoH Proxy service."; 14 }; 15 arguments = mkOption { 16 type = types.listOf types.str; 17 default = []; 18 example = [ "-config" "10.0.3.0/24=abcdef" ]; 19 description = lib.mdDoc "Additional arguments to be passed to nextdns run."; 20 }; 21 }; 22 }; 23 24 # https://github.com/nextdns/nextdns/blob/628ea509eaaccd27adb66337db03e5b56f6f38a8/host/service/systemd/service.go 25 config = mkIf cfg.enable { 26 systemd.services.nextdns = { 27 description = "NextDNS DNS/53 to DoH Proxy"; 28 environment = { 29 SERVICE_RUN_MODE = "1"; 30 }; 31 startLimitIntervalSec = 5; 32 startLimitBurst = 10; 33 serviceConfig = { 34 ExecStart = "${pkgs.nextdns}/bin/nextdns run ${escapeShellArgs config.services.nextdns.arguments}"; 35 RestartSec = 120; 36 LimitMEMLOCK = "infinity"; 37 }; 38 after = [ "network.target" ]; 39 before = [ "nss-lookup.target" ]; 40 wants = [ "nss-lookup.target" ]; 41 wantedBy = [ "multi-user.target" ]; 42 }; 43 }; 44}