diff --git a/flake.nix b/flake.nix index 906d785..f119996 100644 --- a/flake.nix +++ b/flake.nix @@ -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 @@ -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 = { diff --git a/govarnam/default.nix b/govarnam/default.nix index f51231d..014efcb 100644 --- a/govarnam/default.nix +++ b/govarnam/default.nix @@ -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; @@ -14,7 +37,7 @@ buildGoModule rec { CGO_ENABLED = 1; - nativeBuildInputs = [ pkg-config libgovarnam ]; + nativeBuildInputs = [ pkg-config libgovarnam makeWrapper]; buildInputs = [ pkg-config libgovarnam ]; ldflags = [ @@ -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 = { diff --git a/govarnam/libgovarnam.nix b/govarnam/libgovarnam.nix index 60a957f..8bea219 100644 --- a/govarnam/libgovarnam.nix +++ b/govarnam/libgovarnam.nix @@ -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"; @@ -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 '';