aboutsummaryrefslogtreecommitdiff
path: root/modules/networking/nixos/networkd.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/networking/nixos/networkd.nix')
-rw-r--r--modules/networking/nixos/networkd.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/modules/networking/nixos/networkd.nix b/modules/networking/nixos/networkd.nix
new file mode 100644
index 0000000..2c7f580
--- /dev/null
+++ b/modules/networking/nixos/networkd.nix
@@ -0,0 +1,44 @@
+{
+ # lib,
+ config,
+ ...
+}: let
+ cfg = config.collinux.system.network;
+ dhcp_enabled = cfg.static == null;
+
+ device =
+ if (cfg.wireless == null)
+ then "eth0"
+ else "wl*";
+in {
+ networking.useNetworkd = true;
+ systemd.network = {
+ enable = true;
+
+ wait-online = {
+ enable = true;
+ ignoredInterfaces = ["docker0"];
+ anyInterface = true;
+ };
+
+ networks."11-default" =
+ if dhcp_enabled
+ then {
+ name = device;
+ networkConfig.DHCP = "yes";
+
+ # never accept dhcp dns
+ dhcpV4Config.UseDNS = "no";
+ dhcpV6Config.UseDNS = "no";
+ }
+ else {
+ name = device;
+ networkConfig = {
+ Address = cfg.static.ip;
+ Gateway = cfg.static.gateway;
+ DHCP = "no";
+ # DNS is managed by systemd-resolved (not specified here)
+ };
+ };
+ };
+}