1{
2 lib,
3 fetchurl,
4 bash,
5 tinycc,
6 gnumake,
7}:
8let
9 pname = "gnugrep";
10 version = "2.4";
11
12 src = fetchurl {
13 url = "mirror://gnu/grep/grep-${version}.tar.gz";
14 sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
15 };
16
17 # Thanks to the live-bootstrap project!
18 # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
19 makefile = fetchurl {
20 url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
21 sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
22 };
23in
24bash.runCommand "${pname}-${version}"
25 {
26 inherit pname version;
27
28 nativeBuildInputs = [
29 tinycc.compiler
30 gnumake
31 ];
32
33 passthru.tests.get-version =
34 result:
35 bash.runCommand "${pname}-get-version-${version}" { } ''
36 ${result}/bin/grep --version
37 mkdir ''${out}
38 '';
39
40 meta = with lib; {
41 description = "GNU implementation of the Unix grep command";
42 homepage = "https://www.gnu.org/software/grep";
43 license = licenses.gpl3Plus;
44 teams = [ teams.minimal-bootstrap ];
45 mainProgram = "grep";
46 platforms = platforms.unix;
47 };
48 }
49 ''
50 # Unpack
51 ungz --file ${src} --output grep.tar
52 untar --file grep.tar
53 rm grep.tar
54 cd grep-${version}
55
56 # Configure
57 cp ${makefile} Makefile
58
59 # Build
60 make CC="tcc -B ${tinycc.libs}/lib"
61
62 # Install
63 make install PREFIX=$out
64 ''