summaryrefslogtreecommitdiff
path: root/sys/net.nix
blob: 30675e0e1ea1e9c5b644be6db7db943525fe231f (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
{ lib, config, pkgs, ... }:
with lib; let
  cfg = config.local;
in {
  options.local = with lib.types; {
    hostname = mkOption {
      type = str;
    };

    dhcpInterface = mkOption {
      type = nullOr str;
      default = null;
    };
  };

  config = {
    networking = {
      hostName = cfg.hostname;
      useDHCP = false;
      useNetworkd = true;

      interfaces = mkIf (cfg.dhcpInterface != null) {
        "${cfg.dhcpInterface}".useDHCP = true;
      };

      wireguard.enable = true;
    };

    environment.systemPackages = [ pkgs.dhcpcd ];
  };
}