mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
3f9ea32279
This adds `pkgs.translatelocally-models.*` providing machine translation models which can be used with `pkgs.translatelocally`. `translatelocally-models.is-en-tiny` is marked as broken because its archive is missing.
44 lines
1.3 KiB
Nix
44 lines
1.3 KiB
Nix
{ lib, stdenvNoCC, fetchurl }:
|
|
|
|
let
|
|
modelSpecs = (builtins.fromJSON (builtins.readFile ./models.json));
|
|
withCodeAsKey = f: { code, ... }@attrs: lib.nameValuePair code (f attrs);
|
|
mkModelPackage = { name, code, version, url, checksum }:
|
|
stdenvNoCC.mkDerivation {
|
|
pname = "translatelocally-model-${code}";
|
|
version = toString version;
|
|
|
|
src = fetchurl {
|
|
inherit url;
|
|
sha256 = checksum;
|
|
};
|
|
dontUnpack = true;
|
|
|
|
installPhase = ''
|
|
TARGET="$out/share/translateLocally/models"
|
|
mkdir -p "$TARGET"
|
|
tar -xzf "$src" -C "$TARGET"
|
|
|
|
# avoid patching shebangs in inconsistently executable extra files
|
|
find "$out" -type f -exec chmod -x {} +
|
|
'';
|
|
|
|
meta = {
|
|
description = "translateLocally model - ${name}";
|
|
homepage = "https://translatelocally.com/";
|
|
# https://github.com/browsermt/students/blob/master/LICENSE.md
|
|
license = lib.licenses.cc-by-sa-40;
|
|
};
|
|
};
|
|
allModelPkgs =
|
|
lib.listToAttrs (map (withCodeAsKey mkModelPackage) modelSpecs);
|
|
|
|
in allModelPkgs // {
|
|
is-en-tiny = allModelPkgs.is-en-tiny.overrideAttrs (super: {
|
|
# missing model https://github.com/XapaJIaMnu/translateLocally/issues/147
|
|
meta = super.meta // { broken = true; };
|
|
});
|
|
} // {
|
|
passthru.updateScript = ./update.sh;
|
|
}
|