summaryrefslogtreecommitdiffstats
path: root/lass/3modules/dnsmasq.nix
blob: 99c16547932aecd0144ac4096558956e6c5e5476 (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
49
50
51
52
53
54
55
{ 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 = {
    #users.extraUsers.go = {
    #  name = "go";
    #  uid = 42774411; #genid go
    #  description = "go url shortener user";
    #  home = "/var/lib/go";
    #  createHome = true;
    #};

    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