Jump to content

Tauri: Difference between revisions

From NixOS Wiki
Documentation for tauri on Nix
 
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{warning | Incomplete Documentation Reason: being worked on}}  
{{warning | Work in Progress}}


[https://tauri.app/ | Tauri] is a optimized & secure [ Electron] Alternative out there. It runs natively
== Development environment with <code>nix-shell</code> ==
 
References
== Getting Started With Developing [https://tauri.app/ | Tauri] on [https://nixos.org/ | Nix/NixOS] ==
 
To get started developing[https://tauri.app/ | Tauri] you need a setup a devshell with the following packages:
...
 
 
== Building A Tauri App Using Nix ==  
To build a tauri app use the following template below


* [[Development environment with nix-shell|https://wiki.nixos.org/wiki/Development_environment_with_nix-shell]] (2025-01-23)
* https://v2.tauri.app/start/prerequisites/ (2025-01-23)
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
# Run with `nix-shell shell.nix`
  lib,
  buildNpmPackage,
  openssl,
  stdenv,
  pkg-config,
  glibc,
  libsoup_3,
  gtk3,
  cairo,
  webkitgtk_4_1,
  nodejs-slim,
  cargo-tauri,
  cargo,
  rustPlatform,
  rustc,
  bun,
  darwin,
  llvmPackages,
  rustup,
  libiconv,
}:
 
let
let
   inherit (darwin.apple_sdk.frameworks)
   pkgs = import <nixpkgs> { };
    Security
    SystemConfiguration
    AppKit
    WebKit
    CoreFoundation
    ;
in
in
buildNpmPackage rec {
pkgs.mkShell {
   pname = "Example Name"; # TODO: Change This
   nativeBuildInputs = with pkgs; [
  version = "0.0.1-dev"; # TODO: Change This
    pkg-config
  dontNpmBuild = true; # Don't want to npm build since it will produce the application from tauri
    gobject-introspection
    cargo
    cargo-tauri # Optional, Only needed if Tauri doesn't work through the traditional way.
    nodejs # Optional, this is for if you have a js frontend
  ];


   src = ./..;
   buildInputs = with pkgs;[
 
    at-spi2-atk
   npmDepsHash = "sha256-eNAOAjBZQ/L9MMHRFOZi6+wIsj0axF6y7bbdswOuPww=";
    atkmm
    cairo
    gdk-pixbuf
    glib
    gtk3
    harfbuzz
    librsvg
    libsoup_3
    pango
    webkitgtk_4_1
    openssl
  ];
   # shellHook = "";
}


  cargoDeps = rustPlatform.importCargoLock {
    lockFile = "${src}/src-tauri/Cargo.lock";
    outputHashes = {
      "tauri-plugin-clipboard-manager-2.1.0-beta.1" = "sha256-2F+OkX92B2/aJva86orotHc7mYUZuaYAmKx50dDp2Sc=";
    };
  };
  configurePhase = ''
    export HOME=$(mktemp -d)
  '';
  preBuild = if stdenv.isLinux then "cargo tauri build -b deb" else "cargo tauri build -b app";
  cargoRoot = "src-tauri/";
  preInstall =
    if stdenv.isLinux then
      "mv src-tauri/target/release/bundle/deb/*/data/usr/ \"$out\""
    else
      "mv src-tauri/target/release/bundle/macos/* \"$out/\"";
  nativeBuildInputs =
    [
      pkg-config
      rustPlatform.cargoSetupHook
      cargo
      rustc
      cargo-tauri
      nodejs-slim
      openssl
      bun
    ]
    ++ lib.optionals stdenv.isDarwin [
      llvmPackages.libcxxStdenv
      llvmPackages.libcxxClang
      llvmPackages.libcxx
      darwin.libobjc
      darwin.libiconv
      libiconv
      Security
      SystemConfiguration
      AppKit
      WebKit
      CoreFoundation
    ];
  buildInputs =
    [ openssl ]
    ++ lib.optionals stdenv.isLinux [
      glibc
      libsoup_3
      cairo
      gtk3
      webkitgtk_4_1
    ]
    ++ lib.optionals stdenv.isDarwin [
      Security
      darwin.libiconv
      SystemConfiguration
      AppKit
      WebKit
      rustup
    ];
  meta = with lib; {
    description = "Example description"; # TODO: Change This
    homepage = "https://example.com"; # TODO: Change This
    license = with licenses; [ MIT ]; # TODO: Change This
    mainProgram = "program"; # TODO: Change This
    maintainers = with maintainers; []; # TODO: Change This
  };
}
</syntaxhighlight>
</syntaxhighlight>


 
== Building a Tauri app on nixpkgs? ==
{{note | You may need a beta version of [Cargo Tauri] please grab the package the nixpkgs source and modify version and hashes. If your maintainer of cargo-tauri please consider a beta version of the package}}
A distribution mechanism has been implemented for Tauri applications within Nixpkgs. Refer to the Nixpkgs documentation for implementation details. [https://nixos.org/manual/nixpkgs/unstable/#tauri-hook here]

Latest revision as of 18:17, 28 February 2025

Warning: Work in Progress

Development environment with nix-shell

References

# Run with `nix-shell shell.nix`
let
  pkgs = import <nixpkgs> { };
in
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    pkg-config
    gobject-introspection
    cargo 
    cargo-tauri # Optional, Only needed if Tauri doesn't work through the traditional way.
    nodejs # Optional, this is for if you have a js frontend
  ];

  buildInputs = with pkgs;[
    at-spi2-atk
    atkmm
    cairo
    gdk-pixbuf
    glib
    gtk3
    harfbuzz
    librsvg
    libsoup_3
    pango
    webkitgtk_4_1
    openssl
  ];
  # shellHook = "";
}

Building a Tauri app on nixpkgs?

A distribution mechanism has been implemented for Tauri applications within Nixpkgs. Refer to the Nixpkgs documentation for implementation details. here