tauri
                                
                                 tauri copied to clipboard
                                
                                    tauri copied to clipboard
                            
                            
                            
                        [bug] AppImage build fail with Nix Flake
Describe the bug
Hello,
I'm on Ubuntu 22.04 but using Nix package manager.
After following your prerequisites for NixOS and attempting to build a tauri project with the below flake.nix, I got the following error:
-- Running input plugin: gtk --
[gtk/stderr] chmod: cannot access 'edgen-chat.AppDir/usr/lib64': No such file or directory
[gtk/stdout] Installing AppRun hook
[gtk/stderr] cp: cannot stat '/nix/store/2if9iy5cy0bicwafllpa2aiq30v26app-glib-2.78.1/share/glib-2.0/schemas': No such file or directory
[gtk/stdout] Installing GLib schemas
ERROR: Failed to run plugin: gtk (exit code: 1)
       Error [tauri_cli_node] failed to bundle project: error running appimage.sh
error Command failed with exit code 1.
Thanks in advance
Reproduction
flake.nix:
{
    inputs = {
        nixpkgs.url = "nixpkgs";
        rust-overlay.url = "github:oxalica/rust-overlay";
        flake-utils.url = "github:numtide/flake-utils";
    };
    outputs = { self, nixpkgs, rust-overlay, flake-utils }:
        flake-utils.lib.eachDefaultSystem (system:
        let
            overlays = [ (import rust-overlay) ];
            pkgs = import nixpkgs {
                inherit system overlays;
            };
            rust-toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
                extensions = [ "rust-src" ];
                #targets = [ "wasm32-unknown-unknown" ];
            });
            nativeBuildInputs = with pkgs; [
                pkg-config
                rust-toolchain
            ];
            libraries = with pkgs;[
                webkitgtk
                gtk3
                cairo
                gdk-pixbuf
                glib
                dbus
                openssl_3
                librsvg
            ];
            packages = with pkgs; [
                curl
                wget
                dbus
                openssl_3
                glib
                gtk3
                gdk-pixbuf
                libsoup
                pango
                harfbuzz
                at-spi2-atk
                cairo
                webkitgtk
                librsvg
                yarn
                nodejs_18
            ];
            buildInputs = packages;
        in
        rec {
            # `nix develop`
            devShell = pkgs.mkShell {
                inherit buildInputs nativeBuildInputs;
                shellHook = ''
                # For rust-analyzer 'hover' tooltips to work.
                export RUST_SRC_PATH=${rust-toolchain}
                # add ~/.cargo/bin to PATH for crates installed with `cargo install`
                export PATH=$PATH:$HOME/.cargo/bin
                
                export RUST_BACKTRACE=1
                # tauri
                export WEBKIT_DISABLE_COMPOSITING_MODE=1
                export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH
                export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
                '';
            };
        });
}
Expected behavior
Successful build with no issues.
Full tauri info output
[⚠] Environment
    - OS: Ubuntu 22.04 X64
    ✔ webkit2gtk-4.0: 2.42.3
    ✔ rsvg2: 2.57.0
    ✔ rustc: 1.77.0-nightly (3d0e6bed6 2023-12-21)
    ✔ cargo: 1.77.0-nightly (1a2666ddd 2023-12-17)
    ⚠ rustup: not installed!
      If you have rust installed some other way, we recommend uninstalling it
      then use rustup instead. Visit https://rustup.rs/
    ⚠ Rust toolchain: couldn't be detected!
      Maybe you don't have rustup installed? if so, Visit https://rustup.rs/
    - node: 18.19.0
    - yarn: 1.22.19
    - npm: 10.2.3
