From 2526fd573ace94a85cb67f810dd27f34049c9424 Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Mon, 19 Apr 2021 00:11:48 +1000 Subject: Makefile: don't rely on the shebang of mysql2sqlite On NixOS, /usr/bin/awk doesn't exist. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 36c75d7..0d67b39 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 | ./mysql2sqlite - | sqlite3 $@ + unzip -p $< openrussian.sql | awk -f ./mysql2sqlite - | sqlite3 $@ sqlite3 $@ -batch Date: Mon, 19 Apr 2021 00:16:10 +1000 Subject: Makefile: update database url --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0d67b39..8cc99a3 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ openrussian : openrussian.lua # a database matching the openrussian.lua script. #.INTERMEDIATE: openrussian-sql.zip openrussian-sql.zip: - wget -O $@ 'https://en.openrussian.org/downloads/openrussian-sql.zip' + wget -O $@ 'https://api.openrussian.org/downloads/openrussian-sql.zip' openrussian-sqlite3.db : openrussian-sql.zip mysql2sqlite postprocess.sql $(RM) $@ -- cgit v1.2.3 From ffce89ff5ce84ef2baa28c468db2c06a2d3a2df9 Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Tue, 20 Apr 2021 23:04:42 +1000 Subject: openrussian-sql.zip: update as of 2021-04-20 --- openrussian-sql.zip | Bin 36496959 -> 36601305 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/openrussian-sql.zip b/openrussian-sql.zip index a1d9e4f..8c4eaa0 100644 Binary files a/openrussian-sql.zip and b/openrussian-sql.zip differ -- cgit v1.2.3 From 35a03cd7d6bc25d9eeba555900d8e5d462d943e2 Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Mon, 19 Apr 2021 00:43:30 +1000 Subject: Makefile: don't rm the downloaded zip on clean As it's in git. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8cc99a3..7a6082a 100644 --- a/Makefile +++ b/Makefile @@ -50,4 +50,4 @@ install : openrussian openrussian-sqlite3.db \ mandb clean: - $(RM) openrussian openrussian-sql.zip openrussian-sqlite3.db + $(RM) openrussian openrussian-sqlite3.db -- cgit v1.2.3 From 60507fcfdc2c8901d413a83ea7543b1dd1e9ca37 Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Tue, 20 Apr 2021 20:34:13 +1000 Subject: Makefile: add phony targets --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7a6082a..8fe3880 100644 --- a/Makefile +++ b/Makefile @@ -51,3 +51,5 @@ install : openrussian openrussian-sqlite3.db \ clean: $(RM) openrussian openrussian-sqlite3.db + +.PHONY: all check install clean -- cgit v1.2.3 From 732172e2b49a1c468d9097cf937d8da83e6f061f Mon Sep 17 00:00:00 2001 From: Zane van Iperen Date: Tue, 20 Apr 2021 23:08:42 +1000 Subject: meta: add Nix build scripts --- default.nix | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 7 +++++++ 2 files changed, 64 insertions(+) create mode 100644 default.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0a784a2 --- /dev/null +++ b/default.nix @@ -0,0 +1,57 @@ +{ stdenv, lib, nix-gitignore, gnumake, pkgconfig, wget, unzip, gawk +, sqlite, which, luaPackages, installShellFiles, makeWrapper +}: +let + luaLibs = with luaPackages; [ lua luasql-sqlite3 luautf8 ]; +in +stdenv.mkDerivation rec { + pname = "openrussian-cli"; + version = "1.0.0"; + + src = nix-gitignore.gitignoreSource [] ./.; + + nativeBuildInputs = [ + gnumake pkgconfig wget unzip gawk sqlite which installShellFiles + ]; + + buildInputs = [ makeWrapper ] ++ luaLibs; + + makeFlags = [ + "LUA=${luaPackages.lua}/bin/lua" + "LUAC=${luaPackages.lua}/bin/luac" + ]; + + dontConfigure = true; + + # Disable check as it's too slow. + # doCheck = true; + + #This is needed even though it's the default for some reason. + checkTarget = "check"; + + # Can't use "make install" here + installPhase = '' + 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 ';' "$LUA_PATH" \ + --prefix LUA_CPATH ';' "$LUA_CPATH" + + runHook postInstall + ''; + + postInstall = '' + installShellCompletion --bash --name openrussian ./openrussian-completion.bash + installManPage ./openrussian.1 + ''; + + meta = with lib; { + homepage = "https://github.com/rhaberkorn/openrussian-cli"; + description = "Offline Console Russian Dictionary (based on openrussian.org)"; + license = with licenses; [ gpl3 mit cc-by-sa-40 ]; + platforms = platforms.unix; + }; +} + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..93c27dc --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +{ pkgs ? (import {}) }: +let + openrussian = pkgs.callPackage ./default.nix {}; +in +pkgs.mkShell { + buildInputs = [ openrussian ]; +} -- cgit v1.2.3