summaryrefslogtreecommitdiffstats
path: root/lass/3modules/dnsmasq.nix
blob: c05ad0fc9fc2614b06f51e6419db81a113a7e530 (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
46
47
{ config, lib, pkgs, ... }:

with config.krebs.lib;

let
  cfg = config.lass.dnsmasq;

  out = {
    options.lass.dnsmasq = api;
    config = mkIf cfg.enable imp;
  };

  api = {
    enable = mkEnableOption "dnsmasq";
    config = mkOption {
      type = types.str;
      #TODO: find a good default
      default = ''
      '';
      description = "configuration dnsmasq is started with";
    };
  };

  configFile = pkgs.writeText "dnsmasq.conf" cfg.config;

  imp = {

    systemd.services.dnsmasq = {
      description = "dnsmasq";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];

      path = with pkgs; [
        dnsmasq
      ];


      restartIfChanged = true;

      serviceConfig = {
        Restart = "always";
        ExecStart = "${pkgs.dnsmasq}/bin/dnsmasq -k -C ${configFile}";
      };
    };
  };

in out