From a385371c32613c1ec2649a4f51522a7ddefb5d4c Mon Sep 17 00:00:00 2001 From: Evgeny Khudoba Date: Thu, 30 Apr 2026 07:46:23 +0700 Subject: [PATCH] refactor(nix): rely on cargo-tauri.hook standard phases (#1335) Set buildAndTestSubdir + tauriBundleType so cargo-tauri.hook handles build/install correctly, and drop the manual overrides: - installPhase override (was needed because hook didn't know to pushd into src-tauri without buildAndTestSubdir; hook's install script now finds bundle/deb/.../data/usr/* on its own) - preBuild with `bun run build` (hook runs beforeBuildCommand from tauri.conf.json itself; bun2nix.hook has node_modules ready before buildPhase) - jq del(.build.beforeBuildCommand) in postPatch (no longer needed) Net change: +3/-18. End-to-end verified on NixOS x86_64-linux: GigaAM v3 ASR + Whisper large-v3-turbo on Vulkan both work. --- flake.nix | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 52f69b5..718328f 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,8 @@ src = self; cargoRoot = "src-tauri"; + buildAndTestSubdir = "src-tauri"; + tauriBundleType = "deb"; cargoLock = { lockFile = ./src-tauri/Cargo.lock; @@ -103,7 +105,7 @@ }; postPatch = '' - ${pkgs.jq}/bin/jq 'del(.build.beforeBuildCommand) | .bundle.createUpdaterArtifacts = false' \ + ${pkgs.jq}/bin/jq '.bundle.createUpdaterArtifacts = false' \ src-tauri/tauri.conf.json > $TMPDIR/tauri.conf.json cp $TMPDIR/tauri.conf.json src-tauri/tauri.conf.json @@ -150,27 +152,10 @@ shaderc ]; - preBuild = '' - # bun2nix.hook has already set up node_modules from pre-fetched cache. - # Build the frontend with bun (tsc + vite). - export HOME=$TMPDIR - bun run build - ''; - # Tests require runtime resources (audio devices, model files, GPU/Vulkan) # not available in the Nix build sandbox doCheck = false; - # The tauri hook's installPhase expects target/ in cwd, but our - # cargoRoot puts it under src-tauri/. Override to extract the DEB. - installPhase = '' - runHook preInstall - mkdir -p $out - cd src-tauri - mv target/${pkgs.stdenv.hostPlatform.rust.rustcTarget}/release/bundle/deb/*/data/usr/* $out/ - runHook postInstall - ''; - buildInputs = commonNativeDeps pkgs ++ (with pkgs; [ glib-networking libx11