{ config, lib, ... }: let cfg = config.soispha.networking; in { options.soispha.networking = { enable = lib.mkEnableOption "networking"; networkManager = { enable = lib.mkEnableOption "NetworkManager"; }; hostName = lib.mkOption { type = lib.types.str; example = "apzu"; description = "The name of the host"; }; }; config = lib.mkIf cfg.enable { systemd.network = { networks = { "tap0" = { name = "tap0"; bridge = [ "virbr0" ]; }; "enp4s0" = { name = "enp4s0"; networkConfig = { DHCP = "yes"; DNSOverTLS = "yes"; DNSSEC = "yes"; }; bridge = [ "virbr0" ]; }; }; netdevs = { "tap0" = { netdevConfig = { Name = "tap0"; Kind = "tap"; }; tapConfig = { User = "${config.users.users.soispha.uid}"; Group = "libvirtd"; }; }; "virbr0" = { netdevConfig = { Name = "br0"; Kind = "bridge"; }; }; }; }; } // lib.mkIf cfg.networkManager.enable { networking = { networkmanager = { enable = true; dns = "default"; wifi = { powersave = true; }; }; inherit (cfg) hostName; }; users.users.soispha.extraGroups = [ "networkmanager" # allows to configure networkmanager as this user ]; }; }