From 43423300b5996f9f2845d164b8697edd8dfd92ff Mon Sep 17 00:00:00 2001 From: didier amyot Date: Wed, 30 Oct 2024 08:11:33 -0400 Subject: [PATCH] Added nvidia drivers --- flake.nix | 8 ++++++++ gcp-configuration.nix | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2381e36..b3e3af9 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,13 @@ { description = "Tool to build NixOS for GCP. "; + nixConfig = { + extra-substituters = [ + "https://cuda-maintainers.cachix.org" + ]; + extra-trusted-public-keys = [ + "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" + ]; + }; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; diff --git a/gcp-configuration.nix b/gcp-configuration.nix index d48baf8..d0ce55a 100644 --- a/gcp-configuration.nix +++ b/gcp-configuration.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, modulesPath, ... }: { +{ pkgs, lib, modulesPath, config, ... }: { imports = [ "${modulesPath}/virtualisation/google-compute-image.nix" ]; config = { @@ -55,6 +55,7 @@ bat ripgrep helix + (pkgs.python312.withPackages (ps: [ps.torch])) ]; nixpkgs.config.allowUnfree = true; nixpkgs.config.cudaSupport = true; @@ -62,5 +63,18 @@ services.openssh.settings.PasswordAuthentication = false; programs.zsh.enable = true; + services.xserver.videoDrivers = ["nvidia"]; + nix.settings.substituters = [ + "https://cuda-maintainers.cachix.org" + ]; + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + hardware.graphics.enable = true; }; }