From edbbc31f04c714a7e42594cd5845b30701fceb7a Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Fri, 24 May 2024 17:23:59 +0530 Subject: [PATCH] add varnam pkg --- flake.nix | 2 ++ govarnam/default.nix | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 govarnam/default.nix diff --git a/flake.nix b/flake.nix index a264084..ccd289a 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,8 @@ ]; }; packages = rec { + libgovarnam = pkgs.callPackage ./govarnam/default.nix { }; + varnam-cli = pkgs.callPackage ./govarnam/default.nix { cli = true; }; }; } ); diff --git a/govarnam/default.nix b/govarnam/default.nix new file mode 100644 index 0000000..c843d6c --- /dev/null +++ b/govarnam/default.nix @@ -0,0 +1,66 @@ +{ lib +, buildGoModule +, fetchFromGitHub +, pkg-config +, cli ? false +}: + +buildGoModule rec { + pname = "libgovarnam"; + version = "1.9.1"; + + src = fetchFromGitHub { + owner = "varnamproject"; + repo = "govarnam"; + rev = "v${version}"; + hash = "sha256-7SYdeOMgc8VBx0rsu6tWGND9mq0Td1VeGmZrpfsWsVE="; + fetchSubmodules = true; + }; + + vendorHash = "sha256-a7m2THvdi17muJI6p6OVX9cBMcmocYwju29beG2H8CY="; + + CGO_ENABLED = 1; + + nativeBuildInputs = [ pkg-config ]; + + buildPhase = + let buildcli = ''go build -o varnamcli -ldflags "-s -w -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}'" ./cli''; + in '' + runHook preInstall + + go build -tags "fts5" -buildmode=c-shared -ldflags "-s -w -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}' -extldflags "-Wl,-soname,${pname}.so.1,--version-script,${src}/govarnam.syms"" -o ${pname}.so . + ${lib.optionalString cli "${buildcli}"} + + runHook postInstall + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib + cp ${pname}.so $out/lib/${pname}.so.${version} + ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so + ln -s $out/lib/${pname}.so.${version} $out/lib/${pname}.so.1 + + mkdir -p $out/lib/pkgconfig + cp govarnam.pc.in $out/lib/pkgconfig/govarnam.pc + sed -i "s#@INSTALL_PREFIX@#$out/lib#g" $out/lib/pkgconfig/govarnam.pc + + mkdir -p $out/include/${pname} + cp *.h $out/include/${pname}/ + + ${lib.optionalString cli "install -Dt $out/bin varnamcli"} + + runHook postInstall + ''; + + + meta = { + description = "Easily type Indic languages on computer and mobile. GoVarnam is a cross-platform transliteration library. Manglish -> Malayalam, Thanglish -> Tamil, Hinglish -> Hindi plus another 10 languages. GoVarnam is a near-Go port of libvarnam"; + homepage = "https://github.com/varnamproject/govarnam"; + license = lib.licenses.agpl3Only; + maintainers = with lib.maintainers; [ adtya ]; + pkgConfigModules = [ "libgovarnam" ]; + + }; +}