diff --git a/config/networking.nix b/config/networking.nix index bb009b7..874df3c 100644 --- a/config/networking.nix +++ b/config/networking.nix @@ -2,16 +2,18 @@ with lib; -{ +let + networkD = config.machine.networkD; +in{ networking = { hostName = config.machine.hostName; - useNetworkd = config.machine.useNetworkd; - useDHCP = !config.machine.useNetworkd; - dhcpcd.enable = !config.machine.useNetworkd; + useNetworkd = networkD.enable; + useDHCP = !networkD.enable; + dhcpcd.enable = !networkD.enable; }; # Based on # https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069 - systemd.network = mkIf config.machine.useNetworkd { + systemd.network = mkIf networkD.enable { enable = true; networks = let networkConfig = { @@ -33,10 +35,30 @@ with lib; dhcpV4Config.RouteMetric = 1024; inherit networkConfig; }; + "50-vlan" = { + enable = true; + matchConfig = { + Name = "br0"; + }; + networkConfig = { + DNS = "10.0.0.1"; + Address = "10.0.0.100/16"; + # DHCPServer = true; + # IPMasquerade = true; + }; + # dhcpServerConfig = { + # ServerAddress = "172.16.9.1/12"; + # PoolOffset = 100; + # EmitDNS = false; + # }; + }; }; }; # Wait for any interface to become available, not for all - systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [ - "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" - ]; + systemd.services."systemd-networkd-wait-online" = { + enable = mkForce networkD.waitOnline; + serviceConfig.ExecStart = [ + "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" + ]; + }; } diff --git a/machines/Lilim/options.nix b/machines/Lilim/options.nix index d469045..7210f75 100644 --- a/machines/Lilim/options.nix +++ b/machines/Lilim/options.nix @@ -9,7 +9,10 @@ with lib; config.machine = { allowUnfree = true; hostName = "Lilim"; - useNetworkd = true; + networkD = { + enable = true; + waitOnline = false; + }; administrators = [ { name = "derped"; id = 1337; } ]; conffiles = [ "etcfiles" diff --git a/options/machine.nix b/options/machine.nix index 48319f0..c49d20b 100644 --- a/options/machine.nix +++ b/options/machine.nix @@ -59,12 +59,21 @@ in { The Machines HostName ''; }; - useNetworkd = mkOption { - type = types.bool; - default = false; - description = '' - Disables dhcpcd and enables networkd. - ''; + networkD = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Disables dhcpcd and enables networkd. + ''; + }; + waitOnline = mkOption { + type = types.bool; + default = true; + description = '' + Enables/disables systemd-networkd-wait-online service. + ''; + }; }; binaryCaches = mkOption { type = types.listOf types.str;