blob: 88839f7f72cf6a5979e3d7488b8b266f9fbdb4fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
{
config,
lib,
...
}: 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 = {
};
};
};
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 = [];
example = [
{
id = "my-wifi";
ssid = "WiFi SSID";
}
];
};
};
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;
}
|