From fc019d789523ce5f89436b8dbc458cf3b79abf43 Mon Sep 17 00:00:00 2001 From: aristote Date: Tue, 29 Jul 2025 15:25:11 +0200 Subject: reformat everything with nixfmt --- modules/nixos/personal/networking/wifi.nix | 101 +++++++++++++++-------------- 1 file changed, 52 insertions(+), 49 deletions(-) (limited to 'modules/nixos/personal/networking/wifi.nix') 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; } -- cgit v1.2.3