about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/sorted-grep/default.nix
blob: f0225d8a244476cc264c995d50a841118d29405b (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
52
53
54
55
56
57
{ stdenv, fetchurl, lib }:

stdenv.mkDerivation rec {
  pname = "sorted-grep";
  version = "1.0";

  src = fetchurl {
    url = "mirror://sourceforge/sgrep/sgrep-${version}.tgz";
    hash = "sha256-3F7cXrZnB38YwE1sHYm/CIGKmG+1c0QU+Pk3Y53a0T4=";
  };

  postPatch = ''
    # Its Makefile is missing compiler flags and an install step
    rm -f Makefile
  '';

  buildPhase = ''
    runHook preBuild

    ${stdenv.cc.targetPrefix}cc -Wall -O2 -o sgrep sgrep.c

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    install -D sgrep "$out/bin/sgrep"

    runHook postInstall
  '';

  installCheckPhase = ''
    runHook preInstallCheck

    set +o pipefail
    $out/bin/sgrep 2>&1 | grep ^Usage:

    runHook postInstallCheck
  '';

  doInstallCheck = true;

  meta = with lib; {
    homepage = "https://sgrep.sourceforge.net/";
    description = "Sgrep (sorted grep) searches sorted input files for lines that match a search key";
    mainProgram = "sgrep";
    longDescription = ''
      Sgrep (sorted grep) searches sorted input files for lines that match a search
      key and outputs the matching lines. When searching large files sgrep is much
      faster than traditional Unix grep, but with significant restrictions.
    '';
    platforms = platforms.unix;
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ ivan ];
  };
}