5 , cudaSupport ? config.cudaSupport
11 , Foundation, IOKit, Metal, OpenCL, libiconv
14 stdenv.mkDerivation rec {
19 url = "https://hashcat.net/files/hashcat-${version}.tar.gz";
20 sha256 = "sha256-sl4Qd7zzSQjMjxjBppouyYsEeyy88PURRNzzuh4Leyo=";
24 # MACOSX_DEPLOYMENT_TARGET is defined by the enviroment
25 # Remove hardcoded paths on darwin
26 substituteInPlace src/Makefile \
27 --replace "export MACOSX_DEPLOYMENT_TARGET" "#export MACOSX_DEPLOYMENT_TARGET" \
28 --replace "/usr/bin/ar" "ar" \
29 --replace "/usr/bin/sed" "sed" \
30 --replace '-i ""' '-i'
35 ] ++ lib.optionals cudaSupport [
39 buildInputs = [ opencl-headers xxHash ]
40 ++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation IOKit Metal OpenCL libiconv ];
43 "PREFIX=${placeholder "out"}"
45 "VERSION_TAG=${version}"
48 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform) [
49 "IS_APPLE_SILICON='${if stdenv.hostPlatform.isAarch64 then "1" else "0"}'"
52 enableParallelBuilding = true;
55 for f in $out/share/hashcat/OpenCL/*.cl; do
56 # Rewrite files to be included for compilation at runtime for opencl offload
57 sed "s|#include \"\(.*\)\"|#include \"$out/share/hashcat/OpenCL/\1\"|g" -i "$f"
58 sed "s|#define COMPARE_\([SM]\) \"\(.*\.cl\)\"|#define COMPARE_\1 \"$out/share/hashcat/OpenCL/\2\"|g" -i "$f"
63 LD_LIBRARY_PATH = builtins.concatStringsSep ":" ([
65 ] ++ lib.optionals cudaSupport [
66 "${cudaPackages.cudatoolkit}/lib"
69 wrapProgram $out/bin/hashcat \
70 --prefix LD_LIBRARY_PATH : ${lib.escapeShellArg LD_LIBRARY_PATH}
71 '' + lib.optionalString cudaSupport ''
72 for program in $out/bin/hashcat $out/bin/.hashcat-wrapped; do
73 isELF "$program" || continue
74 addDriverRunpath "$program"
79 description = "Fast password cracker";
80 mainProgram = "hashcat";
81 homepage = "https://hashcat.net/hashcat/";
82 license = licenses.mit;
83 platforms = platforms.unix;
84 maintainers = with maintainers; [ felixalbrigtsen zimbatm ];