Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 96 lines 2.0 kB view raw
1{ 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, 15}: 16let 17 luaEnv = lua5_3.withPackages ( 18 p: with p; [ 19 luasql-sqlite3 20 luautf8 21 ] 22 ); 23in 24stdenv.mkDerivation rec { 25 pname = "openrussian-cli"; 26 version = "1.0.0"; 27 28 src = fetchFromGitHub { 29 owner = "rhaberkorn"; 30 repo = "openrussian-cli"; 31 rev = version; 32 hash = "sha256-lu13Dd3D4P/7Yol1ixt86BHk86y8DMsbFzfi244+KuY="; 33 }; 34 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 ]; 43 44 nativeBuildInputs = [ 45 pkg-config 46 wget 47 unzip 48 sqlite 49 which 50 installShellFiles 51 makeWrapper 52 mawk 53 ]; 54 55 buildInputs = [ luaEnv ]; 56 57 makeFlags = [ 58 "LUA=${luaEnv}/bin/lua" 59 "LUAC=${luaEnv}/bin/luac" 60 ]; 61 62 dontConfigure = true; 63 64 # Can't use "make install" here 65 installPhase = '' 66 runHook preInstall 67 68 mkdir -p $out/bin $out/share/openrussian 69 cp openrussian-sqlite3.db $out/share/openrussian 70 cp openrussian $out/bin 71 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}' 75 76 runHook postInstall 77 ''; 78 79 postInstall = '' 80 installShellCompletion --cmd openrussian --bash ./openrussian-completion.bash 81 installManPage ./openrussian.1 82 ''; 83 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 }; 96}