[-] Packages
    - tauri [RUST]: 1.5.4
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.5
    - tauri-cli [RUST]: 1.5.9
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.5.9
[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../out
    - devPath: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Webpack
seeing same here https://github.com/rainlanguage/rain.orderbook/actions/runs/7479976179/job/20358351394?pr=57
note though that this is just ubuntu with nix not nixos
I have the same problem on NixOS:
{
  description = "Nix Development Flake for Taskyon";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };
  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        # this is all tauri-related stuff
        libraries = with pkgs; [
          # tauri deps
          webkitgtk
          gtk3
          cairo
          gdk-pixbuf
          glib
          dbus
          openssl_3
          librsvg
          libsoup
          # this is needed for appimage by build_appimage.sh ...
          libgpg-error 
          xorg.libX11
          xorg.libSM
          xorg.libICE
          xorg.libxcb
          fribidi
          fontconfig
          libthai
          harfbuzz
          freetype
          libglvnd
          mesa
          libdrm
        ];
        packages = with pkgs; [
          rustfmt
          rustc
          cargo
          # for tauri
          curl
          wget
          pkg-config
          # node
          yarn
          nodejs_21
        ];
      in {
        devShells.default = pkgs.mkShell rec {
          name = "xyntopia_gui";
          buildInputs = libraries ++ packages;
          shellHook = ''
            if [ -f ./.env ]; then
              set -a  # automatically export all variables
              source ./.env
              set +a
            fi
            export PATH="$(pwd)/node_modules/.bin:$PATH"
            export LD_LIBRARY_PATH=${
              pkgs.lib.makeLibraryPath libraries
            }:$LD_LIBRARY_PATH
            export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
          '';
        };
      });
}
tauri-info:
[⚠] Environment
    - OS: NixOS 23.11.0 X64
    ✔ webkit2gtk-4.0: 2.42.5
    ✔ rsvg2: 2.57.0
    ✔ rustc: 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)
    ✔ cargo: 1.73.0
    ⚠ rustup: not installed!
      If you have rust installed some other way, we recommend uninstalling it
      then use rustup instead. Visit https://rustup.rs/
    ⚠ Rust toolchain: couldn't be detected!
      Maybe you don't have rustup installed? if so, Visit https://rustup.rs/
    - node: 21.6.2
    - yarn: 1.22.19
    - npm: 10.2.4
[-] Packages
    - tauri [RUST]: 1.1.0
    - tauri-build [RUST]: 1.1.0
    - wry [RUST]: 0.21.1
    - tao [RUST]: 0.14.0
    - @tauri-apps/api [NPM]: 1.5.3
    - @tauri-apps/cli [NPM]: 1.5.10
[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist/spa
    - devPath: http://localhost:8080/
    - framework: Vue.js (Quasar)
    - bundler: Webpack
When running tauri build -v I get:
-- Running input plugin: gtk --
[gtk/stdout] Installing AppRun hook
[gtk/stderr] chmod: cannot access 'taskyon.AppDir/usr/lib64': No such file or directory
[gtk/stdout] Installing GLib schemas
[gtk/stderr] cp: cannot stat '/nix/store/3j4bisnb0bk9vzpfxbcmv4v51pkha8lx-glib-2.78.4/share/glib-2.0/schemas': No such file or directory
ERROR: Failed to run plugin: gtk (exit code: 1)
       Error [tauri_cli_node] failed to bundle project: error running appimage.sh
And the same thing happens, when I use this, basically replacing all rust dependencies with the tauri packages from nixpcks:
{
  description = "Nix Development Flake for Taskyon";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };
  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        # this is all tauri-related stuff
        libraries = with pkgs; [
          cargo-tauri
        ];
        packages = with pkgs; [
          # rust
          rustfmt
          #clippy
          rustc
          cargo
          # for tauri
          curl
          wget
          pkg-config
          # node
          yarn
          nodejs_21
        ];
      in {
        devShells.default = pkgs.mkShell rec {
          name = "xyntopia_gui";
          # TODO: what is this for? nativeBuildInputs = [ pkgs.bashInteractive ];
          buildInputs = libraries ++ packages;
          shellHook = ''
            if [ -f ./.env ]; then
              set -a  # automatically export all variables
              source ./.env
              set +a
            fi
            export PATH="$(pwd)/node_modules/.bin:$PATH"
            export LD_LIBRARY_PATH=${
              pkgs.lib.makeLibraryPath libraries
            }:$LD_LIBRARY_PATH
            export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
          '';
        };
      });
}
ok, I did a little more investigation on this.
so..
this file here:
[gtk/stderr] cp: cannot stat '/nix/store/3j4bisnb0bk9vzpfxbcmv4v51pkha8lx-glib-2.78.4/share/glib-2.0/schemas': No such file or directory
it is part of the "glib.dev" package.. I have added "glib.dev" to my flake.nix but it doesn't not seem to make any difference...
from nix-locate --top-level /share/glib-2.0/schemas:
glib.dev                                              1 d /nix/store/8gkrqg6bx8q4rnhvs7zg6hpqzw870mp7-glib-2.78.4-dev/share/glib-2.0/schemas
this one has a different hash, so probably is there on my system for some other reason :) --> I am not sure, what to do about this from here.
- I don't know how I can check where stuff gets installed from glib.dev in the flake.
- I don't know how to check where tauri gets the directory from where to look for the schemas...
try this package
{
  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";
  version = "0.0.1-dev";
  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";
    homepage = "https://example.com";
    license = with licenses; [ epl20 ];
    mainProgram = "program";
    maintainers = with maintainers; [ ];
  };
}
Hi, I believe I have located something that might be causing this. I was trying to build https://github.com/Martichou/rquickshare, and was running into this error. If you run pnpm build --verbose, you get the following error:
     Running [tauri_bundler::bundle::common] Command `/home/purewater/projects/rquickshare/frontend/src-tauri/target/release/bundle/appimage/build_appimage.sh `
