install schemes along with libgovarnam

This commit is contained in:
Adithya 2024-05-25 00:16:21 +05:30
parent 5ea9c63f9d
commit 24797f9cd1
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
5 changed files with 117 additions and 10 deletions

View file

@ -14,7 +14,7 @@
}; };
packages = rec { packages = rec {
libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { }; libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { selected_schemes = [ "ml" ]; };
varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; }; varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; };
fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; }; fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; };
}; };

View file

@ -1,21 +1,14 @@
{ lib { lib
, buildGoModule , buildGoModule
, fetchFromGitHub
, pkg-config , pkg-config
, libgovarnam , libgovarnam
}: }:
buildGoModule rec { buildGoModule rec {
pname = "varnam-cli"; pname = "varnam-cli";
version = "1.9.1"; version = libgovarnam.version;
src = fetchFromGitHub { src = libgovarnam.src;
owner = "varnamproject";
repo = "govarnam";
rev = "v${version}";
hash = "sha256-7SYdeOMgc8VBx0rsu6tWGND9mq0Td1VeGmZrpfsWsVE=";
fetchSubmodules = true;
};
vendorHash = "sha256-a7m2THvdi17muJI6p6OVX9cBMcmocYwju29beG2H8CY="; vendorHash = "sha256-a7m2THvdi17muJI6p6OVX9cBMcmocYwju29beG2H8CY=";

View file

@ -1,8 +1,30 @@
{ lib { lib
, fetchzip
, buildGoModule , buildGoModule
, fetchFromGitHub , fetchFromGitHub
, selected_schemes ? [ ]
}: }:
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
buildGoModule rec { buildGoModule rec {
pname = "libgovarnam"; pname = "libgovarnam";
version = "1.9.1"; version = "1.9.1";
@ -47,6 +69,10 @@ buildGoModule rec {
mkdir -p $out/include/${pname} mkdir -p $out/include/${pname}
cp *.h $out/include/${pname}/ cp *.h $out/include/${pname}/
mkdir -p $out/share/varnam/schemes
echo ${toString (lib.lists.forEach schemeSrcs (scheme: "${scheme}/*.vst"))}
cp ${toString (lib.lists.forEach schemeSrcs (scheme: "${scheme}/*.vst"))} $out/share/varnam/schemes/
runHook postInstall runHook postInstall
''; '';

58
govarnam/schemes.nix Normal file
View file

@ -0,0 +1,58 @@
{
"as" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/as.zip";
sha = "1skc85kwc4zvrzj7j4jbwnj1kc6662r3cypi1rgp40srmga0wvs5";
};
"bn" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/bn.zip";
sha = "0ywmlhwwmm183g7rm62lfp58qrgk2wiwgxlzzpkp0g5w5n01g86i";
};
"gu" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/gu.zip";
sha = "0wvjgfmyp1pqkvknc0p3x69rb5czry11gddr0spzbq68z9yqalq7";
};
"hi" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/hi.zip";
sha = "09v4ld7xy1xm8qf4hr8m9fmnmzm89rqyjpn7aifp008vaws0pd7y";
};
"kn" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/kn.zip";
sha = "19l9b3hy32sli3c2mll5x9akiy1nczj9m8knf221f2m1wp92i4cx";
};
"ml-inscript" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/ml-inscript.zip";
sha = "0hbr4pyaa6jwxjxxrwih99510q1mb91vph75njmnrcrifs74k186";
};
"ml" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/ml.zip";
sha = "0cj1ca1ynbga3cry9sgwvs0bra3i0bvjp9prg28s4nvj3jk0zdry";
};
"mr" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/mr.zip";
sha = "061hc81n12zbzlp5qcfl4bf4ixv70f80x75igymlps9s8nvjm853";
};
"ne" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/ne.zip";
sha = "0lcdc600cmpkdpb4k1k68wvczz4vidcj25ikzr21ml8jy861pz2m";
};
"or" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/or.zip";
sha = "0ibvm3wsy0z179b3fhdba78riv8h5c47sm8xma0phhr151nmaplz";
};
"pa" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/pa.zip";
sha = "06nxkz2jxd845kya8231qd2m7g9xg9q6bllb78achx09wrigv5wj";
};
"sa" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/sa.zip";
sha = "1lrl23d5rgkb5lnsbdz2cqq14zvi7hi0mkvpsay03fbg97mzghx7";
};
"ta" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/ta.zip";
sha = "0w14qp19b9r36aaq0wl7awdc7w5633j8x3mpx013cr0xqraqwjm1";
};
"te" = {
url = "https://github.com/varnamproject/schemes/releases/download/v1.8.0/te.zip";
sha = "0mqllwi0337iwn9jy2s8piqlc9bj7a8rg1ykxfnxmyhh77vs6dax";
};
}

30
govarnam/update.sh Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash --keep GITHUB_TOKEN -p nix-prefetch jq
set -eo pipefail
curl_args=( '--silent' )
# optionally takes a GITHUB_TOKEN to overcome api rate limiting.
if [ -n "$GITHUB_TOKEN" ]; then curl_args+=( --header "authorization: Bearer ${GITHUB_TOKEN}" ); fi
# get latest release assets
curl_args+=( --url https://api.github.com/repos/varnamproject/schemes/releases/latest )
scheme_archives=$(curl "${curl_args[@]}" | jq -r '.assets' )
dirname="$(dirname "$0")"
printf '{\n' > "$dirname/schemes.nix"
while
read -r file_path
do
name="$(basename $file_path)"
name="${name/.zip/}"
if [ $name != "source-with-lfs" ]; then
printf ' "%s" = {\n url = "%s";\n sha = "%s";\n };\n' "${name}" "$file_path" "$(nix-prefetch-url --unpack "$file_path")" >>"$dirname/schemes.nix"
fi
done < <(jq -r '.[].browser_download_url' <<<"$scheme_archives")
printf '}\n' >> "$dirname/schemes.nix"