summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2026-06-17 17:24:26 -0500
committerTim Keller <tjk@tjkeller.xyz>2026-06-17 17:24:26 -0500
commit20256167c33db9c6b762a5bcf0b6678de45653d0 (patch)
tree63c6fe9e9e9ef36d0437939f4b65a725d5ca831f
parentaf63e346ff5542559dc507b0a901a4d8b370d4d3 (diff)
downloadnixos-20256167c33db9c6b762a5bcf0b6678de45653d0.tar.xz
nixos-20256167c33db9c6b762a5bcf0b6678de45653d0.zip
cuda support and immich cuda support
-rw-r--r--archetypes/profiles/cuda/default.nix28
-rw-r--r--archetypes/profiles/default.nix1
-rw-r--r--hosts/optiplex/configuration.nix1
-rw-r--r--hosts/poweredge/configuration.nix12
-rw-r--r--hosts/poweredge/immich.nix80
5 files changed, 102 insertions, 20 deletions
diff --git a/archetypes/profiles/cuda/default.nix b/archetypes/profiles/cuda/default.nix
new file mode 100644
index 0000000..14de560
--- /dev/null
+++ b/archetypes/profiles/cuda/default.nix
@@ -0,0 +1,28 @@
+{ lib, pkgs, ... }: let
+ mkCuda = lib.mkOverride 800;
+
+ nixosConfig = {
+ # Binary cache packages built with cudaSupport
+ nix.settings = {
+ substituters = mkCuda [ "https://cache.nixos-cuda.org" ];
+ trusted-public-keys = mkCuda [ "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" ];
+ };
+
+ # Enable cudaSupport
+ nixpkgs.config.cudaSupport = mkCuda true;
+
+ # Nvidia packages
+ environment.systemPackages = with pkgs; mkCuda [
+ config.hardware.nvidia.package # nvidia-smi
+ nvtopPackages.nvidia
+ ];
+
+ # Enable nvidia graphics
+ services.xserver.videoDrivers = mkCuda [ "nvidia" ]; # xserver.videoDrivers does not imply X
+ hardware.graphics.enable = mkCuda true;
+ };
+
+ homeConfig = {};
+in {
+ imports = [ (lib._mkProfileArchetype "cuda" nixosConfig homeConfig) ];
+}
diff --git a/archetypes/profiles/default.nix b/archetypes/profiles/default.nix
index 23b5c05..ef5d87b 100644
--- a/archetypes/profiles/default.nix
+++ b/archetypes/profiles/default.nix
@@ -1,6 +1,7 @@
{
imports = [
./btrfs
+ ./cuda
./desktop
./headless
./pi
diff --git a/hosts/optiplex/configuration.nix b/hosts/optiplex/configuration.nix
index 74d09b5..5108e72 100644
--- a/hosts/optiplex/configuration.nix
+++ b/hosts/optiplex/configuration.nix
@@ -80,6 +80,7 @@
hardware.nvidia = {
modesetting.enable = true; # Required
powerManagement.enable = false; # Can cause bugs
+ powerManagement.finegrained = false; # Only works on turing and newer
nvidiaSettings = true;
open = false; # Not compatible w/ GTX-1050
package = config.boot.kernelPackages.nvidiaPackages.legacy_580;
diff --git a/hosts/poweredge/configuration.nix b/hosts/poweredge/configuration.nix
index 3935daf..40803bf 100644
--- a/hosts/poweredge/configuration.nix
+++ b/hosts/poweredge/configuration.nix
@@ -11,6 +11,9 @@
#./notification-mailer.nix # TODO move some of this stuff to archetype
];
+ # Allow unfree packages for nvidia/cuda
+ nixpkgs.config.allowUnfree = true;
+
# Setup bootloader
boot._loader.enable = true;
@@ -22,6 +25,7 @@
home.users.timmy.enable = true;
};
zfs.enable = true;
+ cuda.enable = true;
};
};
@@ -30,8 +34,12 @@
# Enable nvidia
hardware.nvidia = {
- open = false; # Need for NVENC
- package = config.boot.kernelPackages.nvidiaPackages.stable;
+ modesetting.enable = true; # Required
+ nvidiaSettings = false; # Don't need gui
+ open = false;
+ package = config.boot.kernelPackages.nvidiaPackages.legacy_580; # Support for P600
+ powerManagement.enable = false; # Can cause bugs
+ powerManagement.finegrained = false; # Only works on turing and newer
};
# Enable user timmy
diff --git a/hosts/poweredge/immich.nix b/hosts/poweredge/immich.nix
index 51d7885..24b32c2 100644
--- a/hosts/poweredge/immich.nix
+++ b/hosts/poweredge/immich.nix
@@ -1,4 +1,6 @@
-{
+{ pkgs, ... }: let
+ onnxruntimeCuda = pkgs.onnxruntime.override { cudaSupport = true; };
+in {
containers.immich = {
autoStart = true;
privateNetwork = true;
@@ -14,30 +16,55 @@
};
# GPU
- #allowedDevices = [
- # { node = "/dev/dri/card1"; modifier = "rw"; }
- # { node = "/dev/dri/renderD128"; modifier = "rw"; }
- #];
-
- #bindMounts = {
- # "/dev/dri/card1" = {
- # hostPath = "/dev/dri/card1";
- # isReadOnly = false;
- # };
- # "/dev/dri/renderD128" = {
- # hostPath = "/dev/dri/renderD128";
- # isReadOnly = false;
- # };
- #};
+ allowedDevices = [
+ { node = "/dev/nvidia0"; modifier = "rw"; }
+ { node = "/dev/nvidiactl"; modifier = "rw"; }
+ { node = "/dev/nvidia-uvm"; modifier = "rw"; }
+ { node = "/dev/nvidia-uvm-tools"; modifier = "rw"; }
+ { node = "/dev/nvidia-modeset"; modifier = "rw"; }
+ ];
+
+ bindMounts = {
+ # NVENC/NVDEC - video transcoding
+ "/dev/nvidia0" = { hostPath = "/dev/nvidia0"; isReadOnly = false; };
+ "/dev/nvidiactl" = { hostPath = "/dev/nvidiactl"; isReadOnly = false; };
+ # CUDA - required for ML inference
+ "/dev/nvidia-uvm" = { hostPath = "/dev/nvidia-uvm"; isReadOnly = false; };
+ "/dev/nvidia-uvm-tools" = { hostPath = "/dev/nvidia-uvm-tools"; isReadOnly = false; };
+ # Modeset - needed by some driver paths
+ "/dev/nvidia-modeset" = { hostPath = "/dev/nvidia-modeset"; isReadOnly = false; };
+ };
config = { lib, pkgs, config, ... }: {
# Network
networking.interfaces.eth0.useDHCP = true;
networking.firewall.allowedTCPPorts = [ 80 ]; # Caddy
+ # Configure nixpkgs for nvidia/cuda
+ nixpkgs.config.allowUnfree = true;
+ nixpkgs.config.cudaSupport = true;
+
# Immich
- services.immich.enable = true;
- environment.systemPackages = with pkgs; [ immich immich-cli ];
+ services.immich = {
+ enable = true;
+ accelerationDevices = [
+ "/dev/nvidia0"
+ "/dev/nvidiactl"
+ "/dev/nvidia-uvm"
+ "/dev/nvidia-uvm-tools"
+ "/dev/nvidia-modeset"
+ ];
+
+ # Tell immich-server to use NVENC for transcoding
+ environment = {
+ NVIDIA_VISIBLE_DEVICES = "all";
+ NVIDIA_DRIVER_CAPABILITIES = "compute,video,utility";
+ };
+
+ # Enable the ML microservice with CUDA
+ machine-learning.enable = true;
+ };
+ #environment.systemPackages = with pkgs; [ immich immich-cli ];
# Reverse proxy
services.caddy = {
@@ -47,6 +74,23 @@
'';
};
+ # NVIDIA
+ services.xserver.videoDrivers = [ "nvidia" ]; # xserver.videoDrivers does not imply X
+ hardware.graphics.enable = true;
+ hardware.nvidia = {
+ modesetting.enable = true; # Required
+ nvidiaSettings = false; # Don't need gui
+ open = false;
+ package = config.boot.kernelPackages.nvidiaPackages.legacy_580; # Must match host
+ };
+
+ # Packages
+ environment.systemPackages = with pkgs; [
+ immich
+ immich-cli
+ config.hardware.nvidia.package # nvidia-smi
+ ];
+
system.stateVersion = "25.11";
};
};