about summary refs log tree commit diff
path: root/grep/default.nix
blob: 5585c10413aba8fb593a48130a3e4d6e788a18f0 (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
# Recipe for building GNU grep at specific snapshot
#
# SPDX-FileCopyrightText: 2003-2012 Eelco Dolstra
# SPDX-FileCopyrightText: 2009-2011 Ludovic Courtès
# SPDX-FileCopyrightText: 2009-2010 Rob Vermaas
# SPDX-FileCopyrightText: 2010 Lluís Batlle i Rossell
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong
# SPDX-License-Identifier: AGPL-3.0-or-later

{ lib, stdenv, version, base, snapshot
, bcExtractHook, binRenameHook, pcre, libiconv }:
stdenv.mkDerivation rec {
  pname = "grep";
  inherit version;

  nativeBuildInputs = [ bcExtractHook binRenameHook ];
  buildInputs = [ pcre libiconv ];
  hardeningDisable = [ "all" ];

  src = base;  # bootstrap files
  postPatch = ''
    tar xf ${snapshot} --strip-components=1
  '';

  preConfigure = ''
    # On macOS, force use of mkdir -p,
    # since grep's fallback (./install-sh) is broken.
    export MKDIR_P="mkdir -p"
    # Skip extra initialization and optimizations
    configureFlagsArray+=(--disable-nls)
  '';
  doCheck = false;

  meta = with lib; {
    homepage = "https://www.gnu.org/software/grep";
    description = "GNU implementation of the Unix grep command";
    longDescription = ''
      The grep command searches one or more input files for lines
      containing a match to a specified pattern.  By default, grep
      prints the matching lines.
    '';
    license = licenses.gpl3Plus;
    platforms = platforms.all;
  };
}