summary refs log tree commit diff stats
path: root/system/modules/darwin/kresd.nix
blob: 6bce8af1566353c953e87063b8917a65e6d58dab (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
40
41
42
43
44
45
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.kresd;
  package = pkgs.knot-resolver;

  configFile = pkgs.writeText "kresd.conf" cfg.extraConfig;
in
{
  options = {
    services.kresd.enable = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to enable knot-resolver daemon.";
    };

    services.kresd.extraConfig = mkOption {
      type = types.lines;
      default = "";
      description = ''
        Extra configuration to be added to the generated configuration file.
      '';
    };
  };

  config = mkIf cfg.enable {
    launchd.daemons.kresd = {
      command = "${package}/bin/kresd -c ${configFile}";

      serviceConfig = {
        ProcessType = "Interactive";
        # Sockets = {
        #   Listeners = {
        #     SockServiceName = "dns";
        #     SockFamily = "IPv4";
        #   };
        # };
      };
    };

    environment.systemPackages = [ package ];
  };
}