Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 122 lines 3.3 kB view raw
1{ 2 lib, 3 stdenv, 4 updateAutotoolsGnuConfigScriptsHook, 5 glibcLocales, 6 fetchurl, 7 pcre2, 8 libiconv, 9 perl, 10 runtimeShellPackage, 11}: 12 13# Note: this package is used for bootstrapping fetchurl, and thus 14# cannot use fetchpatch! All mutable patches (generated by GitHub or 15# cgit) that are needed here should be included directly in Nixpkgs as 16# files. 17 18let 19 version = "3.12"; 20in 21 22stdenv.mkDerivation { 23 pname = "gnugrep"; 24 inherit version; 25 26 src = fetchurl { 27 url = "mirror://gnu/grep/grep-${version}.tar.xz"; 28 hash = "sha256-JkmyfA6Q5jLq3NdXvgbG6aT0jZQd5R58D4P/dkCKB7k="; 29 }; 30 31 patches = [ 32 # Fixes test-float-h failure on ppc64 with C23 33 # https://lists.gnu.org/archive/html/bug-gnulib/2025-07/msg00021.html 34 # Multiple upstream commits squashed with adjustments, see header 35 ./gnulib-float-h-tests-port-to-C23-PowerPC-GCC.patch 36 ]; 37 38 # Some gnulib tests fail 39 # - on Musl: https://github.com/NixOS/nixpkgs/pull/228714 40 # - on x86_64-darwin: https://github.com/NixOS/nixpkgs/pull/228714#issuecomment-1576826330 41 postPatch = 42 if stdenv.hostPlatform.isMusl || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) then 43 '' 44 sed -i 's:gnulib-tests::g' Makefile.in 45 '' 46 else 47 null; 48 49 nativeCheckInputs = [ 50 perl 51 glibcLocales 52 ]; 53 outputs = [ 54 "out" 55 "info" 56 ]; # the man pages are rather small 57 58 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ]; 59 buildInputs = [ 60 pcre2 61 libiconv 62 ] 63 ++ lib.optional (!stdenv.hostPlatform.isWindows) runtimeShellPackage; 64 65 # cygwin: FAIL: multibyte-white-space 66 # freebsd: FAIL mb-non-UTF8-performance 67 # x86_64-darwin: fails 'stack-overflow' tests on Rosetta 2 emulator 68 # aarch32: fails 'stack-overflow' when run on qemu under x86_64 69 doCheck = 70 !stdenv.hostPlatform.isCygwin 71 && !stdenv.hostPlatform.isFreeBSD 72 && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) 73 && !stdenv.buildPlatform.isRiscV64 74 && !stdenv.hostPlatform.isAarch32; 75 76 # On macOS, force use of mkdir -p, since Grep's fallback 77 # (./install-sh) is broken. 78 preConfigure = '' 79 export MKDIR_P="mkdir -p" 80 ''; 81 82 enableParallelBuilding = true; 83 84 # Fix reference to sh in bootstrap-tools, and invoke grep via 85 # absolute path rather than looking at argv[0]. 86 postInstall = '' 87 rm $out/bin/egrep $out/bin/fgrep 88 echo "#! /bin/sh" > $out/bin/egrep 89 echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep 90 echo "#! /bin/sh" > $out/bin/fgrep 91 echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep 92 chmod +x $out/bin/egrep $out/bin/fgrep 93 ''; 94 95 env = lib.optionalAttrs stdenv.hostPlatform.isMinGW { 96 NIX_CFLAGS_COMPILE = "-Wno-error=format-security"; 97 }; 98 99 meta = with lib; { 100 homepage = "https://www.gnu.org/software/grep/"; 101 description = "GNU implementation of the Unix grep command"; 102 103 longDescription = '' 104 The grep command searches one or more input files for lines 105 containing a match to a specified pattern. By default, grep 106 prints the matching lines. 107 ''; 108 109 license = licenses.gpl3Plus; 110 111 maintainers = [ 112 maintainers.das_j 113 maintainers.m00wl 114 ]; 115 platforms = platforms.all; 116 mainProgram = "grep"; 117 }; 118 119 passthru = { 120 inherit pcre2; 121 }; 122}