Skip to content

Commit 5069440

Browse files
committed
fix: set wsl.useWindowsDriver when the nvidia-ctk is enabled
This improves the user experience as whenever the user enables the `config.hardware.nvidia-container-toolkit.enable` option, they cannot use their Nvidia GPU's within the Docker containers because of missing libraries. This gets fixed by setting `wsl.useWindowsDriver` explicitly when the user requests to enable GPU support on Docker containers. Issue and fix provided by @qwqawawow Related: #433 Related: NVIDIA/nvidia-container-toolkit#452
1 parent 041bad0 commit 5069440

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
./build-tarball.nix
44
./docker-desktop.nix
55
./interop.nix
6+
./nvidia.nix
67
./recovery.nix
78
./systemd
89
./usbip.nix

modules/nvidia.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{ config, lib, ... }:
2+
{
3+
4+
config =
5+
lib.mkIf
6+
(
7+
config.wsl.enable &&
8+
(config.wsl.docker-desktop.enable ||
9+
config.virtualisation.podman.enable ||
10+
(config.virtualisation.docker.enable &&
11+
(lib.versionAtLeast config.virtualisation.docker.package.version "25")))
12+
)
13+
{
14+
15+
# Related issues:
16+
# - https://github.com/nix-community/NixOS-WSL/issues/433
17+
# - https://github.com/NVIDIA/nvidia-container-toolkit/issues/452
18+
#
19+
# By setting `useWindowsDriver` to true, the Nvidia libraries are properly
20+
# mounted on the container from the host.
21+
wsl.useWindowsDriver = lib.mkIf config.hardware.nvidia-container-toolkit.enable true;
22+
23+
};
24+
}

0 commit comments

Comments
 (0)