Tauri Apps - lets build it with Nix!

Hey folks!

I am super excited about Tauri. Tauri is a Rust and WebView-powered Electron-alternative.

tauri.studio → https://tauri.studio/en/

The project, team, and the product/infra/tooling they’ve already built is quite impressive to me:

  • automated benchmarks for example apps vs Electron
  • GHA for producing final release-able apps for all platforms automatically
  • Rust and JS tooling
  • Vue helpers and a create-tauri-app starter

It feels like a project with serious momentum and serious vision and determination.

I suspect we will need to build something in nixpkgs to make it relatively easy to package these Tauri apps. I don’t have a lot of experience orchestrating more complex builds with Nix, nor do I have a lot of (any) experience with Tauri but I’m excited and wanted to start a discussion.

For now I’m mostly just expressing interest in case someone else wants to chat about it or tinker with me.

15 Likes

Hey there @colemickens, Did you make any progress on this? I am a junior software engineer who has recently joined the Nix community and I’m looking for this, I will also gladly contribute by testing and building some tauri applications.

1 Like

How does it compare with something like Flutter? Is it a drop-in replacement for electron?

2 Likes

It is a framework that is similar but a lot more efficient and safe than electron, you can write your backend in rust and your UI with any web framework (such as react or svelte), but instead of shipping a whole chromium browser with the application it creates a native window and renders a native webView, So it is way less resource intensive and applications compile to a very small binary. I haven’t used flutter so I am unsure how to compare it, but here is a quick video (2:37) Which explains it in a very simple amd understandable way https://youtu.be/-X8evddpu7M

There’s an example of packaging a Tauri-based project in Nixpkgs here cinny-desktop: init at 2.1.1 by aveltras · Pull Request #185427 · NixOS/nixpkgs · GitHub but unfortunately it’s just using the compiled Debian package from the release and unpacking it.

I will note that, nowadays, cargo-tauri is available in nixpkgs (unstable only).
When using cargo tauri build, you get an error about AppImages, but it’s possible to make it only try to build the deb.
You can then pull the files from the cargo target directory (or from the Deb if you really prefer).
I don’t know if you can generate the distribution files without asking to build either the Deb or the AppImage; this is something we could request on Tauri’s issue tracker if not possible.

I don’t know if this can be made to fit in to Nix’s normal procedures for packaging Rust projects, but at least it seems like there’s an option that lets us build from source.

I will look into this soon, but I thought it would be prudent to drop a note here for future reference in case I don’t make any progress beyond this point

3 Likes

I initially packaged cargo-tauri thinking it might be required for Tauri projects but it seems like there is not much special about Tauri than a regular Rust project with a dist directory of static contents. However, building that static content remains challenging given the lack of support for varios JavaScript ecosystem nuances.

I also have an open PR for a Tauri based app - xplorer: init at unstable-2022-08-11 by dit7ya · Pull Request #187547 · NixOS/nixpkgs · GitHub

Edit: The PR was failing but I have figured out the cause most likely.

2 Likes

Hi! Maybe somewhat tangential to the topic here, but I guess that’s the best place to ask: Has someone managed to open the devtools in a tauri based application? See also [bug] nixos/nix development shell: Opening devtools does not work · Issue #5711 · tauri-apps/tauri · GitHub … I just can’t see how to get it working…

it seems to me that this is a nixos related problem, some lib missing or something… that’s why I am asking here as well.