1{ stdenv, lib, fetchFromGitHub, gnumake, pkg-config, wget, unzip, gawk
2, sqlite, which, luaPackages, installShellFiles, makeWrapper
3}:
4stdenv.mkDerivation rec {
5 pname = "openrussian-cli";
6 version = "1.0.0";
7
8 src = fetchFromGitHub {
9 owner = "rhaberkorn";
10 repo = "openrussian-cli";
11 rev = version;
12 sha256 = "1ria7s7dpqip2wdwn35wmkry84g8ghdqnxc9cbxzzq63vl6pgvcn";
13 };
14
15 nativeBuildInputs = [
16 gnumake pkg-config wget unzip gawk sqlite which installShellFiles makeWrapper
17 ];
18
19 buildInputs = with luaPackages; [ lua luasql-sqlite3 luautf8 ];
20
21 makeFlags = [
22 "LUA=${luaPackages.lua}/bin/lua"
23 "LUAC=${luaPackages.lua}/bin/luac"
24 ];
25
26 dontConfigure = true;
27
28 # Disable check as it's too slow.
29 # doCheck = true;
30
31 #This is needed even though it's the default for some reason.
32 checkTarget = "check";
33
34 # Can't use "make install" here
35 installPhase = ''
36 runHook preInstall
37
38 mkdir -p $out/bin $out/share/openrussian
39 cp openrussian-sqlite3.db $out/share/openrussian
40 cp openrussian $out/bin
41
42 wrapProgram $out/bin/openrussian \
43 --prefix LUA_PATH ';' "$LUA_PATH" \
44 --prefix LUA_CPATH ';' "$LUA_CPATH"
45
46 runHook postInstall
47 '';
48
49 postInstall = ''
50 installShellCompletion --cmd openrussian --bash ./openrussian-completion.bash
51 installManPage ./openrussian.1
52 '';
53
54 meta = with lib; {
55 homepage = "https://github.com/rhaberkorn/openrussian-cli";
56 description = "Offline Console Russian Dictionary (based on openrussian.org)";
57 license = with licenses; [ gpl3Only mit cc-by-sa-40 ];
58 maintainers = with maintainers; [ zane ];
59 platforms = platforms.unix;
60 };
61}