{ lib
, stdenv
, fetchFromGitHub
, gnumake
}:

stdenv.mkDerivation rec {
  pname = "gimgtools";
  version = "2013-0919";

  src = fetchFromGitHub {
    owner = "wuyongzheng";
    repo = pname;
    rev = "92d015749e105c5fb8eb704ae503a5c7e51af2bd";
    sha256 = "sha256-AgZqczhYr5frD9Id75if/38O057BC6YfeGquFpidKZI=";
  };

  nativeBuildInputs = [
    gnumake
  ];

  installPhase = ''
    runHook preInstallHook

    mkdir -p $out/bin
    cp cmdc gimgch gimgextract gimgfixcmd gimginfo gimgunlock gimgxor $out/bin

    runHook postInstallHook
  '';
}
