aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZane van Iperen <zane@zanevaniperen.com>2021-04-20 23:08:42 +1000
committerZane van Iperen <zane@zanevaniperen.com>2021-04-20 23:08:42 +1000
commit732172e2b49a1c468d9097cf937d8da83e6f061f (patch)
treef67a1e323166b96990c950641e4dcbe6327c465e
parent60507fcfdc2c8901d413a83ea7543b1dd1e9ca37 (diff)
downloadopenrussian-cli-732172e2b49a1c468d9097cf937d8da83e6f061f.tar.gz
meta: add Nix build scripts
-rw-r--r--default.nix57
-rw-r--r--shell.nix7
2 files changed, 64 insertions, 0 deletions
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 <nixpkgs> {}) }:
+let
+ openrussian = pkgs.callPackage ./default.nix {};
+in
+pkgs.mkShell {
+ buildInputs = [ openrussian ];
+}