refactor: move core.networking to networking

This commit is contained in:
Youwen Wu 2024-12-26 02:20:00 -08:00
parent 8fb6e79cb5
commit 11762d6c0e
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
3 changed files with 23 additions and 30 deletions

View file

@ -46,23 +46,6 @@ in
'';
};
suppressWarnings = lib.mkEnableOption "suppress warnings";
networking = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''Whether to set up and enable networking daemons.'';
};
backend = lib.mkOption {
type = lib.types.enum [
"wpa_supplicant"
"iwd"
];
default = "wpa_supplicant";
description = ''
Which backend to use for networking. Default is wpa_supplicant with NetworkManager as a frontend. With iwd, iwctl is the frontend.
'';
};
};
bluetooth.enable = lib.mkOption {
type = lib.types.bool;
default = true;
@ -161,19 +144,6 @@ in
hardware.enableRedistributableFirmware = true;
networking.networkmanager.enable = lib.mkIf (
cfg.networking.enable && cfg.networking.backend == "wpa_supplicant"
) true;
systemd.services.NetworkManager-wait-online.enable = lib.mkIf (
cfg.networking.enable && cfg.networking.backend == "wpa_supplicant"
) false;
networking.wireless.iwd = lib.mkIf (cfg.networking.enable && cfg.networking.backend == "iwd") {
enable = true;
settings.General.EnableNetworkConfiguration = true;
};
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;

View file

@ -31,6 +31,16 @@ in
vite = lib.mkEnableOption "firewall ports for Vite";
};
cloudflareNameservers.enable = lib.mkEnableOption "Cloudflare DNS servers";
backend = lib.mkOption {
type = lib.types.enum [
"wpa_supplicant"
"iwd"
];
default = "wpa_supplicant";
description = ''
Which backend to use for networking. Default is wpa_supplicant with NetworkManager as a frontend. With iwd, iwctl is the frontend.
'';
};
};
config = lib.mkIf cfg.enable {
@ -55,5 +65,17 @@ in
"1.1.1.1"
"1.0.0.1"
];
networking.networkmanager.enable = lib.mkIf (cfg.enable && cfg.backend == "wpa_supplicant") true;
systemd.services.NetworkManager-wait-online.enable = lib.mkIf (
cfg.enable && cfg.backend == "wpa_supplicant"
) false;
networking.wireless.iwd = lib.mkIf (cfg.enable && cfg.backend == "iwd") {
enable = true;
settings.General.EnableNetworkConfiguration = true;
};
};
}

View file

@ -28,6 +28,7 @@
networking = {
firewallPresets.vite = true;
cloudflareNameservers.enable = true;
backend = "iwd";
};
};
};