about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/text/sgrep/default.nix
blob: f3d23d1666968ad36d51b0978a86a5ffeaa5d2c0 (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
{ stdenv, sgrep, fetchurl, runCommand, lib, m4, makeWrapper }:

stdenv.mkDerivation rec {
  pname = "sgrep";
  version = "1.94a";

  src = fetchurl {
    url = "https://www.cs.helsinki.fi/pub/Software/Local/Sgrep/sgrep-${version}.tar.gz";
    sha256 = "sha256-1bFkeOOrRHNeJCg9LYldLJyAE5yVIo3zvbKsRGOV+vk=";
  };

  nativeBuildInputs = [ makeWrapper ];

  postInstall = ''
    wrapProgram $out/bin/sgrep \
      --prefix PATH : ${lib.makeBinPath [ m4 ]}
  '';

  passthru.tests.smokeTest = runCommand "test-sgrep" { } ''
    expr='"<foo>" __ "</foo>"'
    data="<foo>1</foo><bar>2</bar>"
    ${sgrep}/bin/sgrep "$expr" <<<$data >$out
    read result <$out
    [[ $result = 1 ]]
  '';

  meta = with lib; {
    homepage = "https://www.cs.helsinki.fi/u/jjaakkol/sgrep.html";
    description = "A grep for structured text formats such as XML";
    longDescription = ''
      sgrep (structured grep) is a tool for searching and indexing text,
      SGML, XML and HTML files and filtering text streams using
      structural criteria.
    '';
    platforms = platforms.unix;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ eigengrau ];
  };
}