Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / op / openrussian-cli / package.nix
blobe196507f67e347614f4e63c6394c027063135d08
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , fetchpatch
5 , pkg-config
6 , wget
7 , unzip
8 , mawk
9 , sqlite
10 , which
11 , lua5_3
12 , installShellFiles
13 , makeWrapper
15 let
16   luaEnv = lua5_3.withPackages (p: with p; [ luasql-sqlite3 luautf8 ]);
18 stdenv.mkDerivation rec {
19   pname = "openrussian-cli";
20   version = "1.0.0";
22   src = fetchFromGitHub {
23     owner = "rhaberkorn";
24     repo = "openrussian-cli";
25     rev = version;
26     hash = "sha256-lu13Dd3D4P/7Yol1ixt86BHk86y8DMsbFzfi244+KuY=";
27   };
29   patches = [
30     (fetchpatch {
31       url = "https://github.com/rhaberkorn/openrussian-cli/commit/984e555acbadbd1aed7df17ab53e2c586a2f8f68.patch";
32       hash = "sha256-/z4YrEeuejtCtwiFXksFREwgQoWvtI0Kl9w75KDQfF8=";
33     })
34     # Work around https://github.com/dumblob/mysql2sqlite/issues/75
35     ./use-mawk.patch
36   ];
38   nativeBuildInputs = [
39     pkg-config
40     wget
41     unzip
42     sqlite
43     which
44     installShellFiles
45     makeWrapper
46     mawk
47   ];
49   buildInputs = [ luaEnv ];
51   makeFlags = [
52     "LUA=${luaEnv}/bin/lua"
53     "LUAC=${luaEnv}/bin/luac"
54   ];
56   dontConfigure = true;
58   # Can't use "make install" here
59   installPhase = ''
60     runHook preInstall
62     mkdir -p $out/bin $out/share/openrussian
63     cp openrussian-sqlite3.db $out/share/openrussian
64     cp openrussian $out/bin
66     wrapProgram $out/bin/openrussian \
67       --prefix LUA_PATH ';' '${lua5_3.pkgs.luaLib.genLuaPathAbsStr luaEnv}' \
68       --prefix LUA_CPATH ';' '${lua5_3.pkgs.luaLib.genLuaCPathAbsStr luaEnv}'
70     runHook postInstall
71   '';
73   postInstall = ''
74     installShellCompletion --cmd openrussian --bash ./openrussian-completion.bash
75     installManPage ./openrussian.1
76   '';
78   meta = with lib; {
79     description = "Offline Console Russian Dictionary (based on openrussian.org)";
80     homepage = "https://github.com/rhaberkorn/openrussian-cli";
81     license = with licenses; [ gpl3Only mit cc-by-sa-40 ];
82     maintainers = with maintainers; [ zane ];
83     mainProgram = "openrussian";
84     platforms = platforms.unix;
85   };