{ pkgs, config, lib, ... }: let cfg = config.xyno.networking.networkd; in { options.xyno.networking.networkd.enable = lib.mkEnableOption "enable systemd networkd"; options.xyno.networking.networkd.enableWifi = lib.mkEnableOption "enable iwd"; config = lib.mkIf cfg.enable { systemd.network.enable = true; networking.useNetworkd = true; networking = { dhcpcd.enable = false; useDHCP = true; useHostResolvConf = false; }; systemd.network.networks."60-wifi-client" = { matchConfig = { WLANInterfaceType = "station"; }; networkConfig = { DHCP = "yes"; IgnoreCarrierLoss = "3s"; IPv6PrivacyExtensions = "kernel"; }; dhcpV4Config = { RouteMetric = 1025; # IPv6OnlyMode = "yes"; }; ipv6AcceptRAConfig = { # UsePREF64 = true; RouteMetric = 1025; }; }; # systemd.network.networks."60-wifi-client" = { # matchConfig = { # WLANInterfaceType = "station"; # }; # networkConfig = { # DHCP = "yes"; # # IPv6AcceptRA = true; # KeepConfiguration = "no"; # IPv6PrivacyExtensions = "kernel"; # }; # linkConfig.RequiredForOnline = "routable"; # dhcpV4Config = { # RouteMetric = 1025; # # IPv6OnlyMode = "yes"; # }; # ipv6AcceptRAConfig = { # # UsePREF64 = true; # RouteMetric = 1025; # }; # }; # systemd.network.networks."60-ethernet-dhcp" = { # matchConfig = { # Kind = "!*"; # Type = "either"; # # Name = "en*"; # }; # linkConfig.RequiredForOnline = "routable"; # dhcpV4Config = { # # IPv6OnlyMode = "yes"; # }; # networkConfig = { # DHCP = "yes"; # # IPv6AcceptRA = true; # KeepConfiguration = "no"; # IPv6PrivacyExtensions = "kernel"; # }; # # ipv6AcceptRAConfig.UsePREF64 = true; # }; networking.wireless.iwd.enable = cfg.enableWifi; networking.wireless.iwd.settings = { General = { AddressRandomization = "network"; AddressRandomizationRange = "full"; }; }; xyno.impermanence.directories = lib.optionals cfg.enableWifi [ "/var/lib/iwd" ]; # services.clatd.enable = true; }; }