include schemes with varnamcli

This commit is contained in:
Adithya 2024-05-26 15:41:55 +05:30
parent 24797f9cd1
commit 4d554a7425
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
3 changed files with 35 additions and 30 deletions

View file

@ -14,8 +14,8 @@
}; };
packages = rec { packages = rec {
libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { selected_schemes = [ "ml" ]; }; libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { };
varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; }; varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; selected_schemes = [ "ml" ]; };
fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; }; fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; };
}; };
in in
@ -24,11 +24,15 @@
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = (with pkgs; [ packages = (with pkgs; [
go_1_22 go_1_22
gopls
gnumake gnumake
meson meson
ninja ninja
cmake cmake
pkg-config pkg-config
ruby
rubyPackages.ffi
python3
]) ++ (with packages; [ libgovarnam varnam-cli ]); ]) ++ (with packages; [ libgovarnam varnam-cli ]);
}; };
packages = { packages = {

View file

@ -1,9 +1,32 @@
{ lib { lib
, buildGoModule , buildGoModule
, fetchzip
, pkg-config , pkg-config
, libgovarnam , libgovarnam
, makeWrapper
, 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 = "varnam-cli"; pname = "varnam-cli";
version = libgovarnam.version; version = libgovarnam.version;
@ -14,7 +37,7 @@ buildGoModule rec {
CGO_ENABLED = 1; CGO_ENABLED = 1;
nativeBuildInputs = [ pkg-config libgovarnam ]; nativeBuildInputs = [ pkg-config libgovarnam makeWrapper];
buildInputs = [ pkg-config libgovarnam ]; buildInputs = [ pkg-config libgovarnam ];
ldflags = [ ldflags = [
@ -29,7 +52,11 @@ buildGoModule rec {
]; ];
postInstall = '' postInstall = ''
mv $out/bin/cli $out/bin/varnamcli 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
''; '';
meta = { meta = {

View file

@ -1,30 +1,8 @@
{ 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";
@ -69,10 +47,6 @@ 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
''; '';