summaryrefslogtreecommitdiffstats
path: root/modules/services/nextdns/default.nix
blob: cc486085e068316ef637b13d2dca49d0c2920aa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.nextdns;
  nextdns = pkgs.nextdns;

in {
  options = {
    services.nextdns = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description =
          "Whether to enable the NextDNS DNS/53 to DoH Proxy service.";
      };
      arguments = mkOption {
        type = types.listOf types.str;
        default = [ ];
        example = [ "-config" "10.0.3.0/24=abcdef" ];
        description = "Additional arguments to be passed to nextdns run.";
      };
    };
  };

  config = mkIf cfg.enable {

    environment.systemPackages = [ nextdns ];

    launchd.daemons.nextdns = {
      path = [ nextdns ];
      command = concatStringsSep " " (["${pkgs.nextdns}/bin/nextdns run"] ++ cfg.arguments);
      serviceConfig.KeepAlive = true;
      serviceConfig.RunAtLoad = true;
    };

  };
}