lrcget: use cargo-tauri.hook

This commit is contained in:
TomaSajt 2025-05-14 21:47:26 +02:00
parent 851c8b9a53
commit 9887ab90ba
2 changed files with 71 additions and 68 deletions

View file

@ -1,20 +1,25 @@
{
dbus,
openssl,
gtk3,
webkitgtk_4_1,
pkg-config,
wrapGAppsHook3,
fetchFromGitHub,
buildNpmPackage,
rustPlatform,
lib,
stdenv,
copyDesktopItems,
makeDesktopItem,
rustPlatform,
fetchFromGitHub,
fetchNpmDeps,
cargo-tauri,
makeBinaryWrapper,
nodejs,
npmHooks,
pkg-config,
wrapGAppsHook3,
alsa-lib,
openssl,
webkitgtk_4_1,
nix-update-script,
}:
rustPlatform.buildRustPackage rec {
pname = "lrcget";
version = "0.9.3";
@ -22,85 +27,70 @@ rustPlatform.buildRustPackage rec {
src = fetchFromGitHub {
owner = "tranxuanthang";
repo = "lrcget";
rev = "${version}";
tag = version;
hash = "sha256-3dBjQ1fO1q8JCQFvvV8LWBCD8cKFkFmm8ufC/Xihmj4=";
};
sourceRoot = "${src.name}/src-tauri";
patches = [
# needed to not attempt codesigning on darwin
./remove-signing-identity.patch
];
cargoRoot = "src-tauri";
buildAndTestSubdir = "src-tauri";
useFetchCargoVendor = true;
cargoHash = "sha256-Nu1N96OrLG/D2/1vbU229jLVNZuKIiCSwDJA25hlqFM=";
frontend = buildNpmPackage {
inherit version src;
pname = "lrcget-ui";
# 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.
forceGitDeps = true;
distPhase = "true";
dontInstall = true;
# To fix `npm ERR! Your cache folder contains root-owned files`
makeCacheWritable = true;
# 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.
forceGitDeps = true;
npmDepsHash = "sha256-N48+C3NNPYg/rOpnRNmkZfZU/ZHp8imrG/tiDaMGsCE=";
postBuild = ''
cp -r dist/ $out
'';
npmDeps = fetchNpmDeps {
name = "lrcget-${version}-npm-deps";
inherit src forceGitDeps;
hash = "sha256-N48+C3NNPYg/rOpnRNmkZfZU/ZHp8imrG/tiDaMGsCE=";
};
# copy the frontend static resources to final build directory
# Also modify tauri.conf.json so that it expects the resources at the new location
postPatch = ''
cp -r $frontend ./frontend
substituteInPlace tauri.conf.json \
--replace-fail '"frontendDist": "../dist"' '"frontendDist": "./frontend"'
'';
nativeBuildInputs = [
pkg-config
wrapGAppsHook3
copyDesktopItems
rustPlatform.bindgenHook
];
buildInputs =
nativeBuildInputs =
[
dbus
openssl
gtk3
cargo-tauri.hook
nodejs
npmHooks.npmConfigHook
rustPlatform.bindgenHook
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
webkitgtk_4_1
alsa-lib
pkg-config
wrapGAppsHook3
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
makeBinaryWrapper
];
buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [
alsa-lib
openssl
webkitgtk_4_1
];
# To fix `npm ERR! Your cache folder contains root-owned files`
makeCacheWritable = true;
# Disable checkPhase, since the project doesn't contain tests
doCheck = false;
postInstall = ''
install -DT icons/128x128@2x.png $out/share/icons/hicolor/128x128@2/apps/lrcget.png
install -DT icons/128x128.png $out/share/icons/hicolor/128x128/apps/lrcget.png
install -DT icons/32x32.png $out/share/icons/hicolor/32x32/apps/lrcget.png
# make the binary also runnable from the shell
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
makeWrapper "$out/Applications/LRCGET.app/Contents/MacOS/LRCGET" "$out/bin/LRCGET"
'';
# WEBKIT_DISABLE_COMPOSITING_MODE essential in NVIDIA + compositor https://github.com/NixOS/nixpkgs/issues/212064#issuecomment-1400202079
postFixup = ''
wrapProgram "$out/bin/lrcget" \
preFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
gappsWrapperArgs+=(
# WEBKIT_DISABLE_COMPOSITING_MODE essential in NVIDIA + compositor https://github.com/NixOS/nixpkgs/issues/212064#issuecomment-1400202079
--set WEBKIT_DISABLE_COMPOSITING_MODE 1
)
'';
desktopItems = [
(makeDesktopItem {
name = "LRCGET";
exec = "lrcget";
icon = "lrcget";
desktopName = "LRCGET";
comment = meta.description;
})
];
passthru.updateScript = nix-update-script { };
meta = {
@ -112,7 +102,7 @@ rustPlatform.buildRustPackage rec {
anas
Scrumplex
];
mainProgram = "lrcget";
mainProgram = "LRCGET";
platforms = with lib.platforms; unix ++ windows;
};
}

View file

@ -0,0 +1,13 @@
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 92d43e7..6519fd0 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -36,7 +36,7 @@
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
- "signingIdentity": "-"
+ "signingIdentity": null
},
"resources": [],
"shortDescription": "Utility for mass-downloading LRC synced lyrics for your offline music library.",