From 957209d2a0492dbc654114bd5b2f8136edeb5b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Sat, 21 Feb 2026 13:23:57 +0100 Subject: [PATCH] feat: extract nvidia module and cleanup matej-nixos HW config --- hosts/matej-nixos/configuration.nix | 23 +++++++ hosts/matej-nixos/hardware-configuration.nix | 70 -------------------- modules/nixos/nvidia.nix | 23 +++++++ 3 files changed, 46 insertions(+), 70 deletions(-) create mode 100644 modules/nixos/nvidia.nix diff --git a/hosts/matej-nixos/configuration.nix b/hosts/matej-nixos/configuration.nix index ebb72c9..56f1cab 100644 --- a/hosts/matej-nixos/configuration.nix +++ b/hosts/matej-nixos/configuration.nix @@ -23,6 +23,7 @@ in inputs.self.nixosModules.gnupg inputs.self.nixosModules.tuigreet inputs.self.nixosModules.workstation + inputs.self.nixosModules.nvidia ]; # Modules @@ -43,6 +44,8 @@ in cmdFlags = [ "--unsupported-gpu" ]; }; + nvidia.enable = true; + # Stylix theming stylix = { enable = true; @@ -87,6 +90,26 @@ in # Hardware hardware.keyboard.zsa.enable = true; hardware.ledger.enable = true; + hardware.bluetooth.powerOnBoot = true; + + # Networking + networking = { + hostName = "matej-nixos"; + useDHCP = false; + networkmanager.enable = true; + interfaces.enp5s0.ipv4.addresses = [ + { + address = "10.222.0.247"; + prefixLength = 24; + } + ]; + firewall.enable = false; + defaultGateway = "10.222.0.1"; + nameservers = [ + "1.1.1.1" + "8.8.8.8" + ]; + }; # XDG xdg.mime.defaultApplications = { diff --git a/hosts/matej-nixos/hardware-configuration.nix b/hosts/matej-nixos/hardware-configuration.nix index d8081f3..ee606b2 100644 --- a/hosts/matej-nixos/hardware-configuration.nix +++ b/hosts/matej-nixos/hardware-configuration.nix @@ -75,76 +75,6 @@ { device = "/dev/disk/by-uuid/ff4750e7-3a9f-42c2-bb68-c458a6560540"; } ]; - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking - # (the default) this is the recommended approach. When using systemd-networkd it's - # still possible to use this option, but it's recommended to use it in conjunction - # with explicit per-interface declarations with `networking.interfaces..useDHCP`. - - networking = { - useDHCP = false; - hostName = "matej-nixos"; - networkmanager.enable = true; # Easiest to use and most distros use this by default. - interfaces.enp5s0.ipv4.addresses = [ - { - address = "10.222.0.247"; - prefixLength = 24; - } - ]; - firewall = { - enable = false; - allowedTCPPorts = lib.range 8800 8900; - }; - defaultGateway = "10.222.0.1"; - nameservers = [ - "1.1.1.1" - "8.8.8.8" - ]; - - }; - # networking.interfaces.enp4s0.useDHCP = lib.mkDefault true; - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - - # TODO: maybe move later - hardware.bluetooth.enable = true; # enables support for Bluetooth - hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot - - # Enable OpenGL - hardware.graphics = { - enable = true; - }; - - # Load nvidia driver for Xorg and Wayland - services.xserver.videoDrivers = [ "nvidia" ]; - - hardware.nvidia = { - # Modesetting is required. - modesetting.enable = true; - - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - # Enable this if you have graphical corruption issues or application crashes after waking - # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead - # of just the bare essentials. - powerManagement.enable = false; - - # Fine-grained power management. Turns off GPU when not in use. - # Experimental and only works on modern Nvidia GPUs (Turing or newer). - powerManagement.finegrained = false; - - # Use the NVidia open source kernel module (not to be confused with the - # independent third-party "nouveau" open source driver). - # Support is limited to the Turing and later architectures. Full list of - # supported GPUs is at: - # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus - # Only available from driver 515.43.04+ - open = true; - - # Enable the Nvidia settings menu, - # accessible via `nvidia-settings`. - nvidiaSettings = true; - - # Optionally, you may need to select the appropriate driver version for your specific GPU. - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; } diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix new file mode 100644 index 0000000..85164a4 --- /dev/null +++ b/modules/nixos/nvidia.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: +{ + options = { + nvidia.enable = lib.mkEnableOption "NVIDIA GPU support"; + }; + + config = lib.mkIf config.nvidia.enable { + hardware.graphics.enable = true; + + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.nvidia = { + modesetting.enable = true; + open = true; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + }; +}