varnam-nix/govarnam/default.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2024-05-24 17:23:59 +05:30
{ lib
, buildGoModule
2024-05-26 15:41:55 +05:30
, fetchzip
2024-05-24 17:23:59 +05:30
, pkg-config
2024-05-24 20:28:07 +05:30
, libgovarnam
2024-05-26 15:41:55 +05:30
, makeWrapper
, selected_schemes ? [ ]
2024-05-24 17:23:59 +05:30
}:
2024-05-26 15:41:55 +05:30
let
schemeShas = import ./schemes.nix;
knownSchemes = builtins.attrNames schemeShas;
selectedSchemes =
if (selected_schemes == [ ])
then knownSchemes
else
let
unknown = lib.subtractLists knownSchemes selected_schemes;
in
if (unknown != [ ])
then throw "Unknown scheme(s): ${lib.concatStringsSep " " unknown}"
else selected_schemes;
schemeSrcs = lib.lists.forEach selectedSchemes (
name: (fetchzip {
url = schemeShas.${name}.url;
sha256 = schemeShas.${name}.sha;
})
);
in
2024-05-24 17:23:59 +05:30
buildGoModule rec {
2024-05-24 20:28:07 +05:30
pname = "varnam-cli";
2024-05-25 00:16:21 +05:30
version = libgovarnam.version;
src = libgovarnam.src;
2024-05-24 17:23:59 +05:30
vendorHash = "sha256-a7m2THvdi17muJI6p6OVX9cBMcmocYwju29beG2H8CY=";
CGO_ENABLED = 1;
2024-05-26 16:02:53 +05:30
nativeBuildInputs = [ pkg-config libgovarnam makeWrapper ];
2024-05-24 22:53:29 +05:30
buildInputs = [ pkg-config libgovarnam ];
2024-05-24 17:23:59 +05:30
2024-05-24 20:28:07 +05:30
ldflags = [
"-w"
"-s"
"-X 'github.com/varnamproject/govarnam/govarnam.BuildString=${version} (\#0000000 1970-01-01T00:00:00+0000)'"
"-X 'github.com/varnamproject/govarnam/govarnam.VersionString=${version}'"
];
2024-05-24 17:23:59 +05:30
2024-05-24 20:28:07 +05:30
subPackages = [
"cli"
];
2024-05-24 17:23:59 +05:30
2024-05-24 22:53:29 +05:30
postInstall = ''
2024-05-26 15:41:55 +05:30
mkdir -p $out/share/varnam/schemes
cp ${toString (lib.lists.forEach schemeSrcs (scheme: "${scheme}/*.vst"))} $out/share/varnam/schemes/
mv $out/bin/cli $out/bin/.varnamcli
makeWrapper $out/bin/.varnamcli $out/bin/varnamcli --set VARNAM_VST_DIR $out/share/varnam/schemes
2024-05-24 22:53:29 +05:30
'';
2024-05-24 17:23:59 +05:30
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 ];
2024-05-24 22:53:29 +05:30
mainProgram = "varnamcli";
2024-05-24 17:23:59 +05:30
};
}