Open flosse opened 2 years ago
You need to use patchelf or use the hook, or nix-ld to patch linuxdeploy-x86_64.AppImage
I'll try to fix your shell file when I get time this weekend.
That script will also fail to get the libraries, which... why is it getting them from the host system in the first place? o.O
The script should also have set -e
and explicitly choose where to allow errors
Maybe #4457 fixes this? Please try it tomorrow when we release 1.0.1.
Probably not. But feel free to ping me and I'll try again
some findings:
The No such file or directory
is probably the binary trying to point to the standard FHS location for the dynamic linker.
I honestly think a bigger issue here is just wget
ting and executing stuff off the internet. At the very least it should download a specific version and match it against a known good hash (taking a page out of Nix itself: derivations either know the hash of their output or are barred from accessing the internet).
I wonder if something along the lines of https://blog.mediocregopher.com/posts/building-appimages-with-nix could packaged in a nice way for nix. Something like a "build tauri project" derivation.
I'm not knowledgeable enough in nix to write this but I think it should be doable.
Just a note, gnome.webkitgtk
was removed in favor of pkgs.webkitgtk
@miniBill This is definitely possible. All you need is a derivation (or a function to create a derivation) to do what you want (build tauri project), then get that derivation into the nixpkgs repository through a pull request. It would then be available for everyone's use.
Since the transition to flakes, this isn't even necessary, just have a flake somewhere with the derivations that you want (git repo). These can be included in any other flake.
I'm pretty new to tauri, but cargo tauri build
doesn't seem to be an availabe command. I was able to get the application to build with cargo build
though, as well as through npm run tauri dev
Unless this is about building the main repo, haven't tried that yet.
Just built from the dev branch without any errors. Again, no cargo tauri build
command was available, so I just did cargo build
.
cargo tauri build
is only a thing after installing the tauri cli via cargo install tauri-cli
, similar to the nom package.
I see, well I can confirm that cargo tauri build
fails on NixOS
Just took a look at build_appimage.sh
. It seems entirely incompatible with the way nix does things in terms of packaging (nix will block all calls to wget, as well as any reference to absolute paths).
That being said, it is possible to get cargo tauri build
to work within a nix shell
, or a call to nix run
with only a few modifications. One thing I am confused about is this line (one right before the last line in build_appimage.sh
)
dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="/home/myuser/.cache/tauri/linuxdeploy-${ARCH}.AppImage"
Which seems to modify the ELF header magic bits so that the appImage can not be identified as an appImage. (why do this?) Removing this line seems to have no detrimental effect as far as I can tell.
adding appimage-run
to the final line of build_appimage.sh
almost works, except it can't find the gtk plugin.
@IllustratedMan-code See https://github.com/tauri-apps/tauri/pull/4457 for the elf header stuff.
Interesting, well I'm stumped then. I don't think there is a way to fix this issue without a major rewrite to build_appimage.sh
or some fancy nix stuff that's beyond me for the moment.
appimage-run
requires the correct elf header, so I would have to reverse the effects of #4457 to make it work at all.
It might be possible to sidestep this problem and do it through a nix derivation, maybe using something like https://github.com/matthewbauer/nix-bundle . This would start to get a bit nix-specific though and would probably need its own section of the documentation. This might end up looking like nix build .#appimage
in practice.
It might be possible to replicate the effects of appimage-run
for this specific use case as well. I'm not really sure how appimage-run
works, but the sources are here if anyone wants to take a crack at it.
https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/package-management/appimage-run/default.nix
https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/appimage/appimage-exec.sh
Seems like you could also just run cargo tauri build
in a docker container (which you could probably build with nix if you wanted), not the cleanest workaround but might be the easiest to implement.
@IllustratedMan-code thank you for taking the time to look into that I agree that for now a nix-built docker container seems the simplest path
In my case, I don't need to build an appimage, so I can work around this issue by configuring the targets. i.e.,
// Can't build appimage: https://github.com/tauri-apps/tauri/issues/3323
"targets": ["deb", "msi", "app", "dmg", "updater"]
Obviously this is not helpful if you do want an appimage, but just wanted to share in case anyone else is in a similar situation.
Here I have a package that may help when building tauri into a drv:
{
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; [ ];
};
}
Describe the bug
The
build_appimage.sh
script invoked bycargo tauri build
fails to run on NixOS because thelinuxdeploy-x86_64.AppImage
always tells meNo such file or directory
. In contrast, the exact same project with the same version of tauri can be build successfully on Ubuntu.Reproduction
shell.nix
file in the project root and runnix-shell
cargo tauri build
Expected behavior
No response
Platform and versions
Stack trace
Additional context
No response