nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 fetchpatch,
5 stdenv,
6}:
7let
8 # This repository has numbered versions, but not Git tags.
9 rev = "b7d180fe73636740f694ec60c1ffab52b06e7150";
10in
11stdenv.mkDerivation {
12 pname = "agrep";
13 version = "3.41.5-unstable-2022-03-23";
14
15 src = fetchFromGitHub {
16 inherit rev;
17 owner = "Wikinaut";
18 repo = "agrep";
19 hash = "sha256-2J4bw5BVZgTEcIn9IuD5Q8/L+8tldDbToDefuxDf85g=";
20 };
21
22 patches = [
23 # Implicit declaration of functions & implicit int
24 # https://github.com/Wikinaut/agrep/pull/31
25 (fetchpatch {
26 url = "https://patch-diff.githubusercontent.com/raw/Wikinaut/agrep/pull/31.patch";
27 hash = "sha256-9ik2RANq12T/1vCUYTBNomzw+aJVa/LU2RsZovu3r3E=";
28 })
29 ];
30
31 postPatch = ''
32 # agrep only doesn't includes <sys/stat.h> for Linux
33 # Starting from gcc14, this is a compiler error
34 substituteInPlace checkfil.c recursiv.c \
35 --replace-fail '#ifdef __APPLE__
36 #include <sys/stat.h>
37 #endif' '#include <sys/stat.h>'
38
39 substituteInPlace newmgrep.c \
40 --replace-fail '#if defined(_WIN32) || defined(__APPLE__)
41 #include <sys/stat.h>
42 #endif' '#include <sys/stat.h>'
43 '';
44
45 makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
46
47 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-std=c89";
48
49 installPhase = ''
50 runHook preInstall
51
52 install -Dm 555 agrep -t "$out/bin"
53 install -Dm 444 docs/* -t "$out/doc"
54
55 runHook postInstall
56 '';
57
58 meta = {
59 description = "Approximate grep for fast fuzzy string searching";
60 mainProgram = "agrep";
61 homepage = "https://www.tgries.de/agrep/";
62 maintainers = with lib.maintainers; [ momeemt ];
63 changelog = "https://github.com/Wikinaut/agrep/blob/${rev}/CHANGES";
64 license = lib.licenses.isc;
65 platforms = lib.platforms.unix;
66 };
67}