1# cargo-tauri.hook {#tauri-hook}
2
3[Tauri](https://tauri.app/) is a framework for building smaller, faster, and
4more secure desktop applications with a web frontend.
5
6In Nixpkgs, `cargo-tauri.hook` overrides the default build and install phases.
7
8## Example code snippet {#tauri-hook-example-code-snippet}
9
10```nix
11{
12 lib,
13 stdenv,
14 rustPlatform,
15 fetchNpmDeps,
16 cargo-tauri,
17 glib-networking,
18 nodejs,
19 npmHooks,
20 openssl,
21 pkg-config,
22 webkitgtk_4_1,
23 wrapGAppsHook4,
24}:
25
26rustPlatform.buildRustPackage (finalAttrs: {
27 # ...
28
29 cargoHash = "...";
30
31 # Assuming our app's frontend uses `npm` as a package manager
32 npmDeps = fetchNpmDeps {
33 name = "${finalAttrs.pname}-npm-deps-${finalAttrs.version}";
34 inherit src;
35 hash = "...";
36 };
37
38 nativeBuildInputs =
39 [
40 # Pull in our main hook
41 cargo-tauri.hook
42
43 # Setup npm
44 nodejs
45 npmHooks.npmConfigHook
46
47 # Make sure we can find our libraries
48 pkg-config
49 ]
50 ++ lib.optionals stdenv.hostPlatform.isLinux [
51 wrapGAppsHook4
52 ];
53
54 buildInputs =
55 [ openssl ]
56 ++ lib.optionals stdenv.hostPlatform.isLinux [
57 glib-networking # Most Tauri apps need networking
58 webkitgtk_4_1
59 ];
60
61 # Set our Tauri source directory
62 cargoRoot = "src-tauri";
63 # And make sure we build there too
64 buildAndTestSubdir = cargoRoot;
65
66 # ...
67})
68```
69
70## Variables controlling cargo-tauri {#tauri-hook-variables-controlling}
71
72### Tauri Exclusive Variables {#tauri-hook-exclusive-variables}
73
74#### `tauriBuildFlags` {#tauri-build-flags}
75
76Controls the flags passed to `cargo tauri build`.
77
78#### `tauriBundleType` {#tauri-bundle-type}
79
80The [bundle type](https://tauri.app/v1/guides/building/) to build.
81
82#### `dontTauriBuild` {#dont-tauri-build}
83
84Disables using `tauriBuildHook`.
85
86#### `dontTauriInstall` {#dont-tauri-install}
87
88Disables using `tauriInstallPostBuildHook` and `tauriInstallHook`.
89
90### Honored Variables {#tauri-hook-honored-variables}
91
92Along with those found in [](#compiling-rust-applications-with-cargo), the
93following variables used by `cargoBuildHook` and `cargoInstallHook` are honored
94by the cargo-tauri setup hook.
95
96- `buildAndTestSubdir`
97- `cargoBuildType`
98- `cargoBuildNoDefaultFeatures`
99- `cargoBuildFeatures`