Kieran's opinionated (and probably slightly dumb) nix config

feat: update the network manager module with suggestion from @isabelroses

dunkirk.sh 430ce776 017dc207

verified
Changed files
+28 -9
nixos
modules
network
+28 -9
nixos/modules/network/wifi.nix
···
+
# simple network manager
+
#
+
# This module provides a simpler way to declare wifi profiles with network manager.
+
# - you can pass the PSK via environment variable, direct value, or file.
+
# - profiles are defined in `modules.network.wifi.profiles`.
+
#
+
# Example usage:
+
# modules.network.wifi = {
+
# enable = true;
+
# profiles = {
+
# "MySSID" = { psk = "supersecret"; };
+
# };
+
# };
+
{
lib,
config,
···
let
cfg = config.modules.network.wifi;
mkProfile =
-
name: p:
+
name:
+
{
+
pskVar ? null,
+
psk ? null,
+
pskFile ? null,
+
}:
let
base = {
connection = {
···
};
};
sec =
-
if (p ? pskVar && p.pskVar != null) then
+
if pskVar != null then
{
wifi-security = {
key-mgmt = "wpa-psk";
-
psk = "$${" + p.pskVar + "}";
+
psk = "$${" + pskVar + "}";
};
}
-
else if (p ? psk && p.psk != null) then
+
else if psk != null then
{
wifi-security = {
key-mgmt = "wpa-psk";
-
psk = p.psk;
+
psk = psk;
};
}
-
else if (p ? pskFile && p.pskFile != null) then
+
else if pskFile != null then
{
wifi-security = {
key-mgmt = "wpa-psk";
-
psk = "$(" + pkgs.coreutils + "/bin/cat " + p.pskFile + ")";
+
psk = "$(" + pkgs.coreutils + "/bin/cat " + pskFile + ")";
};
}
else
···
enable = lib.mkEnableOption "Enable NetworkManager with simplified Wi-Fi profiles";
hostName = lib.mkOption {
type = lib.types.str;
-
default = config.networking.hostName or "";
+
default = lib.mkDefault (config.networking.hostName or "nixos");
};
nameservers = lib.mkOption {
type = lib.types.listOf lib.types.str;
-
default = [ ];
+
default = lib.mkDefault [ ];
};
envFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;