diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 284ee5778101..38f3e226d0ff 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -374,15 +374,7 @@ stdenv.mkDerivation (finalAttrs: { ''; }; - gpuChecks.cudaAvailable = { blenderWithCuda, runCommand }: runCommand - "blender-cuda-available" - { - nativeBuildInputs = [ blenderWithCuda ]; - requiredSystemFeatures = [ "cuda" ]; - } - '' - blender --background -noaudio --python-exit-code 1 --python ${./test-cuda.py} && touch $out - '' { }; + gpuChecks = callPackage ./gpu-checks.nix { }; }; meta = { diff --git a/pkgs/applications/misc/blender/gpu-checks.nix b/pkgs/applications/misc/blender/gpu-checks.nix new file mode 100644 index 000000000000..144cdeb968c4 --- /dev/null +++ b/pkgs/applications/misc/blender/gpu-checks.nix @@ -0,0 +1,29 @@ +{ + bash, + blender, + callPackage, + lib, + runCommand, + writeScriptBin, +}: + +let + blenderWithCuda = blender.override {cudaSupport = true;}; + name = "${blenderWithCuda.name}-check-cuda"; + unwrapped = writeScriptBin "${name}-unwrapped" '' + #!${lib.getExe bash} + ${lib.getExe blenderWithCuda} --background -noaudio --python-exit-code 1 --python ${./test-cuda.py} + ''; +in +{ + cudaAvailable = + runCommand name + { + nativeBuildInputs = [unwrapped]; + requiredSystemFeatures = ["cuda"]; + passthru = { + inherit unwrapped; + }; + } + "${name}-unwrapped && touch $out"; +}