Unverified Commit 0951a30f authored by Toma's avatar Toma Committed by GitHub
Browse files

[Backport release-25.05] lrcget: use cargo-tauri.hook (#408718)

parents 2d8aa81e 2db6cadf
Loading
Loading
Loading
Loading
+59 −69
Original line number Diff line number Diff line
{
  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;

    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 = [
  nativeBuildInputs =
    [
      cargo-tauri.hook
      nodejs
      npmHooks.npmConfigHook
      rustPlatform.bindgenHook
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
      pkg-config
      wrapGAppsHook3
    copyDesktopItems
    rustPlatform.bindgenHook
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      makeBinaryWrapper
    ];

  buildInputs =
    [
      dbus
  buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [
    alsa-lib
    openssl
      gtk3
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
    webkitgtk_4_1
      alsa-lib
  ];

  # 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"
  '';

  preFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
    gappsWrapperArgs+=(
      # WEBKIT_DISABLE_COMPOSITING_MODE essential in NVIDIA + compositor https://github.com/NixOS/nixpkgs/issues/212064#issuecomment-1400202079
  postFixup = ''
    wrapProgram "$out/bin/lrcget" \
      --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;
  };
}
+13 −0
Original line number Diff line number Diff line
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.",