1{ lib, stdenv, fetchFromGitHub, bundlerEnv, ruby }:
2
3let
4 gems = bundlerEnv {
5 name = "whatweb-env";
6 inherit ruby;
7 gemdir = ./.;
8 };
9
10in stdenv.mkDerivation rec {
11 pname = "whatweb";
12 version = "0.5.5";
13
14 src = fetchFromGitHub {
15 owner = "urbanadventurer";
16 repo = "whatweb";
17 rev = "v${version}";
18 sha256 = "sha256-HLF55x4C8n8aPO4SI0d6Z9wZe80krtUaGUFmMaYRBIE=";
19 };
20
21 prePatch = ''
22 substituteInPlace Makefile \
23 --replace "/usr/local" "$out" \
24 --replace "/usr" "$out"
25 '';
26
27 buildInputs = [ gems ];
28
29 installPhase = ''
30 runHook preInstall
31
32 raw=$out/share/whatweb/whatweb
33 rm $out/bin/whatweb
34 cat << EOF >> $out/bin/whatweb
35 #!/bin/sh -e
36 exec ${gems}/bin/bundle exec ${ruby}/bin/ruby "$raw" "\$@"
37 EOF
38 chmod +x $out/bin/whatweb
39
40 runHook postInstall
41 '';
42
43 meta = with lib; {
44 description = "Next generation web scanner";
45 homepage = "https://github.com/urbanadventurer/whatweb";
46 license = licenses.gpl2Only;
47 maintainers = with maintainers; [ wolfangaukang ];
48 platforms = platforms.unix;
49 };
50}