summaryrefslogtreecommitdiff
path: root/modules/nixos/personal/networking/wifi.nix
blob: 74164545b18107a27eafa451dd8676819e88f026 (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
{
  config,
  lib,
  ...
}: let
  cfg = config.personal.networking.wifi;
  mkWifiProfile = {
    id,
    ssid,
  }: {
    "${id}" = {
      connection = {
        inherit id;
        type = "wifi";
      };
      wifi = {
        inherit ssid;
        mode = "infrastructure";
      };
      wifi-security = {
        key-mgmt = "wpa-psk";
        # fill-in password on first connection
      };
      ipv4 = {
        method = "auto";
      };
      ipv6 = {
        addr-gen-mode = "stable-privacy";
        method = "auto";
      };
      proxy = {
      };
    };
  };
in {
  options.personal.networking.wifi = {
    enable = lib.mkEnableOption "personal WiFi networks";
    networks = lib.mkOption {
      type = with lib.types; listOf (attrsOf str);
      default = [
        {
          id = "home-private";
          ssid = "Quentintranet";
        }
        {
          id = "hotspot";
          ssid = "Quentinternational";
        }
        {
          id = "home-cercier";
          ssid = "ARISTOTE";
        }
      ];
    };
  };

  config.networking.networkmanager.ensureProfiles.profiles = lib.mkIf cfg.enable (lib.mergeAttrsList (builtins.map mkWifiProfile cfg.networks));
}