programs.nix-required-mounts.presets.zluda.enable: init (#501095)

This commit is contained in:
Someone
2026-04-09 21:17:16 +00:00
committed by GitHub
2 changed files with 67 additions and 21 deletions
@@ -67,6 +67,23 @@ let
# TODO: Refactor `hardware.graphics` to ease referencing the closure
# NOTE: A naive implementation may e.g. introduce a conditional infinite recursion (https://github.com/NixOS/nixpkgs/pull/488199)
nvidia-gpu.unsafeFollowSymlinks = true;
zluda = {
onFeatures = [
"cuda"
];
paths = [
pkgs.addDriverRunpath.driverLink
"/dev/dri"
"/dev/kfd"
"/sys/devices/virtual/kfd"
# As per https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
# 226 is the major ID for "Direct Rendering Infrastructure (DRI)" devices
"/sys/dev/char/226:*"
]
++ config.hardware.graphics.extraPackages;
unsafeFollowSymlinks = true;
};
};
in
{
@@ -82,6 +99,16 @@ in
You may extend or override the exposed paths via the
`programs.nix-required-mounts.allowedPatterns.nvidia-gpu.paths` option.
'';
presets.zluda.enable = lib.mkEnableOption ''
Same as `programs.nix-required-mounts.presets.nvidia-gpu` but adds paths
to the sandbox that are needed for running CUDA applications on top of
the ZLUDA translation layer combined with AMD GPUs.
You may extend or override the exposed paths via the
`programs.nix-required-mounts.allowedPatterns.zluda.paths` option.
'';
allowedPatterns =
with lib.types;
lib.mkOption {
@@ -122,6 +149,14 @@ in
inherit (defaults) nvidia-gpu;
};
})
(lib.mkIf cfg.presets.zluda.enable {
hardware.graphics.enable = lib.mkDefault true;
hardware.amdgpu.zluda.enable = lib.mkDefault true;
nix.settings.system-features = cfg.allowedPatterns.zluda.onFeatures;
programs.nix-required-mounts.allowedPatterns = {
inherit (defaults) zluda;
};
})
]
);
}
+32 -21
View File
@@ -40,30 +40,41 @@ in
};
opencl.enable = lib.mkEnableOption "OpenCL support using ROCM runtime library";
zluda.enable = lib.mkEnableOption "CUDA support using ZLUDA runtime library";
zluda.package = lib.mkPackageOption pkgs "zluda" { };
};
config = {
boot.kernelParams =
lib.optionals cfg.legacySupport.enable [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
]
++ lib.optionals cfg.overdrive.enable [
"amdgpu.ppfeaturemask=${cfg.overdrive.ppfeaturemask}"
];
config = lib.mkMerge [
{
boot.kernelParams =
lib.optionals cfg.legacySupport.enable [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
]
++ lib.optionals cfg.overdrive.enable [
"amdgpu.ppfeaturemask=${cfg.overdrive.ppfeaturemask}"
];
boot.initrd.kernelModules = lib.optionals cfg.initrd.enable [ "amdgpu" ];
hardware.graphics = lib.mkIf cfg.opencl.enable {
enable = lib.mkDefault true;
extraPackages = [
pkgs.rocmPackages.clr
pkgs.rocmPackages.clr.icd
];
};
};
boot.initrd.kernelModules = lib.optionals cfg.initrd.enable [ "amdgpu" ];
}
(lib.mkIf cfg.opencl.enable {
hardware.graphics = {
enable = lib.mkDefault true;
extraPackages = [
pkgs.rocmPackages.clr
pkgs.rocmPackages.clr.icd
];
};
})
(lib.mkIf cfg.zluda.enable {
hardware.graphics = {
enable = lib.mkDefault true;
extraPackages = [ cfg.zluda.package ];
};
})
];
meta = {
maintainers = with lib.maintainers; [ johnrtitor ];