move wifi to components

This commit is contained in:
Ingolf Wagner 2023-06-01 11:38:39 +02:00
parent 6e43db6c79
commit 827215d700
Signed by: palo
GPG key ID: 76BF5F1928B9618B
10 changed files with 70 additions and 15 deletions

View file

@ -1,8 +1,20 @@
{ ... }:
{ pkgs, lib, ... }:
with lib;
with types;
{
options.components.network = {
enable = mkOption {
type = bool;
default = true;
};
};
imports = [
./sshd
./tinc
./hosts.nix
./wifi.nix
];
config = mkIf config.components.network.enable { };
}

View file

@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
with lib;
with types;
{
options.components.network.wifi.enable = mkOption {
type = bool;
default = config.components.network.enable;
};
config = mkIf config.components.network.wifi.enable {
networking.usePredictableInterfaceNames = true;
networking.networkmanager.enable = true;
networking.networkmanager.wifi.powersave = lib.mkDefault true;
networking.networkmanager.extraConfig = ''
# The number of times a connection activation should be automatically tried
# before switching to another one. This value applies only to connections
# that can auto-connect and have a connection. autoconnect-retries property set to -1.
# If not specified, connections will be tried 4 times.
# Setting this value to 1 means to try activation once, without retry.
autoconnect-retries-default=999
'';
hardware.enableRedistributableFirmware = true;
# because Networkd-wait-online is just failing.
systemd.services.systemd-networkd-wait-online.enable = false;
systemd.services.NetworkManager-wait-online.enable = false;
environment.systemPackages = [
(pkgs.writeShellScriptBin "scan-wifi" ''
# todo : use column to make a nice view
${pkgs.wirelesstools}/bin/iwlist scan | \
grep -v "Interface doesn't support scanning" | \
sed -e '/^\s*$/d' | \
grep -e "ESSID" -e "Encrypt" | \
sed -e "s/Encryption key:on/encrypted/g" | \
sed -e "s/Encryption key:off/open/g" | \
sed -e "s/ESSID://g" | \
xargs -L 2 printf "%9s - '%s'\n"
'')
];
};
}

View file

@ -45,6 +45,8 @@
];
components.network.enable = true;
components.network.wifi.enable = false;
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;

View file

@ -30,12 +30,13 @@
components.gui.enable = true;
components.terminal.enable = true;
components.network.enable = true;
components.network.wifi.enable = true;
services.nginx.enable = true;
networking.hostName = "cream";
system.custom.wifi.interfaces = [ "wlp166s0" ];
services.flatpak.enable = true;

View file

@ -59,6 +59,8 @@
./sync-torrent.nix
];
components.network.enable = true;
components.network.wifi.enable = false;
system.custom.mainUser.enable = true;
system.custom.mainUser.userName = "palo";

View file

@ -36,7 +36,6 @@
./system/bluetooth.nix
./system/font.nix
./system/mainUser.nix
./system/wifi.nix
./system/on-failure.nix
];

View file

@ -1,3 +0,0 @@
{ config, lib, pkgs, ... }:
{ }

View file

@ -1,2 +0,0 @@
{ config, lib, ... }:
{ }

View file

@ -8,7 +8,6 @@
./audio.nix
./cachix.nix
./mail-stuff.nix
./network.nix
./packages.nix
./size.nix
./user.nix

View file

@ -1,6 +0,0 @@
{ config, pkgs, lib, ... }: {
system.custom.wifi = {
enable = true;
system = "networkmanager";
};
}