Merge pull request #327914 from 0z13/nvidia-container-toolkit-device-name

nixos/nvidia-container-toolkit: add device-name-strategy option
This commit is contained in:
Sarah Brofeldt 2024-08-13 10:41:45 +02:00 committed by GitHub
commit ba99ba8ea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -1,4 +1,5 @@
{
deviceNameStrategy,
glibc,
jq,
lib,
@ -25,6 +26,7 @@ writeScriptBin "nvidia-cdi-generator"
function cdiGenerate {
${lib.getExe' nvidia-container-toolkit "nvidia-ctk"} cdi generate \
--format json \
--device-name-strategy ${deviceNameStrategy} \
--ldconfig-path ${lib.getExe' glibc "ldconfig"} \
--library-search-path ${lib.getLib nvidia-driver}/lib \
--nvidia-ctk-path ${lib.getExe' nvidia-container-toolkit "nvidia-ctk"}

View File

@ -52,6 +52,17 @@
'';
};
device-name-strategy = lib.mkOption {
default = "index";
type = lib.types.enum [ "index" "uuid" "type-index" ];
description = ''
Specify the strategy for generating device names,
passed to `nvidia-ctk cdi generate`. This will affect how
you reference the device using `nvidia.com/gpu=` in
the container runtime.
'';
};
mount-nvidia-docker-1-directories = lib.mkOption {
default = true;
type = lib.types.bool;
@ -119,6 +130,7 @@
script = pkgs.callPackage ./cdi-generate.nix {
inherit (config.hardware.nvidia-container-toolkit) mounts;
nvidia-driver = config.hardware.nvidia.package;
deviceNameStrategy = config.hardware.nvidia-container-toolkit.device-name-strategy;
};
in
lib.getExe script;