CASCADE/common/cascade-networking.nix

44 lines
1.3 KiB
Nix

with builtins;
with import (toString ../functions);
{config, lib, ...}: {
options = with lib; with types; {
cascade.bridge-interface = mkOption {
type = nullOr str;
default = null;
description = "interface on which to create primary bridge (br0)";
};
cascade.bridge-mac-prefix = mkOption {
type = str;
description = "prefix of mac addresses generated for primary bridge (br0)";
};
};
config = with lib; {
cascade.bridge-mac-prefix = mkDefault "02:${name-to-mac 2 config.networking.domain}";
networking = mkIf (config.cascade.bridge-interface != null) {
useNetworkd = mkForce true;
bridges.br0.interfaces = [config.cascade.bridge-interface];
interfaces.br0.useDHCP = mkImageMediaOverride true;
interfaces.br0.macAddress = mkImageMediaOverride "${config.cascade.bridge-mac-prefix}:${name-to-mac 3 config.networking.hostName}";
# also work around an issue with ipv6 and reverse lookups
hosts = lib.mkForce {
"127.0.1.1" = ["${config.networking.hostName}.${config.networking.domain}" config.networking.hostName];
};
};
#services.resolved.enable = mkForce false;
# let's just do this here to be sure...
system.activationScripts.cascade-networking-domainname = ''
domainname "${config.networking.domain}"
hostname "${config.networking.hostName}"
'';
};
}