From 56c9178c91b0b8ff43930c31c67a80ad1c90106a Mon Sep 17 00:00:00 2001 From: robcohen Date: Wed, 28 Jan 2026 17:18:55 -0600 Subject: [PATCH] fix: find example file in Nix flake installs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add fallback path resolution relative to the executable for Nix installs where the layout is bin/rustfava-desktop alongside lib/rustfava/resources/example.beancount. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- desktop/src-tauri/src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index 3447bc516..3a4b86311 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -45,6 +45,20 @@ fn get_example_file_path(app: AppHandle) -> Result { return Ok(bundled_path.to_string_lossy().to_string()); } + // Fall back to path relative to executable (for Nix flake installs) + // Nix layout: bin/rustfava-desktop, lib/rustfava/resources/example.beancount + if let Ok(exe_path) = std::env::current_exe() { + if let Some(bin_dir) = exe_path.parent() { + let nix_path = bin_dir.parent() + .map(|p| p.join("lib").join("rustfava").join("resources").join("example.beancount")); + if let Some(path) = nix_path { + if path.exists() { + return Ok(path.to_string_lossy().to_string()); + } + } + } + } + // Fall back to development path (relative to desktop/src-tauri) let dev_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .parent() // desktop/