mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-02 04:50:21 +00:00
lrcget: 2.1.0 -> 2.2.0 (#564408)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
fetchFromGitHub,
|
||||
fetchNpmDeps,
|
||||
fetchurl,
|
||||
|
||||
cargo-tauri,
|
||||
makeBinaryWrapper,
|
||||
@@ -22,24 +23,34 @@
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "lrcget";
|
||||
version = "2.1.0";
|
||||
version = "2.2.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "tranxuanthang";
|
||||
repo = "lrcget";
|
||||
tag = version;
|
||||
hash = "sha256-cxQpCuyFsJeujcL2TPMH7n+Q6l4h+P1HvsrMoFmbWMI=";
|
||||
hash = "sha256-sp31o62rwWONd7ajo8prvkEVbU3lPPLFkXsxAT9oRzY=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# needed to not attempt codesigning on darwin
|
||||
./remove-signing-identity.patch
|
||||
|
||||
# Make npm ci pass by adding missing packages to package-lock.json
|
||||
# Upstream PR: https://github.com/tranxuanthang/lrcget/pull/408
|
||||
./sync-package-lock.patch
|
||||
];
|
||||
|
||||
cargoPatches = [
|
||||
# Update charabia crate to v0.10.0 to allow caching of Lindera dictionaries
|
||||
# Upstream PR: https://github.com/tranxuanthang/lrcget/pull/407
|
||||
./update-to-charabia-0.10.0.patch
|
||||
];
|
||||
|
||||
cargoRoot = "src-tauri";
|
||||
buildAndTestSubdir = "src-tauri";
|
||||
|
||||
cargoHash = "sha256-9vyvRJsR4o7kWSLJyGIoiM/13ABWWTrRXVdyU2HfJ+E=";
|
||||
cargoHash = "sha256-qyIvUbEBImJfVaxILtLN88KREgUk45zRdxbdZ1A6vc0=";
|
||||
|
||||
# FIXME: This is a workaround, because we have a git dependency node_modules/lrc-kit contains install scripts
|
||||
# but has no lockfile, which is something that will probably break.
|
||||
@@ -48,9 +59,73 @@ rustPlatform.buildRustPackage rec {
|
||||
npmDeps = fetchNpmDeps {
|
||||
name = "lrcget-${version}-npm-deps";
|
||||
inherit src forceGitDeps patches;
|
||||
hash = "sha256-yXRbQ6xM23VrVaS8Hb5sxPPic1yawKtFi2rCGkplgw4=";
|
||||
hash = "sha256-PyKnh2AjdhWurTQmoCuOnLDdDIcZT51xwpPImkc3nBc=";
|
||||
};
|
||||
|
||||
preConfigure =
|
||||
let
|
||||
# Adapted from pg_search's Nix package: https://github.com/NixOS/nixpkgs/blob/b1b875982b17dabde9b4a37f3e229e74913e6db3/pkgs/servers/sql/postgresql/ext/pg_search.nix#L27
|
||||
# Lindera dictionaries are copied to a temporary directory and Lindera's
|
||||
# cache environment variable prevents the build.rs files in
|
||||
# the Lindera crates from downloading their dictionary from an
|
||||
# external URL, which doesn't work in the Nix sandbox.
|
||||
|
||||
# Lindera uses subdirectory in the main cache directory to separate cached
|
||||
# dictionaries for different versions of Lindera.
|
||||
# The name of those subdirectories is made up of the Lindera version
|
||||
# and the "format" version (currently only for format version 2).
|
||||
# LRCGET's Lindera version is in their Cargo.lock file: https://github.com/tranxuanthang/lrcget/tree/${version}/src-tauri/Cargo.lock
|
||||
# And the current format version is 2, represented by the -fmt2 suffix in the subdirectory name.
|
||||
cacheSubdir = "5.3.0-fmt2";
|
||||
|
||||
# The env var Lindera uses for the cache has changed over time.
|
||||
# Currently, the correct variable name is LINDERA_BUILD_DICTIONARY_CACHE_DIR.
|
||||
dictCacheVarName = "LINDERA_BUILD_DICTIONARY_CACHE_DIR";
|
||||
|
||||
# The Lindera uses several language dictionaries that can be enabled by consuming apps and libraries.
|
||||
# Check the relevant build.rs files to get the proper URLs:
|
||||
# https://github.com/lindera/lindera/blob/${linderaVersion}/${dictionaryKey}/build.rs
|
||||
# Here's an example build.rs URL:
|
||||
# https://github.com/lindera/lindera/blob/v1.5.1/lindera-cc-cedict/build.rs
|
||||
|
||||
dict =
|
||||
{
|
||||
language,
|
||||
filename,
|
||||
hash,
|
||||
}:
|
||||
{
|
||||
inherit filename language;
|
||||
source = fetchurl {
|
||||
url = "https://lindera.dev/${filename}";
|
||||
inherit hash;
|
||||
};
|
||||
};
|
||||
|
||||
# LRCGET via charabia requires the Korean and Japanese (unidic) dictionaries.
|
||||
dictionaries = {
|
||||
lindera-ko-dic = dict {
|
||||
language = "Korean";
|
||||
filename = "mecab-ko-dic-2.1.1-20180720.tar.gz";
|
||||
hash = "sha256-cCztIcYWfp2a68Z0q17lSvWNREOXXylA030FZ8AgWRo=";
|
||||
};
|
||||
lindera-unidic = dict {
|
||||
language = "Japanese";
|
||||
filename = "unidic-mecab-2.1.2.tar.gz";
|
||||
hash = "sha256-JKx1/k5E2XO1XmWEfDX6Suwtt6QaB7ScoSUUbbn8EYk=";
|
||||
};
|
||||
};
|
||||
in
|
||||
''
|
||||
export ${dictCacheVarName}=$TMPDIR/lindera-cache
|
||||
mkdir -p ''$${dictCacheVarName}/${cacheSubdir}
|
||||
${lib.concatMapStringsSep "\n" (dict: ''
|
||||
echo "Copying ${dict.language} dictionary to Lindera cache"
|
||||
cp -r ${dict.source} ''$${dictCacheVarName}/${cacheSubdir}/${dict.filename}
|
||||
'') (lib.attrValues dictionaries)}
|
||||
echo "Lindera cache prepared at ''$${dictCacheVarName}"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo-tauri.hook
|
||||
nodejs
|
||||
|
||||
66
pkgs/by-name/lr/lrcget/sync-package-lock.patch
Normal file
66
pkgs/by-name/lr/lrcget/sync-package-lock.patch
Normal file
@@ -0,0 +1,66 @@
|
||||
diff --git a/package-lock.json b/package-lock.json
|
||||
index 7265f5f..e44f063 100644
|
||||
--- a/package-lock.json
|
||||
+++ b/package-lock.json
|
||||
@@ -192,6 +192,29 @@
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
+ "node_modules/@emnapi/core": {
|
||||
+ "version": "1.10.0",
|
||||
+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
|
||||
+ "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
|
||||
+ "dev": true,
|
||||
+ "license": "MIT",
|
||||
+ "optional": true,
|
||||
+ "dependencies": {
|
||||
+ "@emnapi/wasi-threads": "1.2.1",
|
||||
+ "tslib": "^2.4.0"
|
||||
+ }
|
||||
+ },
|
||||
+ "node_modules/@emnapi/runtime": {
|
||||
+ "version": "1.10.0",
|
||||
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
|
||||
+ "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
|
||||
+ "dev": true,
|
||||
+ "license": "MIT",
|
||||
+ "optional": true,
|
||||
+ "dependencies": {
|
||||
+ "tslib": "^2.4.0"
|
||||
+ }
|
||||
+ },
|
||||
"node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||
@@ -5866,8 +5889,30 @@
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
+ "node_modules/@emnapi/core": {
|
||||
+ "version": "1.10.0",
|
||||
+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
|
||||
+ "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
|
||||
+ "dev": true,
|
||||
+ "optional": true,
|
||||
+ "requires": {
|
||||
+ "@emnapi/wasi-threads": "1.2.1",
|
||||
+ "tslib": "^2.4.0"
|
||||
+ }
|
||||
+ },
|
||||
+ "node_modules/@emnapi/runtime": {
|
||||
+ "version": "1.10.0",
|
||||
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
|
||||
+ "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
|
||||
+ "dev": true,
|
||||
+ "optional": true,
|
||||
+ "requires": {
|
||||
+ "tslib": "^2.4.0"
|
||||
+ }
|
||||
+ },
|
||||
"@emnapi/wasi-threads": {
|
||||
- "version": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||
+ "version": "1.2.1",
|
||||
+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||
"integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
1427
pkgs/by-name/lr/lrcget/update-to-charabia-0.10.0.patch
Normal file
1427
pkgs/by-name/lr/lrcget/update-to-charabia-0.10.0.patch
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user