From 89a605727649bb4599af04681e40a19bf24e69a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 23 Jan 2023 21:23:23 +0100 Subject: nixos: improve wifi configuration --- nixos/routers/wifi-spt.nix | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 nixos/routers/wifi-spt.nix (limited to 'nixos/routers/wifi-spt.nix') diff --git a/nixos/routers/wifi-spt.nix b/nixos/routers/wifi-spt.nix new file mode 100644 index 0000000..1cbb567 --- /dev/null +++ b/nixos/routers/wifi-spt.nix @@ -0,0 +1,83 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cnf = config.cynerd.wifiAP.spt; + + wOptions = card: channelDefault: { + interface = mkOption { + type = with types; nullOr str; + default = null; + description = "Specify interface for ${card}"; + }; + channel = mkOption { + type = types.ints.positive; + default = channelDefault; + description = "Channel to be used for ${card}"; + }; + }; +in { + options = { + cynerd.wifiAP.spt = { + enable = mkEnableOption "Enable Wi-Fi Access Point support"; + ar9287 = wOptions "Qualcom Atheros AR9287" 7; + qca988x = wOptions "Qualcom Atheros QCA988x" 36; + }; + }; + + config = mkIf cnf.enable { + networking.wirelessAP = { + enable = true; + environmentFile = "/run/secrets/hostapd.env"; + interfaces = + (optionalAttrs (cnf.ar9287.interface != null) { + "${cnf.ar9287.interface}" = + wifiAP.qualcomAtherosAR9287 { + channel = cnf.ar9287.channel; + } + // { + bssid = "@BSSID_AR9287_0@"; + ssid = "TurrisRules"; + wpa = 2; + wpaPassphrase = "@PASS_TURRIS_RULES@"; + bridge = "brlan"; + bss = { + "${cnf.ar9287.interface}.guest" = { + bssid = "@BSSID_AR9287_1@"; + ssid = "Kocovi"; + wpa = 2; + wpaPassphrase = "@PASS_KOCOVI@"; + bridge = "brguest"; + }; + }; + }; + }) + // (optionalAttrs (cnf.qca988x.interface != null) { + "${cnf.qca988x.interface}" = + wifiAP.qualcomAtherosQCA988x { + channel = cnf.qca988x.channel; + } + // { + bssid = "@BSSID_QCA988X_0@"; + countryCode = "CZ"; + ssid = "TurrisRules5"; + wpa = 2; + wpaPassphrase = "@PASS_TURRIS_RULES@"; + bridge = "brlan"; + bss = { + "${cnf.qca988x.interface}.guest" = { + bssid = "@BSSID_QCA988X_1@"; + ssid = "Kocovi"; + wpa = 2; + wpaPassphrase = "@PASS_KOCOVI@"; + bridge = "brguest"; + }; + }; + }; + }); + }; + }; +} -- cgit v1.2.3