Use environmentFile for wireless network configuration

This commit is contained in:
Charlotte Van Petegem 2021-10-22 17:20:40 +02:00
parent 52e05029ee
commit 336a353639
No known key found for this signature in database
GPG key ID: 019E764B7184435A
7 changed files with 87 additions and 27 deletions

View file

@ -3,6 +3,6 @@
{
imports = [
./ovh.nix
./networkmanager.nix
./mobile.nix
];
}

View file

@ -0,0 +1,55 @@
{ config, lib, pkgs, ... }:
{
options.chvp.base.network.mobile = {
enable = lib.mkOption {
default = false;
example = true;
};
wireless-interface = lib.mkOption {
type = lib.types.str;
example = "wlp2s0";
};
wired-interfaces = lib.mkOption {
example = { "enp0s29f0u1u2" = { macAddress = "10:65:30:85:bb:18"; }; };
};
};
config = with config.chvp.base.network.mobile; lib.mkIf enable {
networking = {
wireless = {
enable = true;
interfaces = [ wireless-interface ];
environmentFile = config.age.secrets."passwords/networks.age".path;
networks = {
"Public Universal Friend".psk = "@PSK_PUF@";
AndroidAP.psk = "@PSK_AndroidAP@";
draadloosnw.psk = "@PSK_draadloosnw@";
Secorima.psk = "@PSK_Secorima@";
eduroam = {
authProtocols = [ "WPA-EAP" ];
auth = ''
eap=PEAP
identity="@EDUROAM_USER@"
password="@EDUROAM_PASS@"
'';
extraConfig = ''
phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
group=CCMP TKIP
ca_cert="/etc/ssl/certs/ca-bundle.crt"
altsubject_match="DNS:ugnps.ugent.be"
'';
};
};
};
interfaces = {
"${wireless-interface}".useDHCP = true;
} // lib.mapAttrs (name: attrs: { useDHCP = true; } // attrs) wired-interfaces;
};
age.secrets."passwords/networks.age" = {
file = ../../../secrets/passwords/networks.age;
};
};
}

View file

@ -1,24 +0,0 @@
{ config, lib, pkgs, ... }:
{
options.chvp.base.network.networkmanager.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.base.network.networkmanager.enable {
chvp.base.zfs.systemLinks = [
{ path = "/etc/NetworkManager/system-connections"; type = "data"; }
];
networking.networkmanager = {
enable = true;
wifi.macAddress = "random";
};
users.users.charlotte.extraGroups = [ "networkmanager" ];
home-manager.users.charlotte = { ... }: {
home.packages = with pkgs; [ networkmanagerapplet ];
};
};
}