about summary refs log tree commit diff
path: root/grep.nix
diff options
context:
space:
mode:
Diffstat (limited to 'grep.nix')
-rw-r--r--grep.nix24
1 files changed, 15 insertions, 9 deletions
diff --git a/grep.nix b/grep.nix
index 6958739..f29b610 100644
--- a/grep.nix
+++ b/grep.nix
@@ -1,28 +1,34 @@
+# Recipe for building GNU grep at specific snapshot
+#
 # SPDX-FileCopyrightText: 2003-2012 Eelco Dolstra
 # SPDX-FileCopyrightText: 2009-2011 Ludovic Courtès
 # SPDX-FileCopyrightText: 2009-2010 Rob Vermaas
 # SPDX-FileCopyrightText: 2010 Lluís Batlle i Rossell
 # SPDX-License-Identifier: MIT
+#
 # SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong
 # SPDX-License-Identifier: AGPL-3.0-or-later
 
-{ lib, stdenv, fetchurl, pcre, libiconv }:
+{ lib, stdenv, version, base, snapshot, pcre, libiconv }:
 stdenv.mkDerivation rec {
-  pname = "gnugrep";
-  version = "2.11";
-
-  src = fetchurl {
-    url = "mirror://gnu/grep/grep-${version}.tar.xz";
-    sha256 = "sha256-AwMfin39wyimdIMebt+qoHkxKn9BhUUiksaaKj4rDuk=";
-  };
+  pname = "grep";
+  inherit version;
 
   buildInputs = [ pcre libiconv ];
 
-  # On macOS, force use of mkdir -p, since Grep's fallback
+  src = base;  # bootstrap files
+  postPatch = ''
+    tar xf ${snapshot} --strip-components=1
+  '';
+
+  # On macOS, force use of mkdir -p, since grep's fallback
   # (./install-sh) is broken.
   preConfigure = ''
     export MKDIR_P="mkdir -p"
   '';
+  postInstall = ''
+    mv $out/bin/grep{,.${version}}
+  '';
   doCheck = false;
 
   meta = with lib; {