about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap
diff options
context:
space:
mode:
authorEmily Trau <emily@downunderctf.com>2023-05-22 09:44:19 +1000
committerEmily Trau <emily@downunderctf.com>2023-05-22 09:44:19 +1000
commit8586478e174493b4eff3ef4904e814a0480aecf4 (patch)
treebeb00903b7916a067b52b89fd096811111cefadc /pkgs/os-specific/linux/minimal-bootstrap
parentbe55e420e2365cc5e35625ce94e49df5e1dce783 (diff)
downloadnixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar.gz
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar.bz2
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar.lz
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar.xz
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.tar.zst
nixlib-8586478e174493b4eff3ef4904e814a0480aecf4.zip
minimal-bootstrap.gnugrep: init at 2.4
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap')
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/default.nix6
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix60
2 files changed, 66 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
index 423f9e3f5651..1a5f85e79a15 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
@@ -15,6 +15,11 @@ lib.makeScope
 
     coreutils = callPackage ./coreutils { tinycc = tinycc-mes; };
 
+    gnugrep = callPackage ./gnugrep {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
     gnumake = callPackage ./gnumake { tinycc = tinycc-mes; };
 
     gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; };
@@ -40,6 +45,7 @@ lib.makeScope
 
     test = kaem.runCommand "minimal-bootstrap-test" {} ''
       echo ${bash_2_05.tests.get-version}
+      echo ${gnugrep.tests.get-version}
       echo ${gnused.tests.get-version}
       echo ${mes.compiler.tests.get-version}
       echo ${tinycc-mes.compiler.tests.chain}
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix
new file mode 100644
index 000000000000..434b92fafe6f
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix
@@ -0,0 +1,60 @@
+{ lib
+, fetchurl
+, bash
+, tinycc
+, gnumake
+}:
+let
+  pname = "gnugrep";
+  version = "2.4";
+
+  src = fetchurl {
+    url = "mirror://gnu/grep/grep-${version}.tar.gz";
+    sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
+  };
+
+  # Thanks to the live-bootstrap project!
+  # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
+  makefile = fetchurl {
+    url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
+    sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
+  };
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/grep --version
+      mkdir ''${out}
+    '';
+
+  meta = with lib; {
+    description = "GNU implementation of the Unix grep command";
+    homepage = "https://www.gnu.org/software/grep";
+    license = licenses.gpl3Plus;
+    maintainers = teams.minimal-bootstrap.members;
+    mainProgram = "grep";
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  ungz --file ${src} --output grep.tar
+  untar --file grep.tar
+  rm grep.tar
+  cd grep-${version}
+
+  # Configure
+  cp ${makefile} Makefile
+
+  # Build
+  make CC="tcc -static -B ${tinycc.libs}/lib"
+
+  # Install
+  make install PREFIX=$out
+''