Files
nixos/base/network-dhcp.nix

54 lines
958 B
Nix

# Module: base/network-dhcp.nix
{
config,
lib,
pkgs,
pkgsUnstable,
inputs,
options,
...
}:
with lib;
let
cfg = config.network-dhcp;
in
{
options.network-dhcp = {
enable = mkEnableOption "Enables DHCP networking on host";
hardwareAddress = mkOption {
type = types.str;
default = "";
description = "MAC address of primary ethernet interface";
example = "11:22:33:44:55:66";
};
};
config = mkIf cfg.enable {
networking = {
useNetworkd = true;
usePredictableInterfaceNames = false;
};
systemd.network = {
enable = true;
links.eth0 = {
matchConfig.MACAddress = cfg.hardwareAddress;
linkConfig.Name = "eth0";
};
networks."05-eth" = {
matchConfig.Name = "eth0";
linkConfig.RequiredForOnline = "routable";
networkConfig = {
DHCP = "yes";
IPv6AcceptRA = true;
};
};
};
};
}