summaryrefslogtreecommitdiff
path: root/modules/nixos/personal
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2024-04-04 19:55:31 +0200
committerquentin@aristote.fr <quentin@aristote.fr>2024-04-04 21:31:03 +0200
commitfff7544eb65a7d83e0c790517d01ad076e52e6b0 (patch)
treeec95d188937bafd8fa81096937456f61127848ff /modules/nixos/personal
parentf43d6c9f80cde18631688f95ba72ad1b63524e62 (diff)
nixos: wifi: refactor
Diffstat (limited to 'modules/nixos/personal')
-rw-r--r--modules/nixos/personal/networking/wifi.nix51
1 files changed, 38 insertions, 13 deletions
diff --git a/modules/nixos/personal/networking/wifi.nix b/modules/nixos/personal/networking/wifi.nix
index 22f41dd..ffe6b21 100644
--- a/modules/nixos/personal/networking/wifi.nix
+++ b/modules/nixos/personal/networking/wifi.nix
@@ -8,7 +8,7 @@
id,
ssid,
}: {
- "${id}" = {
+ "${id}_template" = {
connection = {
id = "${id} (template)";
type = "wifi";
@@ -20,6 +20,9 @@
wifi-security = {
key-mgmt = "wpa-psk";
# fill-in password on first connection
+ # this will create a new connection
+ # disable the personal.networking.wifi.enable option
+ # to keep it for next rebuild
};
ipv4 = {
method = "auto";
@@ -32,27 +35,49 @@
};
};
};
+ knownSSIDs = {
+ home = "Quentintranet";
+ home-iot = "Quentinternet of Things";
+ home-guest = "Quentinvités";
+ aristote = "ARISTOTE";
+ aristote-4g = "ARISTOTE 4G";
+ stvictoret = "ORBIWAN";
+ montlaur = "Nordnet_E080";
+ montlaur-5g = "Nordnet_E080_5G";
+ };
in {
options.personal.networking.wifi = {
enable = lib.mkEnableOption "personal WiFi networks";
networks = lib.mkOption {
+ type = with lib.types; listOf str;
+ default = ["home-private" "hotspot"];
+ };
+ extraNetworks = lib.mkOption {
type = with lib.types; listOf (attrsOf str);
- default = [
- {
- id = "home-private";
- ssid = "Quentintranet";
- }
- {
- id = "hotspot";
- ssid = "Quentinternational";
- }
+ default = [];
+ example = [
{
- id = "home-cercier";
- ssid = "ARISTOTE";
+ id = "my-wifi";
+ ssid = "WiFi SSID";
}
];
};
};
- config.networking.networkmanager.ensureProfiles.profiles = lib.mkIf cfg.enable (lib.mergeAttrsList (builtins.map mkWifiProfile cfg.networks));
+ config.networking.networkmanager.ensureProfiles.profiles = let
+ networks =
+ builtins.map (id: {
+ inherit id;
+ ssid =
+ if lib.hasAttr id knownSSIDs
+ then lib.getAttr id knownSSIDs
+ else throw "Unknown WiFi ID: ${id}";
+ })
+ cfg.networks
+ ++ cfg.extraNetworks;
+ profiles = lib.mergeAttrsList (builtins.map mkWifiProfile networks);
+ in
+ lib.mkIf
+ cfg.enable
+ profiles;
}