aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/common/optional/services/dhcp.nix
blob: 8585af7fcc36bb6571680cc49d67913c7f7f2c55 (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
{ config, lib, pkgs, ... }:
{

  environment = {
    etc = {
      "tftp/ipxe.efi".source = "${pkgs.ipxe}/ipxe.efi";
      "tftp/undionly.kpxe".source = "${pkgs.ipxe}/undionly.kpxe";
    };

    systemPackages = with pkgs; [
      ipxe
      tftp-hpa
    ];
  };

  services = {
    kea.dhcp4 = {
      configFile = config.sops.secrets.kea-dhcp4_conf.path;
      enable = true;
    };

    xinetd = {
      enable = true;
      services = [{
        name = "tftp";
        protocol = "udp";
        server = "${pkgs.tftp-hpa}/sbin/in.tftpd";
        serverArgs = "-s /etc/tftp";
        user = "root";
      }];
    };
  };

  systemd.services.kea-dhcp4-server = {
    serviceConfig = {
      ExecStart = lib.mkForce ''
        ${pkgs.kea}/bin/kea-dhcp4 -c ''${CREDENTIALS_DIRECTORY}/kea-dhcp4_conf
      '';
      LoadCredential = [ "kea-dhcp4_conf:${config.sops.secrets.kea-dhcp4_conf.path}" ];
    };
  };
}