CASCADE/common/cascade-networking.nix

44 lines
1.3 KiB
Nix
Raw Normal View History

with builtins;
with import (toString ../functions);
2022-09-24 03:24:58 +00:00
{config, lib, ...}: {
options = with lib; with types; {
cascade.bridge-interface = mkOption {
type = nullOr str;
default = null;
2022-09-24 03:24:58 +00:00
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)";
};
};
2022-09-24 03:24:58 +00:00
config = with lib; {
cascade.bridge-mac-prefix = mkDefault "02:${name-to-mac 2 config.networking.domain}";
networking = mkIf (config.cascade.bridge-interface != null) {
2022-09-24 03:24:58 +00:00
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];
};
2022-09-24 03:24:58 +00:00
};
#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}"
'';
2022-09-24 03:24:58 +00:00
};
}