2024-06-20 14:57:18 +00:00
|
|
|
{ lib, stdenv, updateAutotoolsGnuConfigScriptsHook, glibcLocales, fetchurl, pcre2, libiconv, perl, runtimeShellPackage }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# Note: this package is used for bootstrapping fetchurl, and thus
|
|
|
|
# cannot use fetchpatch! All mutable patches (generated by GitHub or
|
|
|
|
# cgit) that are needed here should be included directly in Nixpkgs as
|
|
|
|
# files.
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
let version = "3.11"; in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "gnugrep";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://gnu/grep/grep-${version}.tar.xz";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# Some gnulib tests fail
|
|
|
|
# - on Musl: https://github.com/NixOS/nixpkgs/pull/228714
|
|
|
|
# - on x86_64-darwin: https://github.com/NixOS/nixpkgs/pull/228714#issuecomment-1576826330
|
|
|
|
postPatch = if stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) then ''
|
|
|
|
sed -i 's:gnulib-tests::g' Makefile.in
|
|
|
|
'' else null;
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeCheckInputs = [ perl glibcLocales ];
|
2020-04-24 23:36:52 +00:00
|
|
|
outputs = [ "out" "info" ]; # the man pages are rather small
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
|
|
|
|
buildInputs = [ pcre2 libiconv runtimeShellPackage ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# cygwin: FAIL: multibyte-white-space
|
|
|
|
# freebsd: FAIL mb-non-UTF8-performance
|
2023-07-15 17:15:38 +00:00
|
|
|
# x86_64-darwin: fails 'stack-overflow' tests on Rosetta 2 emulator
|
2024-04-21 15:54:59 +00:00
|
|
|
doCheck = !stdenv.isCygwin && !stdenv.isFreeBSD && !(stdenv.isDarwin && stdenv.hostPlatform.isx86_64) && !stdenv.buildPlatform.isRiscV64;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# On macOS, force use of mkdir -p, since Grep's fallback
|
|
|
|
# (./install-sh) is broken.
|
|
|
|
preConfigure = ''
|
|
|
|
export MKDIR_P="mkdir -p"
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Fix reference to sh in bootstrap-tools, and invoke grep via
|
|
|
|
# absolute path rather than looking at argv[0].
|
|
|
|
postInstall =
|
|
|
|
''
|
|
|
|
rm $out/bin/egrep $out/bin/fgrep
|
|
|
|
echo "#! /bin/sh" > $out/bin/egrep
|
|
|
|
echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
|
|
|
|
echo "#! /bin/sh" > $out/bin/fgrep
|
|
|
|
echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
|
|
|
|
chmod +x $out/bin/egrep $out/bin/fgrep
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
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;
|
|
|
|
|
2022-01-22 01:22:15 +00:00
|
|
|
maintainers = [
|
2023-07-15 17:15:38 +00:00
|
|
|
maintainers.das_j
|
2022-01-22 01:22:15 +00:00
|
|
|
maintainers.m00wl
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
2021-09-22 15:38:15 +00:00
|
|
|
mainProgram = "grep";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru = {
|
|
|
|
inherit pcre2;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|