@@ -1,4 +1,6 @@
1−{ stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 }:
1+{ stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2
2+, writeText
3+}:
24
35with stdenv.lib;
46
@@ -11,18 +13,34 @@ stdenv.mkDerivation rec {
1113 sha256 = "08q92sfdvkz47rx6qjn7qv57cmlpy7i7rgddapq5384mb413vjds";
1214 };
1315
14− buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];
15−
16− NIX_CFLAGS_COMPILE = "-DJOHN_SYSTEMWIDE=1";
16+ postPatch = ''
17+ sed -ri -e '
18+ s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/!
19+ /^#define\s+JOHN_SYSTEMWIDE/s!/usr!'"$out"'!
20+ ' src/params.h
21+ sed -ri -e '/^\.include/ {
22+ s!\$JOHN!'"$out"'/etc/john!
23+ s!^(\.include\s*)<([^./]+\.conf)>!\1"'"$out"'/etc/john/\2"!
24+ }' run/*.conf
25+ '';
1726
1827 preConfigure = "cd src";
1928 configureFlags = [ "--disable-native-macro" ];
2029
30+ buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];
31+
32+ NIX_CFLAGS_COMPILE = [ "-DJOHN_SYSTEMWIDE=1" ];
33+
2134 installPhase = ''
22− mkdir -p "$out/share/john"
23− mkdir -p "$out/bin"
24− cp -R ../run/* "$out/share/john"
25− ln -s "$out/share/john/john" "$out/bin/john"
35+ mkdir -p "$out/etc/john" "$out/share/john" "$out/share/doc/john"
36+ find ../run -mindepth 1 -maxdepth 1 -type f -executable \
37+ -exec "${stdenv.shell}" "${writeText "john-binary-install.sh" ''
38+ filename="$(basename "$1")"
39+ install -vD "$1" "$out/bin/''${filename%.*}"
40+ ''}" {} \;
41+ cp -vt "$out/etc/john" ../run/*.conf
42+ cp -vt "$out/share/john" ../run/*.chr ../run/password.lst
43+ cp -vrt "$out/share/doc/john" ../doc/*
2644 '';
2745
2846 meta = {