about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/security/whatweb/default.nix
blob: fbe78834c82682a54056cce0741da38adbe7c16b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, stdenv, fetchFromGitHub, bundlerEnv, ruby }:

let
  gems = bundlerEnv {
    name = "whatweb-env";
    inherit ruby;
    gemdir = ./.;
  };

in stdenv.mkDerivation rec {
  pname = "whatweb";
  version = "0.5.5";

  src = fetchFromGitHub {
    owner = "urbanadventurer";
    repo = "whatweb";
    rev = "v${version}";
    sha256 = "sha256-HLF55x4C8n8aPO4SI0d6Z9wZe80krtUaGUFmMaYRBIE=";
  };

  prePatch = ''
    substituteInPlace Makefile \
      --replace "/usr/local" "$out" \
      --replace "/usr" "$out"
  '';

  buildInputs = [ gems ];

  installPhase = ''
    runHook preInstall

    raw=$out/share/whatweb/whatweb
    rm $out/bin/whatweb
    cat << EOF >> $out/bin/whatweb
    #!/bin/sh -e
    exec ${gems}/bin/bundle exec ${ruby}/bin/ruby "$raw" "\$@"
    EOF
    chmod +x $out/bin/whatweb

    runHook postInstall
  '';

  meta = with lib; {
    description = "Next generation web scanner";
    mainProgram = "whatweb";
    homepage = "https://github.com/urbanadventurer/whatweb";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ wolfangaukang ];
    platforms = platforms.unix;
  };
}