Tauri: Difference between revisions

From NixOS Wiki
Documentation for tauri on Nix
 
Blanked the page
Tag: Blanking
Line 1: Line 1:
{{warning | Incomplete Documentation Reason: being worked on}}


[https://tauri.app/ | Tauri] is a optimized & secure [ Electron] Alternative out there. It runs natively
== 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
<syntaxhighlight lang="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
  inherit (darwin.apple_sdk.frameworks)
    Security
    SystemConfiguration
    AppKit
    WebKit
    CoreFoundation
    ;
in
buildNpmPackage rec {
  pname = "Example Name"; # TODO: Change This
  version = "0.0.1-dev"; # TODO: Change This
  dontNpmBuild = true; # Don't want to npm build since it will produce the application from tauri
  src = ./..;
  npmDepsHash = "sha256-eNAOAjBZQ/L9MMHRFOZi6+wIsj0axF6y7bbdswOuPww=";
  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>
{{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}}

Revision as of 16:32, 15 July 2024