From 22af8932eed8e073f462759d42704812e14af32b Mon Sep 17 00:00:00 2001 From: smayzy Date: Sat, 5 Jul 2025 13:03:23 +0200 Subject: [PATCH] try to make nvidia module toogleable --- hosts/desktop1/configuration.nix | 2 ++ modules/nix/nvidia.nix | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hosts/desktop1/configuration.nix b/hosts/desktop1/configuration.nix index 9190cf6..d08a477 100644 --- a/hosts/desktop1/configuration.nix +++ b/hosts/desktop1/configuration.nix @@ -9,6 +9,8 @@ ../../modules/nix/virt.nix ]; + smayzy.nvidia.enable = true; + home-manager = { extraSpecialArgs = { inherit inputs; }; users = { diff --git a/modules/nix/nvidia.nix b/modules/nix/nvidia.nix index 79d1243..eea7c3f 100644 --- a/modules/nix/nvidia.nix +++ b/modules/nix/nvidia.nix @@ -1,10 +1,21 @@ { config, lib, pkgs, ... }: +let + inherit (lib) mkIf mkOption types; +in { - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.nvidia = { - modesetting.enable = true; - open = true; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; + options.smayzy.nvidia.enable = mkOption { + type = types.bool; + default = false; + description = "set to true if you want to use a nvidia GC"; + }; + + config = mkIf config.smayzy.nvidia.enable { + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.nvidia = { + modesetting.enable = true; + open = true; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; }; }