From 2d395532c2bf26d39d9a333d05d7f74ae8abab7b Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 10 Jun 2024 14:22:24 -0400 Subject: [PATCH] tips&tricks: expanded wifi notes --- Tips & Tricks.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Tips & Tricks.md b/Tips & Tricks.md index 56ca1aa..b93aed3 100644 --- a/Tips & Tricks.md +++ b/Tips & Tricks.md @@ -8,14 +8,22 @@ 7. Rebuild the new system from git. Secrets will be automatically decrypted and immediately available in `/run/agenix/`. 8. (OPTIONAL) Generate a new user SSH key and add it to `nixosModules/users/default.nix` in order to enable passwordless logins to other hosts. -## WiFi +## Declarative WiFi Connections -WiFi networks can be configured declratively in `nixosModules/system/wifi.nix` using `networking.networkmanager.ensureProfiles.profiles`, provided by nixpkgs. +WiFi networks can be configured declaratiely in `nixosModules/system/wifi.nix` using `config.networking.networkmanager.ensureProfiles.profiles`, provided by nixpkgs. -### Generating WiFi Profiles - -[nm2nix](https://github.com/janik-haag/nm2nix) can generate nix-compatible code for all the WiFi networks in `/etc/NetworkManager/system-connections/` and `/run/NetworkManager/system-connections`. +[nm2nix](https://github.com/janik-haag/nm2nix) can generate nix code for all WiFi networks currently configured in `/etc/NetworkManager/system-connections/` and `/run/NetworkManager/system-connections` with the following command: ```bash sudo su -c "cd /etc/NetworkManager/system-connections && nix --extra-experimental-features 'nix-command flakes' run github:Janik-Haag/nm2nix | nix --extra-experimental-features 'nix-command flakes' run nixpkgs#nixfmt-rfc-style" -``` \ No newline at end of file +``` + +[[Secrets]] (passwords, certificates, and identities) are supported, but must be declared and available as variables with agenix. They will be replaced upon activation with `envsubst`. + +In short, +1. Manually configure the WiFi network on one device. +1. Export configuration to nix with `nm2nix`. +1. Add secrets to `secrets/wifi.age` as variables (e.g. `MYPSK=1234567890`) +1. Edit the code generated by `nm2nix` to reference `$MYPSK` instead of directly declaring the WPA password. +1. Commit and push changes. +1. Rebuild hosts as required to propogate your new WiFi configuration. \ No newline at end of file