+ export ARCH=x86_64
+ ARCH=x86_64
+ APPIMAGE_BUNDLE_XDG_OPEN=0
+ APPIMAGE_BUNDLE_GSTREAMER=0
+ TRAY_LIBRARY_PATH='/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib -L/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -L/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -L/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib -L/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -L/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib -L/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib -L/nix/store/vw10czhhgqyh0ygwb9kwkqajyqnynqwq-libayatana-appindicator-0.5.92/lib -L/nix/store/dywnqj9gmyy79kdvflc8ywkfwvryvc0k-ayatana-ido-0.10.2/lib -L/nix/store/5ivs7x7ngmlqgc1wk0hhdj7d3q7s60z5-libdbusmenu-gtk3-16.04.0/lib/libayatana-appindicator3.so.1'
+ '[' x86_64 == i686 ']'
+ linuxdeploy_arch=x86_64
+ mkdir -p r-quick-share.AppDir
+ cp -r ../appimage_deb/data/usr r-quick-share.AppDir
+ cd r-quick-share.AppDir
+ mkdir -p usr/bin
+ mkdir -p usr/lib
+ [[ 0 != \0 ]]
+ [[ /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib -L/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -L/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -L/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib -L/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -L/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib -L/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib -L/nix/store/vw10czhhgqyh0ygwb9kwkqajyqnynqwq-libayatana-appindicator-0.5.92/lib -L/nix/store/dywnqj9gmyy79kdvflc8ywkfwvryvc0k-ayatana-ido-0.10.2/lib -L/nix/store/5ivs7x7ngmlqgc1wk0hhdj7d3q7s60z5-libdbusmenu-gtk3-16.04.0/lib/libayatana-appindicator3.so.1 != \0 ]]
+ echo 'Copying appindicator library /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib -L/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -L/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -L/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib -L/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -L/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib -L/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib -L/nix/store/vw10czhhgqyh0ygwb9kwkqajyqnynqwq-libayatana-appindicator-0.5.92/lib -L/nix/store/dywnqj9gmyy79kdvflc8ywkfwvryvc0k-ayatana-ido-0.10.2/lib -L/nix/store/5ivs7x7ngmlqgc1wk0hhdj7d3q7s60z5-libdbusmenu-gtk3-16.04.0/lib/libayatana-appindicator3.so.1'
Copying appindicator library /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib -L/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -L/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -L/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib -L/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -L/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib -L/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib -L/nix/store/vw10czhhgqyh0ygwb9kwkqajyqnynqwq-libayatana-appindicator-0.5.92/lib -L/nix/store/dywnqj9gmyy79kdvflc8ywkfwvryvc0k-ayatana-ido-0.10.2/lib -L/nix/store/5ivs7x7ngmlqgc1wk0hhdj7d3q7s60z5-libdbusmenu-gtk3-16.04.0/lib/libayatana-appindicator3.so.1
+ cp /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib -L/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -L/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -L/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib -L/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -L/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib -L/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib -L/nix/store/vw10czhhgqyh0ygwb9kwkqajyqnynqwq-libayatana-appindicator-0.5.92/lib -L/nix/store/dywnqj9gmyy79kdvflc8ywkfwvryvc0k-ayatana-ido-0.10.2/lib -L/nix/store/5ivs7x7ngmlqgc1wk0hhdj7d3q7s60z5-libdbusmenu-gtk3-16.04.0/lib/libayatana-appindicator3.so.1 usr/lib
cp: invalid option -- '/'
Try 'cp --help' for more information.
       Error [tauri_cli_node] failed to bundle project: error running appimage.sh
 ELIFECYCLE  Command failed with exit code 1.
