Can't run an AppImage app

So, I’m back again.
I’m trying to run an app that isn’t in the repo, it is distributed as an appimage.
I downloaded appimage-run, but when I try to use it I get a generic “segmentation fault” error:

appimage-run LittleWeeb-0.4.0.303.AppImage
LittleWeeb-0.4.0.303.AppImage installed in /home/suzu/.cache/appimage-run/e76971bc65ab44285776e178b26f7b7872412ee0ec495ff2
04c13cb1fe091a35
Segmentation fault (core dumped)

I looked around, and the closest thing I could find was this bug report, but the first answer said appimage from the unstable repo was OK.
I tried downloading appimage-run from the unstable repo, but I get the same error.

I tried downloading the source code from their Github to try and create a package, but it turns out the app was made in Electron, and I have no knowledge of Electron at all. By what I understood reading other threads, making packages of Electron apps is a bit of a chore, and TBH my head hurt just from reading the example packages.
So, my best option would be trying the appimage. I imagine the problem I’m having to run it is exactly because it’s an Electron app. Is there any trick I must use to make an appimage work on NixOS (technically an appimage was made to be portable and run hassle-free in any distro, but NixOS is full of little surprises).

1 Like

Have you tried using the appimagetools? See Nixpkgs 23.11 manual | Nix & NixOS

1 Like

Hi. Thanks for the tip, I didn’t know about this tool.
By reading it, it seems simple enough to use, but I tried creating a simple .nix function to use it, and it’s not quite giving me the result I expected.

Here’s my function:

{ pkgs ? import < nixpkgs> {}, fetchurl }:
appimageTools.wrapType2 {
name = “LittleWeeb”;
src = fetchurl {
url = “https://github.com/littleweeb/Desktop/releases/download/v0.4.0_linux/LittleWeeb-0.4.0.303.AppImage”;
sha256 = “e76971bc65ab44285776e178b26f7b7872412ee0ec495ff204c13cb1fe091a35”;
};
}

When running it in nix repl, I expected it to either fetch the appimage from github and then trying to wrap it, or for it to give me any other sort of error, but it just returns me a lambda function with fetchurl.

nix-repl> import ./littleweeb.nix
«lambda @ /home/suzu/LittleWeeb/littleweeb.nix:1:1»

So I must be severely misunderstanding how nix functions work.
I’m going through the pills and the manual again to see if I can find where I did mess up.

You got a lambda because you imported a file containing a function. You didn’t call/apply the function.

Try this:

let
  version = "0.4.0";
  buildNumber = "303";
in { pkgs ? import <nixpkgs> {} }:
pkgs.appimageTools.wrapType2 {
  name = "LittleWeeb";
  src = pkgs.fetchurl {
    url = "https://github.com/littleweeb/Desktop/releases/download/v${version}_linux/LittleWeeb-${version}.${buildNumber}.AppImage";
    sha256 = "e76971bc65ab44285776e178b26f7b7872412ee0ec495ff204c13cb1fe091a35";
  };
}

Then build it with nix build -f littleweeb.nix

It will produce a ./results/bin/LittleWeeb script. I didn’t try running it, but it seemed to build fine.

3 Likes

Ah, thanks.
I guess my mistake was trying to run it the same way I saw in the Nix pills, I was supposed to build it. I also noticed I was supposed to call the fetchurl within the pkgs.

It really did build fine, but I can’t run it. Actually I can, it doesn’t give me any errors, but nothing happens.
I tried running it with -d to see where it stopped, and this is the output:

./LittleWeeb -d
+ getopts x:w:dh option
+ shift 3
+ '[' -n true ']'
+ '[' -d /nix/store/lkw1g55l2fsglznw6669433zp0x86ca3-LittleWeeb-extracted ']'
+ wrap
+ cd /nix/store/lkw1g55l2fsglznw6669433zp0x86ca3-LittleWeeb-extracted
+ export APPIMAGE_SILENT_INSTALL=1
+ APPIMAGE_SILENT_INSTALL=1
+ '[' -n '' ']'
+ exec ./AppRun

So, by what I understand, the script manages to extract the appimage and wrap it, but in the actual “running” nothing happens. And I believe this has something to do with Electron.
So, the “magic” to make this AppImage to work with NixOS didn’t really work. The source code is available, so I guess I’ll take a look at how to create a derivation of an Electron app again.

Thanks for the help.

I checked the binaries in /nix/store/lkw1g55l2fsglznw6669433zp0x86ca3-LittleWeeb-extracted with ldd and some of them are missing linked libraries. Also, the AppRun script is expecting one of several dialong programs, such as zenity, so that’s another missing dependency. Not to mention there are various assertions being made by AppRun which can cause it to exit silently.

Despite all of that, I think you’re quite close to something usable. If you start with a derivation to build an Electron app you’ll probably find yourself no where near this close.

I encourage you to search Nixpkgs for uses of appimageTools, to get a sense of what you would need to do to get this appimage working.

Yeah, last night I tried to go the “wrapping an electron app” route, and really didn’t get any close to where I was with the appimage. It seems the app uses a different structure than the electron apps that were packaged before, and so I’d need to either patch the app or make many changes in the packaging script and, as I said, I’m not knowledgeable in Electron at all (TBH, I also barely know anything about Nix expressions). I think I’ll go back to trying with the appimageTools.
As I said yesterday, looking at the wiki the tools look very simple and without many options, but I bet there’s a lot of stuff underneath that I’m able to change and configure when doing the wrapping, so I guess it’s time to RTFM.

Thanks for the help.

@emmanuelrosa I’m actually curious, do you have more information on why AppRun is quiet when failing? I’d love to see some errors, it’s very rare to see no error at all… And since electron app are quite common, wouldn’t it make sense to put required dependencies into appimage-run?

When I glanced at the AppRun script, I noticed various assertions (if-then blocks) which in exited without displaying any error. So if any of those assertions are triggered the app would just exit silently. I don’t know why it’s done that way.

I think the main problem stems from AppImage itself. Here’s a quote from their documentation where it describes how to put together an AppDir structure:

Of course you can leave out the library if your app does not need one, or if all libraries your app needs are already contained in every base operating system you are targeting.

This implies that an AppImage does not need to include all of it’s dependencies, and instead can rely on some undefined dependencies to be provided by the operating system. Contrary to what may be expected, there’s no way an AppImage can be expected to work on every Linux-based OS.

Perhaps a way to improve the NixOS appimage tooling is to determine which dependencies are commmonly not included in appimages because developers expect them to be provided by the operating system, and include those by default.

Thank you for the explanations. I’m also wondering if electron requires fuse in the sandbox scenario. It could explain also the failure since fuse does not work in bubblewrap.

I guess a first step is to display meaningful errors in appimage-run, add more common libraries, and check if electron sandboxed app can work out of the box or not.

FTR, there’s a package called appimage-run, and it works for me.

found at: AppImage(s) on NixOS (doesn't work) · Issue #472 · AppImage/AppImageKit · GitHub

@attila.lendvai Have you tried with the LittleWeeb appimage? In that case appimage-run it’s not working.

sorry, i wasn’t clear. appimage-run works for me with FreeTube, but i haven’t tried anything else.