about summary refs log tree commit diff
path: root/pkgs/development/libraries/linenoise/default.nix
blob: a525a3da9a411171171438ff87873f6f6492863e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib
, stdenv
, fetchFromGitHub
, validatePkgConfig
, fixDarwinDylibNames
}:

stdenv.mkDerivation {
  pname = "linenoise";
  version = "1.0-34-g93b2db9";

  src = fetchFromGitHub {
    owner = "antirez";
    repo = "linenoise";
    rev = "1.0-34-g93b2db9";
    hash = "sha256-GsrYg16gpjHkkmpCU3yGzqNS/buZl+JoWALLvwzmT4A=";
  };

  nativeBuildInputs = [ validatePkgConfig ]
    ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];

  buildPhase = ''
    runHook preBuild

    $CC -c -o linenoise.o linenoise.c
    $CC -shared -o liblinenoise.so linenoise.o
    $AR rcs liblinenoise.a linenoise.o

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    install -d $out/lib/pkgconfig $out/include
    install -m644 linenoise.h     $out/include/
    install -m644 liblinenoise.a  $out/lib/
    install -m644 liblinenoise.so $out/lib/
    substituteAll ${./linenoise.pc.in} $out/lib/pkgconfig/linenoise.pc

    runHook postInstall
  '';

  meta = {
    homepage = "https://github.com/antirez/linenoise";
    description = "Minimal, zero-config, BSD licensed, readline replacement";
    maintainers = with lib.maintainers; [ fstamour remexre ];
    platforms = lib.platforms.unix;
    license = lib.licenses.bsd2;
  };
}