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

with builtins;
with 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