nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/static.nix
Aleksi Hannula 16796cae6f
gccgo: fix build from minimal-bootstrap.gnugrep-static
gccgo is built by overriding gcc from stdenv stage3. At this stage of
stdenv, when minimal-bootstrap is used as the bootstrap seed, the grep
package is actually gnugrep-static from minimal-bootstrap. This package
was accidentally missing egrep and fgrep.

Now, the gcc configure system is capable of detecting that grep -E
works as an egrep substitute. Still, a few makefiles were using egrep
directly rather than grep -E. This ultimately broke the gccgo build in
a subtle way.

(cherry picked from commit 23eb9d2243)
2026-06-15 20:21:32 +03:00

81 lines
1.4 KiB
Nix

{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "gnugrep-static";
version = "3.12";
src = fetchurl {
url = "mirror://gnu/grep/grep-${version}.tar.xz";
hash = "sha256-JkmyfA6Q5jLq3NdXvgbG6aT0jZQd5R58D4P/dkCKB7k=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/grep --version
mkdir $out
'';
meta = {
description = "GNU implementation of the Unix grep command";
homepage = "https://www.gnu.org/software/grep";
license = lib.licenses.gpl3Plus;
mainProgram = "grep";
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd grep-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-dependency-tracking \
CC=musl-gcc \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
''