Skip to content

Commit

Permalink
include schemes with varnamcli
Browse files Browse the repository at this point in the history
  • Loading branch information
adtya committed May 26, 2024
1 parent 24797f9 commit 4d554a7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
8 changes: 6 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
};

packages = rec {
libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { selected_schemes = [ "ml" ]; };
varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; };
libgovarnam = pkgs.callPackage ./govarnam/libgovarnam.nix { };
varnam-cli = pkgs.callPackage ./govarnam { inherit libgovarnam; selected_schemes = [ "ml" ]; };
fcitx5-varnam = pkgs.callPackage ./varnam-fcitx5 { inherit libgovarnam; };
};
in
Expand All @@ -24,11 +24,15 @@
devShells.default = pkgs.mkShell {
packages = (with pkgs; [
go_1_22
gopls
gnumake
meson
ninja
cmake
pkg-config
ruby
rubyPackages.ffi
python3
]) ++ (with packages; [ libgovarnam varnam-cli ]);
};
packages = {
Expand Down
31 changes: 29 additions & 2 deletions govarnam/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
{ lib
, buildGoModule
, fetchzip
, pkg-config
, 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 {
pname = "varnam-cli";
version = libgovarnam.version;
Expand All @@ -14,7 +37,7 @@ buildGoModule rec {

CGO_ENABLED = 1;

nativeBuildInputs = [ pkg-config libgovarnam ];
nativeBuildInputs = [ pkg-config libgovarnam makeWrapper];
buildInputs = [ pkg-config libgovarnam ];

ldflags = [
Expand All @@ -29,7 +52,11 @@ buildGoModule rec {
];

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 = {
Expand Down
26 changes: 0 additions & 26 deletions govarnam/libgovarnam.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
{ lib
, fetchzip
, buildGoModule
, 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 {
pname = "libgovarnam";
version = "1.9.1";
Expand Down Expand Up @@ -69,10 +47,6 @@ buildGoModule rec {
mkdir -p $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
'';

Expand Down

0 comments on commit 4d554a7

Please sign in to comment.