unityhub: 3.10.0 -> 3.11.0 (#376840)
[NixPkgs.git] / pkgs / by-name / op / openrussian-cli / package.nix
blob64c15b8092b78f8734a16a14f6c2023d3f0bb00b
2   stdenv,
3   lib,
4   fetchFromGitHub,
5   fetchpatch,
6   pkg-config,
7   wget,
8   unzip,
9   mawk,
10   sqlite,
11   which,
12   lua5_3,
13   installShellFiles,
14   makeWrapper,
16 let
17   luaEnv = lua5_3.withPackages (
18     p: with p; [
19       luasql-sqlite3
20       luautf8
21     ]
22   );
24 stdenv.mkDerivation rec {
25   pname = "openrussian-cli";
26   version = "1.0.0";
28   src = fetchFromGitHub {
29     owner = "rhaberkorn";
30     repo = "openrussian-cli";
31     rev = version;
32     hash = "sha256-lu13Dd3D4P/7Yol1ixt86BHk86y8DMsbFzfi244+KuY=";
33   };
35   patches = [
36     (fetchpatch {
37       url = "https://github.com/rhaberkorn/openrussian-cli/commit/984e555acbadbd1aed7df17ab53e2c586a2f8f68.patch";
38       hash = "sha256-/z4YrEeuejtCtwiFXksFREwgQoWvtI0Kl9w75KDQfF8=";
39     })
40     # Work around https://github.com/dumblob/mysql2sqlite/issues/75
41     ./use-mawk.patch
42   ];
44   nativeBuildInputs = [
45     pkg-config
46     wget
47     unzip
48     sqlite
49     which
50     installShellFiles
51     makeWrapper
52     mawk
53   ];
55   buildInputs = [ luaEnv ];
57   makeFlags = [
58     "LUA=${luaEnv}/bin/lua"
59     "LUAC=${luaEnv}/bin/luac"
60   ];
62   dontConfigure = true;
64   # Can't use "make install" here
65   installPhase = ''
66     runHook preInstall
68     mkdir -p $out/bin $out/share/openrussian
69     cp openrussian-sqlite3.db $out/share/openrussian
70     cp openrussian $out/bin
72     wrapProgram $out/bin/openrussian \
73       --prefix LUA_PATH ';' '${lua5_3.pkgs.luaLib.genLuaPathAbsStr luaEnv}' \
74       --prefix LUA_CPATH ';' '${lua5_3.pkgs.luaLib.genLuaCPathAbsStr luaEnv}'
76     runHook postInstall
77   '';
79   postInstall = ''
80     installShellCompletion --cmd openrussian --bash ./openrussian-completion.bash
81     installManPage ./openrussian.1
82   '';
84   meta = with lib; {
85     description = "Offline Console Russian Dictionary (based on openrussian.org)";
86     homepage = "https://github.com/rhaberkorn/openrussian-cli";
87     license = with licenses; [
88       gpl3Only
89       mit
90       cc-by-sa-40
91     ];
92     maintainers = with maintainers; [ zane ];
93     mainProgram = "openrussian";
94     platforms = platforms.unix;
95   };