diff --git a/pkgs/development/cuda-modules/write-gpu-python-test.nix b/pkgs/development/cuda-modules/write-gpu-python-test.nix index 5f0d5c6b8fe6..10b10fa3f923 100644 --- a/pkgs/development/cuda-modules/write-gpu-python-test.nix +++ b/pkgs/development/cuda-modules/write-gpu-python-test.nix @@ -2,16 +2,40 @@ lib, writers, runCommand, + python3Packages, }: { feature ? "cuda", name ? feature, - libraries ? [ ], + libraries ? [ ], # [PythonPackage] | (PackageSet -> [PythonPackage]) }: + +let + inherit (builtins) isFunction all; + librariesFun = if isFunction libraries then libraries else (_: libraries); +in + +assert lib.assertMsg ( + isFunction libraries || all (python3Packages.hasPythonModule) libraries +) "writeGpuTestPython was passed `libraries` from the wrong python release"; + content: let - tester = writers.writePython3Bin "tester-${name}" { inherit libraries; } content; + interpreter = python3Packages.python.withPackages librariesFun; + tester = + runCommand "tester-${name}" + { + inherit content; + passAsFile = [ "content" ]; + } + '' + mkdir -p "$out"/bin + cat << EOF >"$out"/bin/"tester-${name}" + #!${lib.getExe interpreter} + EOF + cat "$contentPath" >>"$out"/bin/"tester-${name}" + ''; tester' = tester.overrideAttrs (oldAttrs: { passthru.gpuCheck = runCommand "test-${name}"