aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/wifi-spt.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2025-01-23 15:31:16 +0100
committerKarel Kočí <cynerd@email.cz>2025-01-23 15:31:16 +0100
commit31661e73a6ce84a25be1b80ee898fe7fe63b16b6 (patch)
tree623e2efb274d96a9f027e8907110f7ae236f6a81 /nixos/modules/wifi-spt.nix
parent49499f75055ce669a439ecdcd964ad64cb591fd9 (diff)
downloadnixos-personal-31661e73a6ce84a25be1b80ee898fe7fe63b16b6.tar.gz
nixos-personal-31661e73a6ce84a25be1b80ee898fe7fe63b16b6.tar.bz2
nixos-personal-31661e73a6ce84a25be1b80ee898fe7fe63b16b6.zip
nixos: refactor the modules
Diffstat (limited to 'nixos/modules/wifi-spt.nix')
-rw-r--r--nixos/modules/wifi-spt.nix84
1 files changed, 31 insertions, 53 deletions
diff --git a/nixos/modules/wifi-spt.nix b/nixos/modules/wifi-spt.nix
index d3f6f68..bec093e 100644
--- a/nixos/modules/wifi-spt.nix
+++ b/nixos/modules/wifi-spt.nix
@@ -6,7 +6,7 @@
inherit (lib) mkOption mkEnableOption types mkIf mkForce mkMerge hostapd elemAt;
cnf = config.cynerd.wifiAP.spt;
- networks = name: let
+ wifi-networks = name: let
is2g = cnf."${name}".channel <= 14;
in {
"${cnf."${name}".interface}" = {
@@ -35,6 +35,32 @@
};
};
+ net-networks = name: {
+ "lan-${cnf."${name}".interface}" = {
+ matchConfig = {
+ Name = cnf."${name}".interface;
+ WLANInterfaceType = "ap";
+ };
+ networkConfig.Bridge = "brlan";
+ bridgeVLANs = [
+ {
+ EgressUntagged = 1;
+ PVID = 1;
+ }
+ ];
+ };
+ "lan-${cnf."${name}".interface}-guest" = {
+ matchConfig.Name = "${cnf."${name}".interface}.guest";
+ networkConfig.Bridge = "brlan";
+ bridgeVLANs = [
+ {
+ EgressUntagged = 2;
+ PVID = 2;
+ }
+ ];
+ };
+ };
+
wOptions = card: channelDefault: {
interface = mkOption {
type = with types; nullOr str;
@@ -77,7 +103,7 @@ in {
enable = true;
inherit (hostapd.qualcomAtherosAR9287.wifi4) capabilities;
};
- networks = networks "ar9287";
+ networks = wifi-networks "ar9287";
};
})
(mkIf (cnf.qca988x.interface != null) {
@@ -98,62 +124,14 @@ in {
enable = !is2g;
inherit (hostapd.qualcomAtherosQCA988x.wifi5) capabilities;
};
- networks = networks "qca988x";
+ networks = wifi-networks "qca988x";
};
})
];
};
systemd.network.networks = mkMerge [
- (mkIf (cnf.ar9287.interface != null) {
- "lan-${cnf.ar9287.interface}" = {
- matchConfig = {
- Name = cnf.ar9287.interface;
- WLANInterfaceType = "ap";
- };
- networkConfig.Bridge = "brlan";
- bridgeVLANs = [
- {
- EgressUntagged = 1;
- PVID = 1;
- }
- ];
- };
- "lan-${cnf.ar9287.interface}-guest" = {
- matchConfig.Name = "${cnf.ar9287.interface}.guest";
- networkConfig.Bridge = "brlan";
- bridgeVLANs = [
- {
- EgressUntagged = 2;
- PVID = 2;
- }
- ];
- };
- })
- (mkIf (cnf.qca988x.interface != null) {
- "lan-${cnf.qca988x.interface}" = {
- matchConfig = {
- Name = cnf.qca988x.interface;
- WLANInterfaceType = "ap";
- };
- networkConfig.Bridge = "brlan";
- bridgeVLANs = [
- {
- EgressUntagged = 1;
- PVID = 1;
- }
- ];
- };
- "lan-${cnf.qca988x.interface}-guest" = {
- matchConfig.Name = "${cnf.qca988x.interface}.guest";
- networkConfig.Bridge = "brlan";
- bridgeVLANs = [
- {
- EgressUntagged = 2;
- PVID = 2;
- }
- ];
- };
- })
+ (mkIf (cnf.ar9287.interface != null) (net-networks "ar9287"))
+ (mkIf (cnf.qca988x.interface != null) (net-networks "qca988x"))
];
};
}