{ stdenv, fetchgit, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 }:

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "JohnTheRipper-${version}";
  version = "8a3e3c1d";
  buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];
  NIX_CFLAGS_COMPILE = "-DJOHN_SYSTEMWIDE=1";
  preConfigure = ''cd src'';
  installPhase = ''
    ensureDir $out/share/john/
    ensureDir $out/bin
    cp -R ../run/* $out/share/john
    ln -s $out/share/john/john $out/bin/john
  '';
  src = fetchgit {
    url = https://github.com/magnumripper/JohnTheRipper.git;
    rev = "93f061bc41652c94ae049b52572aac709d18aa4c";
    sha256 = "1rnfi09830n34jcqaxmsam54p4zsq9a49ic2ljh44lahcipympvy";
  };
  meta = {
    description = "John the Ripper password cracker";
    license = licenses.gpl2;
    homepage = https://github.com/magnumripper/JohnTheRipper/;
    maintainers = with maintainers; [offline];
    platforms = with platforms; unix;
  };
}

{ stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 }:

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "john-${version}";
  version = "1.8.0-jumbo-1";

  src = fetchurl {
    url = "http://www.openwall.com/john/j/${name}.tar.xz";
    sha256 = "08q92sfdvkz47rx6qjn7qv57cmlpy7i7rgddapq5384mb413vjds";
  };

  buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];

  NIX_CFLAGS_COMPILE = "-DJOHN_SYSTEMWIDE=1";

  preConfigure = "cd src";

  installPhase = ''
    mkdir -p "$out/share/john"
    mkdir -p "$out/bin"
    cp -R ../run/* "$out/share/john"
    ln -s "$out/share/john/john" "$out/bin/john"
  '';

  meta = {
    description = "John the Ripper password cracker";
    license = licenses.gpl2;
    homepage = https://github.com/magnumripper/JohnTheRipper/;
    maintainers = with maintainers; [ offline ];
    platforms = with platforms; unix;
  };
}

Clean up and Update to v1.8.0-jumbo-1.
john: Clean up and Update to v1.8.0-jumbo-1.

Cleanups are mostly stylistic, like putting src more to the top (to make
sure it won't be missed on updates of the version attribute) or using
mkdir -p instead of ensureDir.

The most significant change here is that we update the package to
1.8.0-jumbo-1, which is the latest tag available and contains community
updates which were already in magnumripper/JohnTheRipper@93f061bc41652.

We're now also using fetchurl to ensure that we don't need to clone the
whole repository and keep download times low.

And the derivation name is now "john" instead of "JohnTheRipper",
because most users would expect "nix-env -i john" to work.

Signed-off-by: aszlig <ee1aa092358634f9c53f01b5a783726c9e21b35a@redmoonstudios.org>
