diff options
author | Peder Bergebakken Sundt <pbsds@hotmail.com> | 2023-11-16 21:31:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 21:31:44 +0100 |
commit | b74d956ece9628dad174f101f5d2f6b0b4c279e1 (patch) | |
tree | 7a99574b24b02e68ffe7be473587f94431b53bbd /pkgs/by-name | |
parent | da1923d134244ccf6d6fabe7e7df0ad4a8b4b8b1 (diff) | |
parent | d989747e0c73002228a9d89a35964732149d6166 (diff) |
Merge pull request #263916 from vs49688/openrussian
openrussian-cli: fix build & misc cleanups
Diffstat (limited to 'pkgs/by-name')
-rw-r--r-- | pkgs/by-name/op/openrussian-cli/package.nix | 86 | ||||
-rw-r--r-- | pkgs/by-name/op/openrussian-cli/use-mawk.patch | 13 |
2 files changed, 99 insertions, 0 deletions
diff --git a/pkgs/by-name/op/openrussian-cli/package.nix b/pkgs/by-name/op/openrussian-cli/package.nix new file mode 100644 index 0000000000000..e196507f67e34 --- /dev/null +++ b/pkgs/by-name/op/openrussian-cli/package.nix @@ -0,0 +1,86 @@ +{ stdenv +, lib +, fetchFromGitHub +, fetchpatch +, pkg-config +, wget +, unzip +, mawk +, sqlite +, which +, lua5_3 +, installShellFiles +, makeWrapper +}: +let + luaEnv = lua5_3.withPackages (p: with p; [ luasql-sqlite3 luautf8 ]); +in +stdenv.mkDerivation rec { + pname = "openrussian-cli"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "rhaberkorn"; + repo = "openrussian-cli"; + rev = version; + hash = "sha256-lu13Dd3D4P/7Yol1ixt86BHk86y8DMsbFzfi244+KuY="; + }; + + patches = [ + (fetchpatch { + url = "https://github.com/rhaberkorn/openrussian-cli/commit/984e555acbadbd1aed7df17ab53e2c586a2f8f68.patch"; + hash = "sha256-/z4YrEeuejtCtwiFXksFREwgQoWvtI0Kl9w75KDQfF8="; + }) + # Work around https://github.com/dumblob/mysql2sqlite/issues/75 + ./use-mawk.patch + ]; + + nativeBuildInputs = [ + pkg-config + wget + unzip + sqlite + which + installShellFiles + makeWrapper + mawk + ]; + + buildInputs = [ luaEnv ]; + + makeFlags = [ + "LUA=${luaEnv}/bin/lua" + "LUAC=${luaEnv}/bin/luac" + ]; + + dontConfigure = true; + + # Can't use "make install" here + installPhase = '' + runHook preInstall + + mkdir -p $out/bin $out/share/openrussian + cp openrussian-sqlite3.db $out/share/openrussian + cp openrussian $out/bin + + wrapProgram $out/bin/openrussian \ + --prefix LUA_PATH ';' '${lua5_3.pkgs.luaLib.genLuaPathAbsStr luaEnv}' \ + --prefix LUA_CPATH ';' '${lua5_3.pkgs.luaLib.genLuaCPathAbsStr luaEnv}' + + runHook postInstall + ''; + + postInstall = '' + installShellCompletion --cmd openrussian --bash ./openrussian-completion.bash + installManPage ./openrussian.1 + ''; + + meta = with lib; { + description = "Offline Console Russian Dictionary (based on openrussian.org)"; + homepage = "https://github.com/rhaberkorn/openrussian-cli"; + license = with licenses; [ gpl3Only mit cc-by-sa-40 ]; + maintainers = with maintainers; [ zane ]; + mainProgram = "openrussian"; + platforms = platforms.unix; + }; +} diff --git a/pkgs/by-name/op/openrussian-cli/use-mawk.patch b/pkgs/by-name/op/openrussian-cli/use-mawk.patch new file mode 100644 index 0000000000000..d0cfa814bae3c --- /dev/null +++ b/pkgs/by-name/op/openrussian-cli/use-mawk.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile b/Makefile +index 8fe3880..281ce2d 100644 +--- a/Makefile ++++ b/Makefile +@@ -25,7 +25,7 @@ openrussian-sql.zip: + + openrussian-sqlite3.db : openrussian-sql.zip mysql2sqlite postprocess.sql + $(RM) $@ +- unzip -p $< openrussian.sql | awk -f ./mysql2sqlite - | sqlite3 $@ ++ unzip -p $< openrussian.sql | mawk -f ./mysql2sqlite - | sqlite3 $@ + sqlite3 $@ -batch <postprocess.sql + + # Try to generate all possible pages |