From e811bea33d40fa0fbc2d3fdf298cce21ddd92926 Mon Sep 17 00:00:00 2001 From: Vali Date: Fri, 16 Aug 2024 13:32:13 +0200 Subject: [PATCH] system: add config for networking and hardware --- modules/system/boot/grub-boot.nix | 8 ++++- modules/system/hardware/bluetooth.nix | 20 +++++++++++ modules/system/hardware/graphics.nix | 36 +++++++++++++++++++ modules/system/hardware/module.nix | 0 modules/system/hardware/wifi.nix | 0 modules/system/nix/module.nix | 24 +++++-------- modules/system/os/networking/module.nix | 21 +++++++++++ .../system/os/networking/networkmanager.nix | 26 ++++++++++++++ 8 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 modules/system/hardware/bluetooth.nix create mode 100644 modules/system/hardware/graphics.nix create mode 100644 modules/system/hardware/module.nix create mode 100644 modules/system/hardware/wifi.nix create mode 100644 modules/system/os/networking/module.nix create mode 100644 modules/system/os/networking/networkmanager.nix diff --git a/modules/system/boot/grub-boot.nix b/modules/system/boot/grub-boot.nix index 382acc5..456d13f 100644 --- a/modules/system/boot/grub-boot.nix +++ b/modules/system/boot/grub-boot.nix @@ -7,4 +7,10 @@ device = "nodev"; }; }; - } + boot.plymouth = { + enable = true; + # font = "${pkgs.jetbrains-mono}/share/fonts/truetype/JetBrainsMono-Regular.ttf"; + themePackages = [pkgs.catppuccin-plymouth]; + theme = "catppuccin-macchiato"; + }; +} diff --git a/modules/system/hardware/bluetooth.nix b/modules/system/hardware/bluetooth.nix new file mode 100644 index 0000000..5257758 --- /dev/null +++ b/modules/system/hardware/bluetooth.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + pkgs, +}: let + cfg = config.modules.system.hardware.bluetooth; + inherit (config.modules.other.system) username; + inherit (lib) mkIf; +in { + confg = mkIf cfg.enable { + hardware.bluetooth = { + enable = true; + powerOnBoot = mkIf cfg.powerOnBoot true; + }; + + home-manager.users.${username}.home.Packages = with pkgs; [ + bluetuith + ]; + }; +} diff --git a/modules/system/hardware/graphics.nix b/modules/system/hardware/graphics.nix new file mode 100644 index 0000000..f138b4f --- /dev/null +++ b/modules/system/hardware/graphics.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.modules.system.hardware; + inherit (cfg) amd nvidia; + inherit (lib) mkIf; +in { + config = { + hardware = { + graphics = { + enable = true; + extraPackages = with pkgs; + mkIf amd.enable [ + mesa + libva + vaapiVdpau + ]; + }; + }; + nvidia = mkIf nvidia.enable { + modesetting.enable = true; + open = false; + powerManagement = { + enable = true; + finegrained = false; + nvidiaSettings = false; + package = config.boot.kernelPackges.nvidiaPackages.beta; + }; + }; + boot.initrd.kernelModules = mkIf amd.enable ["amdgpu"]; + services.xserver.videoDrivers = mkIf nvidia.enable ["nvidia"]; + }; +} diff --git a/modules/system/hardware/module.nix b/modules/system/hardware/module.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/system/hardware/wifi.nix b/modules/system/hardware/wifi.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/system/nix/module.nix b/modules/system/nix/module.nix index 60debff..abd2f23 100644 --- a/modules/system/nix/module.nix +++ b/modules/system/nix/module.nix @@ -29,7 +29,6 @@ }; # Automatically optimize nix store by removing hard links - # do it after the gc. optimise = { automatic = true; dates = ["21:00"]; @@ -55,18 +54,16 @@ # the same as the number of cores your CPU has. max-jobs = "auto"; - # Always build inside sandboxed environments + # If set, Nix will perform builds in a sandboxed environment + # that it will set up automatically for each build. + # This prevents impurities in builds by disallowing access + # to dependencies outside of the Nix store by using network + # and mount namespaces in a chroot environment. sandbox = true; - sandbox-fallback = false; # Continue building derivations even if one fails keep-going = true; - # Fallback to local builds after remote builders are unavailable. - # Setting this too low on a slow network may cause remote builders - # to be discarded before a connection can be established. - connect-timeout = 5; - # If we haven't received data for >= 20s, retry the download stalled-download-timeout = 20; @@ -120,8 +117,7 @@ # external builders can also pick up those substituters builders-use-substitutes = true; - # Substituters to pull from. While sigs are disabled, we must - # make sure the substituters listed here are trusted. + # Substituters to pull from. substituters = [ "https://cache.nixos.org" # funny binary cache "https://cache.privatevoid.net" # for nix-super @@ -146,12 +142,8 @@ }; }; - # By default nix-gc makes no effort to respect battery life by avoiding - # GC runs on battery and fully commits a few cores to collecting garbage. - # This will drain the battery faster than you can say "Nix, what the hell?" - # and contribute heavily to you wanting to get a new desktop. - # For those curious (such as myself) desktops are always seen as "AC powered" - # so the system will not fail to fire if you are on a desktop system. + # Do not run garbage collection on AC power. + # This makes a quite nice difference in battery life. systemd.services.nix-gc = { unitConfig.ConditionACPower = true; }; diff --git a/modules/system/os/networking/module.nix b/modules/system/os/networking/module.nix new file mode 100644 index 0000000..fd4ca78 --- /dev/null +++ b/modules/system/os/networking/module.nix @@ -0,0 +1,21 @@ +{config, ...}: let + inherit (config.modules.other.system) username; +in { + imports = [ + ./networkmanager.nix + ]; + networking = { + enableIPv6 = true; + nameservers = [ + # quad9 DNS + "9.9.9.9" + "2620::fe::fe" + ]; + }; + services.resolved = { + enable = true; + # quad9 dns + fallbackDns = ["9.9.9.9" "2620::fe::fe"]; + }; + users.users.${username}.extraGroups = ["networkmanager"]; +} diff --git a/modules/system/os/networking/networkmanager.nix b/modules/system/os/networking/networkmanager.nix new file mode 100644 index 0000000..08e715d --- /dev/null +++ b/modules/system/os/networking/networkmanager.nix @@ -0,0 +1,26 @@ +{lib, ...}: let + inherit (lib) mkForce; +in { + networking.networkmanager = { + enable = true; + # Removes about 2GB of stuff we do no need. + plugins = mkForce []; + + dns = "systemd-resolved"; + unmanaged = [ + # DO NOT manage my docker containers, thank you. + "interface-name:docker*" + ]; + wifi = { + # Generate a randomized value upon each connect + macAdress = "random"; + + # Enable Wi-Fi power saving + powersave = true; + + # Backend is either wpa_supplicant or iwd, + # we use wpa_supplicant. + backend = "wpa_supplicant"; + }; + }; +}