Help with a derivation/package

I have been trying to add Jebtrains Toolbox as a package to Nix and here is my copy-pasta attempt https://github.com/amanjeev/nixpkgs/blob/amanjeev/jetbrains-toolbox/pkgs/applications/editors/jetbrains/toolbox/default.nix

The issue I am facing is that it installs ok (using nix-env -f . -iA jetbrains-toolbox);
but running jetbrains-toolbox gives error

dlopen(): error loading libfuse.so.2

AppImages require FUSE to run. 
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information

When I add fuse as a dependency then it gives error

This doesn't look like a squashfs image.

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information
open dir error: No such file or directory

Any help on what I am doing wrong will be great! Thank you!

So far, I have found this answer on SO linux - Running jetbrains-toolbox in NixOS - Stack Overflow

This installs fine (see my setup https://github.com/amanjeev/somenix/tree/primary/nixos/jetbrains) but running the binary gives this error

16:55:12 ? jetbrains-toolbox --version                                                                       ~/somenix
This doesn't look like a squashfs image.

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information
open dir error: No such file or directory

So, I went down the AppImage hell hole and still no luck. I tried both ways

  1. Extracting the binary from the AppImage
  2. Wrapping AppImage by this method linux - Running jetbrains-toolbox in NixOS - Stack Overflow

In case 1: the following command outputs nothing so my assumption is that it finds all the needed SOs

ldd jetbrains-toolbox | grep 'not found'  

I tried with this stupid little thing

with import <nixpkgs> {};

stdenv.mkDerivation rec {
  name = "jetbrains-toolbox";
  buildInputs = [ makeWrapper ];
  buildPhase = "true";
  libPath = lib.makeLibraryPath (with xlibs; [ libcef libX11 libxcb xcbutilkeysyms libXrandr ]);
  unpackPhase = "true";
  installPhase = ''
    mkdir -p $out/bin
    cp ${./jetbrains-toolbox/jetbrains-toolbox} $out/bin/jetbrains-toolbox
  '';
  postFixup = ''
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}" \
      $out/bin/jetbrains-toolbox
  '';
}

but it segfaults

strace ./result/bin/jetbrains-toolbox                                                                                                                                                                                      ~/somenix
execve("./result/bin/jetbrains-toolbox", ["./result/bin/jetbrains-toolbox"], 0x7ffd6f4092c0 /* 74 vars */) = -1 EPERM (Operation not permitted)
+++ killed by SIGSEGV +++
zsh: segmentation fault (core dumped)  strace ./result/bin/jetbrains-toolbox

sigh

Have you tried using buildFHSUserEnv?

Here’s the documentation: Nixpkgs 23.11 manual | Nix & NixOS

Thank you for your response. I really appreciate it.

  1. No I had not tried it but it seems like something that would create an environment? How do you incorporate this nix-shell env script into, say installation?

  2. I tried this script and ran nix-shell

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
  name = "jetbrains-toolbox";
  targetPkgs = pkgs: (with pkgs;
    [ udev
      alsaLib
      fuse
      libcef
      zlib
    ]) ++ (with pkgs.xorg;
    [  
      libX11
      libxcb
      xcbutilkeysyms
      libXrandr 
    ]);
  multiPkgs = pkgs: (with pkgs;
    [ udev
      alsaLib
    ]);
  runScript = "/path/to/jetbrains-toolbox/appimage";
}).env

But the output is still not helpful

these derivations will be built:
  /nix/store/v3zr6m2yxjn1a9jips24lwpr50q6ywv0-jetbrains-toolbox-usr-target.drv
  /nix/store/q9i2fk0fmgng3c932128afbxrvy3r9bx-jetbrains-toolbox-fhs.drv
  /nix/store/46sxd26nfk4vmrai4zxqfv6p1mzay5nd-jetbrains-toolbox-init.drv