This looks a lot like the output of pkg-config ayatana-appindicator3-0.1 --libs-only-L, but without the leading -L flag in the first input, leading me to think that there was an assumption that pkg-config would only ever output one value for the path of a library.  Following the breadcrumbs in the code:
This is copy command causing the bug.
This reads from an environment variable TAURI_TRAY_LIBRARY_PATH. This is set here.
The code that sets path(which the env var is set to) always leads to calling [this function]((https://github.com/tauri-apps/tauri/blob/16641723b001b1172d1962e9fa80f5fafbc570f0/tooling/cli/src/interface/rust.rs#L1442), which, as written in the comment, and as evident in the line
let word = output.stdout[2..].to_vec();
does in fact make that assumption that pkg-config only outputs one library, which it does not do on nixos.
I'm not sure how this might need to be fixed, but given that this can happen on any system where there are multiple versions of a package, this should probably be fixed here as opposed to being simply patched in nixpkgs.
The problem occurs during the Tauri application build process when running the build_appimage.sh script as part of the Tauri application build process. Specifically, an error arises in the linuxdeploy-plugin-gtk.sh script, which is fetched and executed as part of the build.
Relevant Script and Line
The problematic script is located at:
project/src-tauri/target/release/bundle/appimage/build_appimage.sh
Within this script, the following line fetches the GTK plugin script from the URL:
wget -q -4 -N "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
The fetched script (linuxdeploy-plugin-gtk.sh) is located at:
https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
This plugin script then attempts to install GLib schemas using the following command:
glib_schemasdir="$(get_pkgconf_variable "schemasdir" "gio-2.0" "/usr/share/glib-2.0/schemas")"
Command Execution
When manually running the corresponding pkg-config command to retrieve the schemasdir variable, the output is as follows:
pkg-config --variable=schemasdir gio-2.0
Expected Output:
/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/share/glib-2.0/schemas
The Issue on NixOS
On NixOS, it appears that the gio-2.0 package references a schemasdir that does not actually exist:
cd /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/share/glib-2.0/schemas
Output:
cd: no such file or directory: /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/share/glib-2.0/schemas
This leads to the failure of the build script (build_appimage.sh) with the following error:
[gtk/stderr] cp: cannot stat '/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/share/glib-2.0/schemas': No such file or directory
ERROR: Failed to run plugin: gtk (exit code: 1)
Conclusion
The issue is that the gio-2.0 package on NixOS is referencing a schemasdir that does not exist, leading to the failure when trying to copy GLib schemas during the AppImage build process.
Next Steps
To address this issue, the following steps are recommended:
- 
Modify the get_pkgconf_variableFunction:Enhance the get_pkgconf_variablefunction in thelinuxdeploy-plugin-gtk.shscript to handle cases whereschemasdiris not present ingio-2.0by adding fallback logic. This logic can check common locations for the GLib schemas directory and ensure that the script can continue even ifgio-2.0does not define theschemasdirvariable correctly.Example Fix (Generated by ChatGPT, after asking it, to fix this on my system, not tested):get_schemas_dir() { # First, try to get the schemasdir using pkg-config for gio-2.0 glib_schemasdir="$(get_pkgconf_variable "schemasdir" "gio-2.0" "")" # If pkg-config didn't return a valid path, check common fallback locations if [ -z "$glib_schemasdir" ] || [ ! -d "$glib_schemasdir" ]; then # Common locations for glib-2.0 schemas fallback_paths=( "/usr/share/glib-2.0/schemas" "/usr/local/share/glib-2.0/schemas" "/opt/local/share/glib-2.0/schemas" "/nix/store/*/share/glib-2.0/schemas" # Nix store path pattern ) for path in "${fallback_paths[@]}"; do if [ -d "$path" ]; then glib_schemasdir="$path" break fi done fi # If no valid path is found, exit with an error if [ -z "$glib_schemasdir" ] || [ ! -d "$glib_schemasdir" ]; then echo "Error: Could not find GLib schemas directory." >&2 exit 1 fi echo "$glib_schemasdir" }
- 
Test the Script: Ensure that the modified script ( linuxdeploy-plugin-gtk.sh) works on NixOS and other distributions, particularly in environments wheregio-2.0may not include theschemasdir.
- 
Consider Upstream Fixes: If this issue is likely to affect other users, consider contributing this fix upstream to the Tauri or linuxdeployproject so that others benefit from improved compatibility with NixOS and similar environments.
ChatGPT helped me out by identifying the cause of the issue. I am currently working on a workaround for NixOS. I don't know how to test the above case—maybe someone with more experience with Tauri can assist?
Hey so me and @getchoo have been working a hook that might fix this.
How to solve building on Nixos (But not Appimages)
Minimal shell.nix
Minimal shell.nix with which i could compile:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    # pkg-config
    # This can't be here
    cairo
    pango.dev
    glib
    gtk3
    libsoup
    webkitgtk
    gobject-introspection
    cmake
    ninja  # Add ninja build system
    rustc  # Add Rust compiler
    cargo  # Add Cargo package manager
    # add other dependencies here
    ## Other Dependencies
    atk
    gdk-pixbuf
    ## Build Dependencies
    fribidi
    harfbuzz
    fontconfig.lib
    freetype
    libgpg-error
    gsettings-desktop-schemas
  ];
  shellHook = ''
    # We clear PKG_CONFIG_PATH and LD_LIBRARY_PATH to create an isolated
    # environment. Thus we can ensure that the build script will work on any
    # system.
    export PKG_CONFIG_PATH=""
    export LD_LIBRARY_PATH=""
    # We add the dependencies to be able to run cargo tauri build
    export PKG_CONFIG_PATH="${pkgs.cairo.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.pango.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.harfbuzz.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.glib.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.gdk-pixbuf.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.atk.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.gtk3.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.libsoup.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export PKG_CONFIG_PATH="${pkgs.webkitgtk.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    # export PKG_CONFIG_PATH="${pkgs.fribidi.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    # These Libraries are for the build script mainly
    export LD_LIBRARY_PATH="${pkgs.fribidi}/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH="${pkgs.harfbuzz}/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH="${pkgs.fontconfig.lib}/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH="${pkgs.freetype}/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH="${pkgs.libgpg-error}/lib:$LD_LIBRARY_PATH"
    # export LD_LIBRARY_PATH="${pkgs.glib.dev}/lib:$LD_LIBRARY_PATH"
    # export GSETTINGS_SCHEMA_DIR="${pkgs.glib.dev}"
    mkdir -p $TMPDIR/pkgconfig
    cp $(pkg-config --variable=pcfiledir gio-2.0)/gio-2.0.pc $TMPDIR/pkgconfig/gio-2.0.pc
    # Replace the schemasdir path
    substituteInPlace $TMPDIR/pkgconfig/gio-2.0.pc \
    --replace 'schemasdir=''${datadir}/glib-2.0/schemas' 'schemasdir=${pkgs.glib.dev}/share/glib-2.0/schemas'
    export PKG_CONFIG_PATH="$TMPDIR/pkgconfig:$PKG_CONFIG_PATH"
  '';
}
Note: I used PKG_CONFIG_PATH and LD_LIBRARY_PATH to fix it. At the time of solving it I understood it, but now i have forgotten again why it worked. I used IBM documentation to understand LD_LIBARY_PATH. ^2
Maybe someone can compress it even more??
Then I got Permission errors.
Permission Error (Warning Dangerous)
I fixed them by using all of the three commands below, but i don't know which one fixed it for me, as chatgpt solved that for me. $ sudo chown -R $(whoami) project $ sudo chown -R 755 project $ sudo chmod -R 1777 /tmp # I don't know if this is actually safe One of them fixed the error of Permission Denied.
Appimages
Then i got an error, that appimage.sh or smth failed.
I am on an laptop with an amd processor and tauri don't seem to support appimages for amd devices. ^1  :
In the file: 
project/src-tauri/tauri.conf.json I replaced "targets": "all" with "targets": ["deb", "nsis", "msi", "app", "dmg", "updater"],
{
 ...
    "bundle": {
    ...
      "targets": "all",
      "targets": ["deb", "nsis", "msi", "app", "dmg", "updater"],
     ...
    }
  }
...
}
Conclusion
I suggest, that the error itself is just in the nix pkg and not in tauri itself. Though it is very unfortunate that tauri doesn't support appimages on amd devices.
@werererer
Then i got an error, that appimage.sh or smth failed. I am on an laptop with an amd processor and tauri don't seem to support appimages for amd devices. 2 : ... Though it is very unfortunate that tauri doesn't support appimages on amd devices.
I see that the wording is quite unlucky but this warning is in the "Compiling apps for ARM targets" section. This warning does only apply if you're building for ARM. Building for x86 on x86 generally works fine (and until fairly recently only this worked, with no way to build for arm even on arm devices).
Then i got an error, that appimage.sh or smth failed.
Try building with --verbose and it will tell you why.
@werererer building always worked well for all of us my flake.nix also works for compiling binaries. The issue is that we can not run Appimage.sh and build an appimage from those binaries. It looks like that's still the same problem for you, correct?
@yeus Yeah, i couldnt get around it.
My time is currently very limited, as I have very strict deadlines ahead.
So I cant do further testing.
in the time being i just disabled appimages.
In Short: That is the exact error I got
@FabianLars Actually with --verbose it fails at wgetting a link leading to linuxdeploy-plugin-gtk.sh
But am currently sitting behind China Firewall, while having issues with my VPN, so I'll be stuck with testing for now
Hey so me and @getchoo have been working a hook that might fix this.
Mention PR: https://github.com/NixOS/nixpkgs/pull/335751
The above PR has been merged. Tauri packages can now be built in nixpkgs via cargo-tauri.hook, which is documented here -- many real world examples can also be searched through here
@getchoo will this also help in building appimages?
The hook itself is meant to only be used to package a Tauri app in Nixpkgs -- though it does use the AppImage bundler to make it easier to implement. If you wish to do this with the tauri v2 CLI manually, try using the dev shell I made here that is based off of the hook. Haven't tested it though, so no promises :p
This will hopefully be better explained in some Nix-specific resources like wiki.nixos.org as well
@getchoo I'm using Tauri v2 and struggling to build the package. The cargo-tauri.hook looks be only compatible with the Tauri v1.
Is there some progress to updating the hook?
I tried to update it myself, without any luck yet. I would be willing to help, but I'm not sure where.
@getchoo I'm using Tauri v2 and struggling to build the package. The
cargo-tauri.hooklooks be only compatible with the Tauri v1.Is there some progress to updating the hook?
I tried to update it myself, without any luck yet. I would be willing to help, but I'm not sure where.
There is a pr that's in progress of updating tauri here: https://github.com/NixOS/nixpkgs/pull/346277
@Eveeifyeve hey, it looks like the linked pr is merged, how do i take advantage of it exactly?
@Eveeifyeve hey, it looks like the linked pr is merged, how do i take advantage of it exactly?
So make a nix derivation for your application and if you don't know how to follow nixpkgs reference manual. But this will build your Tauri app for nix if you are wanting to build an app image outside of nix but still using nix tooling I will have to investigate further when I have my laptop fixed.
But that's saying this pr includes the v2 of Tauri which is available to use. If you are still using v1 please asap migrate to v2 or use cargo-tauri_1 package which won't be supported in 25.05 and on. So my recommendation is upgrade using the migration guide or use the V1 package until the V1 package gets depreciated at 25.05.
@Eveeifyeve i've been using the tauri github action https://github.com/tauri-apps/tauri-action which i thought was the "official" way to build for release
to get that working i'm using nix develop to setup an environment for that action, i don't have nix doing the build entirely itself, and the github action includes things like apple signing of the binary, and moving libs into place outside the nix store so it is compatible on non-nix machines that download the released binary
@Eveeifyeve i've been using the tauri github action https://github.com/tauri-apps/tauri-action which i thought was the "official" way to build for release
In that case that is different as nix requires everything to be build and use from the nix store there is ways to get around it but i forgot i am sure you could look it up
to get that working i'm using
nix developto setup an environment for that action, i don't have nix doing the build entirely itself, and the github action includes things like apple signing of the binary, and moving libs into place outside the nix store so it is compatible on non-nix machines that download the released binary
So in that case you will have to wait for me to investigate because it's not being built with nix way but the general approach to tauri with a nix shell. Not a derivation.
@Eveeifyeve yeah i already have it working in mac, basically after it finishes building i just copy in the relevant dependencies from absolute paths in the nix store to relative paths in the dmg and sign it
the issue for linux is that i don't even get that far, i can't even get tauri to do the build from nix develop as per this issue
so, can anybody provide a working flake?
I have a working flake but I need to work on a pr to upstream it to tauri docs.
The relevant line that, I believe, would fix the issue is here now: https://github.com/tauri-apps/tauri/blob/db03f00693007ac897129ced163113762560ebbe/crates/tauri-cli/src/interface/rust.rs#L1524
If my analysis from earlier was correct, it should work if this supports multiple outputs from pkg-config.