hashcat: add CUDA support (#240735)

Previously, hashcat was unable to use CUDA at runtime, and would warn:

> Failed to initialize the NVIDIA main driver CUDA runtime library.
> Failed to initialize NVIDIA RTC library.
> * Device #1: CUDA SDK Toolkit not installed or incorrectly installed.
>              CUDA SDK Toolkit required for proper device support and utilization.
>              Falling back to OpenCL runtime.

This remedies that, at least on NixOS.
This commit is contained in:
Andrew Marshall 2023-07-01 04:59:09 -04:00 committed by GitHub
parent e8f97f0ff1
commit 54769c6fa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,8 @@
{ lib, stdenv
, addOpenGLRunpath
, config
, cudaPackages ? {}
, cudaSupport ? config.cudaSupport or false
, fetchurl
, makeWrapper
, opencl-headers
@ -15,7 +19,12 @@ stdenv.mkDerivation rec {
sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo=";
};
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [
makeWrapper
] ++ lib.optionals cudaSupport [
addOpenGLRunpath
];
buildInputs = [ opencl-headers xxHash ];
makeFlags = [
@ -34,8 +43,20 @@ stdenv.mkDerivation rec {
done
'';
postFixup = ''
wrapProgram $out/bin/hashcat --prefix LD_LIBRARY_PATH : ${ocl-icd}/lib
postFixup = let
LD_LIBRARY_PATH = builtins.concatStringsSep ":" ([
"${ocl-icd}/lib"
] ++ lib.optionals cudaSupport [
"${cudaPackages.cudatoolkit}/lib"
]);
in ''
wrapProgram $out/bin/hashcat \
--prefix LD_LIBRARY_PATH : ${lib.escapeShellArg LD_LIBRARY_PATH}
'' + lib.optionalString cudaSupport ''
for program in $out/bin/hashcat $out/bin/.hashcat-wrapped; do
isELF "$program" || continue
addOpenGLRunpath "$program"
done
'';
meta = with lib; {