From 421a736cafb74a1f75ccd2d24784f2dd24940e3f Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:53:20 +0100 Subject: [PATCH] desktop-postflop: use cargo-tauri.hook --- pkgs/by-name/de/desktop-postflop/package.nix | 73 ++++++++------------ 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/pkgs/by-name/de/desktop-postflop/package.nix b/pkgs/by-name/de/desktop-postflop/package.nix index 0eb643a44b041f..8ac19a80366672 100644 --- a/pkgs/by-name/de/desktop-postflop/package.nix +++ b/pkgs/by-name/de/desktop-postflop/package.nix @@ -1,13 +1,18 @@ -{ lib -, rustPlatform -, buildNpmPackage -, fetchFromGitHub -, copyDesktopItems -, makeDesktopItem -, pkg-config -, gtk3 -, libsoup -, webkitgtk_4_0 +{ + lib, + stdenv, + rustPlatform, + fetchFromGitHub, + fetchNpmDeps, + + npmHooks, + nodejs, + + cargo-tauri, + pkg-config, + + libsoup, + webkitgtk_4_0, }: rustPlatform.buildRustPackage rec { @@ -17,24 +22,15 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "b-inary"; repo = "desktop-postflop"; - rev = "v${version}"; + rev = "refs/tags/v${version}"; hash = "sha256-pOPxNHM4mseIuyyWNoU0l+dGvfURH0+9+rmzRIF0I5s="; }; - npmDist = buildNpmPackage { - name = "${pname}-${version}-dist"; + npmDeps = fetchNpmDeps { inherit src; - - npmDepsHash = "sha256-HWZLicyKL2FHDjZQj9/CRwVi+uc/jHmVNxtlDuclf7s="; - - installPhase = '' - mkdir -p $out - cp -r dist/* $out - ''; + hash = "sha256-HWZLicyKL2FHDjZQj9/CRwVi+uc/jHmVNxtlDuclf7s="; }; - sourceRoot = "${src.name}/src-tauri"; - cargoLock = { lockFile = ./Cargo.lock; outputHashes = { @@ -43,46 +39,35 @@ rustPlatform.buildRustPackage rec { }; postPatch = '' - substituteInPlace tauri.conf.json \ - --replace "../dist" "${npmDist}" + cp ${./Cargo.lock} src-tauri/Cargo.lock ''; + cargoRoot = "src-tauri"; + buildAndTestSubdir = cargoRoot; + # postflop-solver requires unstable rust features env.RUSTC_BOOTSTRAP = 1; nativeBuildInputs = [ - copyDesktopItems + npmHooks.npmConfigHook + nodejs + + cargo-tauri.hook pkg-config ]; - buildInputs = [ - gtk3 + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ libsoup webkitgtk_4_0 ]; - postInstall = '' - install -Dm644 ${src}/public/favicon.png $out/share/icons/hicolor/128x128/apps/desktop-postflop.png - ''; - - desktopItems = [ - (makeDesktopItem { - name = "desktop-postflop"; - exec = "desktop-postflop"; - icon = "desktop-postflop"; - desktopName = "Desktop Postflop"; - comment = meta.description; - categories = [ "Utility" ]; - terminal = false; - }) - ]; - meta = { - changelog = "https://github.com/b-inary/desktop-postflop/releases/tag/${src.rev}"; + changelog = "https://github.com/b-inary/desktop-postflop/releases/tag/v${version}"; description = "Free, open-source GTO solver for Texas hold'em poker"; homepage = "https://github.com/b-inary/desktop-postflop"; license = lib.licenses.agpl3Plus; mainProgram = "desktop-postflop"; maintainers = with lib.maintainers; [ tomasajt ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; }; }