Convert appimage to nixos package

Hello!!!

For a couple of day, I start to “play“ with my nixos config. That’s fun when you use debian daily.

Software install is comfortable, easy and efficient.

I tried to convert an appimage working fine with appimage-run. I read https://wiki.nixos.org/wiki/Appimage and several wiki but still don’t understand where I should put this piece of :face_with_symbols_on_mouth: code in my config.

If you got a process or wiki that explains to newbies. You’re welcome. Or the page in the user manual… or just clue….

Thanks a lot!

2 Likes

I assume you mean the appimageTools.wrapType2 block? I’d just replace the URL, hash, and meta, put it in pkgs/<package-name>.nix, and use (pkgs.callPackage ./pkgs/<package-name>.nix { }) in environment.systemPackages. Out of curiosity, what app do you need this appimage for?

1 Like

Thanks for your reply.

Scenari opale for multisupport document a great tool for multi support ressources.

and use (pkgs.callPackage ./pkgs/.nix { }) in environment.systemPackages

I’ll try …

Thanks !!

1 Like

Great ! That’s a part of solution. Now I need to find how to create a .desktop created by the script software usually. The build failed because .desktop does’nt exist. But I can start the app by the terminal. That’s a great jump! Thanks!

1 Like

Looks like you’ll want to:

  1. Make appimageContents equal appimageTools.extractType2 { inherit pname version src; }; in the let block.
  2. Replace extraInstallCommands with this:
install -m 444 -D "${appimageContents}/opale25.desktop" "$out/share/applications/opale25.desktop"
substituteInPlace $out/share/applications/opale25.desktop \
  --replace-fail 'Exec=AppRun' 'Exec=opale'

Also you should know about the --keep-failed option to nix-build and nix build. It’s helpful for debugging stuff like this.

My working derivation
{
  lib,
  appimageTools,
  fetchurl,
}:

let
  version = "25.1.2";
  pname = "opale";

  src = fetchurl {
    url = "https://download.scenari.software/Opale@25.1.2/Opale25_en-US.AppImage";
    hash = "sha256-byB0eegSz5GpmD59IGok3U4RelHF5Q6Zuw4PBadxOgQ=";
  };

  appimageContents = appimageTools.extractType2 { inherit pname version src; };
in
appimageTools.wrapType2 rec {
  inherit pname version src;

  extraInstallCommands = ''
    install -m 444 -D "${appimageContents}/opale25.desktop" "$out/share/applications/opale25.desktop"
    substituteInPlace $out/share/applications/opale25.desktop \
      --replace-fail 'Exec=AppRun' 'Exec=opale'
  '';
}

I use –show-trace but I just start and need learn the”useful” options :slight_smile:

Now the build works properly! I got a white icon instead of opale icon but I’ll try to find.

I think I need to read and learn deeply :joy:

1 Like

Just made a symbolic link.

cd Desktop/
ln -s /user/Appimage-Directory/File.Appimage DeskyopNameYouWant

Looks like you want to do something with symlinking/copying ${appimageContents}/usr/share/icons to $out inextraInstallCommands.

From a quick github code search (Also something useful to know if you want to use nix, very helpful to see how others do things):

--show-trace is almost always useless and just hides the actual issue under a few thousand lines of repetitive traces; I would recommend forgetting that flag exists.

I think I recall about two times the issue was actually hidden in traces instead of plainly obvious in the normal output over the last 10 years.

Thanks for your help!!!

Finally, works fine!!

After logout and login my account…

I think I should spend couple of hours to increase my knowledge on Nixos.

the code…

{ 
 lib, 
 appimageTools, 
 fetchurl, 
}: 

let 
 version = "25.1.2";
 pname = "opale25";

 src = fetchurl {
   url = "https://download.scenari.software/Opale@25.1.2/Opale25_en-US.AppImage";
   hash = "sha256-byB0eegSz5GpmD59IGok3U4RelHF5Q6Zuw4PBadxOgQ=";
 }; 

 appimageContents = appimageTools.extractType2 { inherit pname version src; };
in 
appimageTools.wrapType2 rec { 
 extraInstallCommands = ''
 inherit pname version src; 

   install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications 
   cp -r ${appimageContents}/usr/share/icons $out/share 
   substituteInPlace $out/share/applications/opale25.desktop \ 
     --replace-fail 'Exec=AppRun' 'Exec=${pname}' 
 ''; 
}
1 Like

Unfortunately non-trivial module system errors are usually hidden and require it, but yes, it’s better to avoid by default unless you know the trimmed log is missing crucial info.

2 Likes