summaryrefslogtreecommitdiff
path: root/modules/nixos/personal/networking/wifi.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/personal/networking/wifi.nix')
-rw-r--r--modules/nixos/personal/networking/wifi.nix101
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;
}