building '/nix/store/v3zr6m2yxjn1a9jips24lwpr50q6ywv0-jetbrains-toolbox-usr-target.drv'...
collision between `/nix/store/5hvxigc4xr8lir3kyfy6lcmlhvbs9y7i-glibc-multi-2.31-74/lib/locale/locale-archive' and `/nix/store/23xygjg9rwqa6jbcrrmlv3xz6qlg5kcj-glibc-locales-2.31-74/lib/locale/locale-archive'
collision between `/nix/store/g490crrmig6ffbjk5qxd5siavypng6ld-gcc-9.3.0-lib/lib64/libgcc_s.so.1' and `/nix/store/5hvxigc4xr8lir3kyfy6lcmlhvbs9y7i-glibc-multi-2.31-74/lib64/libgcc_s.so.1'
collision between `/nix/store/g490crrmig6ffbjk5qxd5siavypng6ld-gcc-9.3.0-lib/lib64/libgcc_s.so' and `/nix/store/5hvxigc4xr8lir3kyfy6lcmlhvbs9y7i-glibc-multi-2.31-74/lib64/libgcc_s.so'
collision between `/nix/store/g490crrmig6ffbjk5qxd5siavypng6ld-gcc-9.3.0-lib/lib/libgcc_s.so.1' and `/nix/store/5hvxigc4xr8lir3kyfy6lcmlhvbs9y7i-glibc-multi-2.31-74/lib/libgcc_s.so.1'
collision between `/nix/store/g490crrmig6ffbjk5qxd5siavypng6ld-gcc-9.3.0-lib/lib/libgcc_s.so' and `/nix/store/5hvxigc4xr8lir3kyfy6lcmlhvbs9y7i-glibc-multi-2.31-74/lib/libgcc_s.so'
Use of uninitialized value in string eq at /nix/store/xd7n3la4g3zn7xmm4mfdjfzgm18s84dn-builder.pl line 133.
collision between `/nix/store/4mmqm21fdr7514067snjsaii7jn82pap-shadow-4.8.1/etc/pam.d' and `/nix/store/dib72bxvjk4kpbhnjjc4lajdjwad078v-jetbrains-toolbox-chrootenv-etc/etc/pam.d'
Use of uninitialized value in string eq at /nix/store/xd7n3la4g3zn7xmm4mfdjfzgm18s84dn-builder.pl line 133.
collision between `/nix/store/4mmqm21fdr7514067snjsaii7jn82pap-shadow-4.8.1/etc/login.defs' and `/nix/store/dib72bxvjk4kpbhnjjc4lajdjwad078v-jetbrains-toolbox-chrootenv-etc/etc/login.defs'
Use of uninitialized value in string eq at /nix/store/xd7n3la4g3zn7xmm4mfdjfzgm18s84dn-builder.pl line 133.
created 5472 symlinks in user environment
building '/nix/store/q9i2fk0fmgng3c932128afbxrvy3r9bx-jetbrains-toolbox-fhs.drv'...
building '/nix/store/46sxd26nfk4vmrai4zxqfv6p1mzay5nd-jetbrains-toolbox-init.drv'...
fusermount: /nix/store/v6l2sacryfr88yqq0pq7sia8wfgm9q31-wrapper.c:203: main: Assertion `!(st.st_mode & S_ISUID) || (st.st_uid == geteuid())' failed.

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information
open dir error: No such file or directory

Edit:
All I find is something like this NixOS setuid wrapper prevent running sudo in user namespace · Issue #42117 · NixOS/nixpkgs · GitHub

It looks like you’re trying to use the appImage. I believe the appImage support in NixOS uses buildFHSUserEnv under the hood, so in a sense you’ve already been there done that.

Try it with the tarball download instead. The Sidequest package (pkgs/applications/misc/sidequest/default.nix) uses buildFHSUserEnv, for example.

Thank you. I tried to copy sidequest here jetbrains-toolbox-package.nix · GitHub

This does not seem to work either.

$ nix-build jetbrains-toolbox-package.nix
..
/nix/store/3whcs2ivibnws8jzdk7irwxidj2flrjf-jetbrains-toolbox

Running

$ ./result/bin/jetbrains-toolbox                                                                                                                                                             ~/proj/nix-nixos/trials/jetbrains-toolbox
This doesn't look like a squashfs image.

Cannot mount AppImage, please check your FUSE setup.
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information
open dir error: No such file or directory

Hello :wave: ,

@amanjeev did you happen to figure out how to install it? I’m looking to install Jetbrains Toolbox as well! Thanks for creating this thread!

not really. I just could not figure out and ended up just using direct installs. I would love to do this but if you figure this out please let me know.

Finally, I figured out how to run it jetbrains-toolbox: init at 1.27.2.13801 by AnatolyPopov · Pull Request #206288 · NixOS/nixpkgs · GitHub

1 Like

oooo thank you so much! subscribed to the PR!

Thanks for the PR ! I just reviewed it :slight_smile:

Feel free to test the upcoming jetbrains-toolbox package by doing:

NIXPKGS_ALLOW_UNFREE=1 nix run "github:drupol/nixpkgs/init/jetbrains-toolbox-init#jetbrains-toolbox" --impure

Please report back any issue in the corresponding pull request, it will help.

1 Like

jetbrains-toolbox is now in Nix !

2 Likes

Thank you very much for getting the package into nixpkgs!
Did you have luck using a tool installed by the jetbrains-toolbox? For example when I use clion, the git client called inside the app seg faults for me… The GitHub Copilot plugin works tho.