diff options
| author | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
|---|---|---|
| committer | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
| commit | fc019d789523ce5f89436b8dbc458cf3b79abf43 (patch) | |
| tree | ec56fd1b1ed9fc75096c0b09db48a152975e4d53 /modules/nixos/personal/networking/wifi.nix | |
| parent | a3d19bc509d9f39fb41256cd55d2bd7706de202f (diff) | |
reformat everything with nixfmt
Diffstat (limited to 'modules/nixos/personal/networking/wifi.nix')
| -rw-r--r-- | modules/nixos/personal/networking/wifi.nix | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/modules/nixos/personal/networking/wifi.nix b/modules/nixos/personal/networking/wifi.nix index d7415a8..2e23349 100644 --- a/modules/nixos/personal/networking/wifi.nix +++ b/modules/nixos/personal/networking/wifi.nix @@ -2,39 +2,42 @@ config, lib, ... -}: let +}: +let cfg = config.personal.networking.wifi; - mkWifiProfile = { - id, - ssid, - }: { - "${id}" = { - connection = { - id = "${id}"; - type = "wifi"; - }; - wifi = { - inherit ssid; - mode = "infrastructure"; - }; - 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"; - }; - ipv6 = { - addr-gen-mode = "stable-privacy"; - method = "auto"; - }; - proxy = { + mkWifiProfile = + { + id, + ssid, + }: + { + "${id}" = { + connection = { + id = "${id}"; + type = "wifi"; + }; + wifi = { + inherit ssid; + mode = "infrastructure"; + }; + 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"; + }; + ipv6 = { + addr-gen-mode = "stable-privacy"; + method = "auto"; + }; + proxy = { + }; }; }; - }; knownSSIDs = { home = "Quentintranet"; home-iot = "Quentinternet of Things"; @@ -46,16 +49,20 @@ montlaur = "Nordnet_E080"; montlaur-5g = "Nordnet_E080_5G"; }; -in { +in +{ options.personal.networking.wifi = { enable = lib.mkEnableOption "personal WiFi networks"; networks = lib.mkOption { type = with lib.types; listOf str; - default = ["home-private" "hotspot"]; + default = [ + "home-private" + "hotspot" + ]; }; extraNetworks = lib.mkOption { type = with lib.types; listOf (attrsOf str); - default = []; + default = [ ]; example = [ { id = "my-wifi"; @@ -65,20 +72,16 @@ in { }; }; - 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; + 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; } |
