Install program (Teamwire) via installer.sh

Hello everybody!

I am trying to install “Teamwire” on my NixOS machine, which I’m using for work (and evaluating how well that works). I’ve written some simple derivations and have read about autoPatchElfHook (Teamwire has a Debian … installer). Unfortunately, the installer they offer for Debian is not a Debian package, it’s simply a huge shell script. At the top it says

# This script was generated using Makeself 2.4.5

which I am not familiar with.

So, I don’t really know the mechanics of how this script accomplishes an installation on Debian, which makes it hard to work with it. Maybe somebody here has experience with this sort of thing?

Anyway, in the hopes of being somehow able to eventually inspect what happens in the $out dir (if anything), I’ve come up with this

{
  stdenv,
  fetchurl,
  lib,
  ...
}:
stdenv.mkDerivation rec {
  name = "teamwire";

  source = fetchurl {
    url = "https://desktop.teamwire.eu/download.php?platform=linuxDebian";
    hash = "sha256-qFPG0Y1oX7fQKi28YNIvtAPVrhC837OfdMb/KFcmhsU=";
  };

  phases = ["installPhase"];

  installPhase = ''
    mkdir -p $out
    cp ${source} $out/installer.sh
    chmod +x $out/installer.sh
    $out/installer.sh
  '';

  meta = with lib; {
    homepage = "https://teamwire.eu";
    description = "team collaboration software";
    platforms = platforms.linux;
  };
}

which fails with the error

unning phase: installPhase
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing Teamwire  100%  
/nix/store/f3g0020qzlbsddfg7y557ckhp13dvpky-teamwire/installer.sh: eval: line 700: ./Teamwire/setup.sh: not found

which uhm I don’t understand right now.

If somebody

  • understands why this file wouldn’t be there
  • can recommend a better debugging procedure than including this file in my configuration.nix, rebuilding and seeing what happens
  • knows a better way to install stuff that ships as a shell script like this one
  • has a working derivation for Teamwire

I’d be very grateful :slight_smile:

Makeself creates self-extracting archives. See https://makeself.io/

You probably shouldn’t execute the installer since it’s expecting a FHS-compatible Linux distro, which NixOS is not.

NVIDIA uses makeself to package the Linux drivers. The Nix package extracts the .run file manually, instead of executing the script. See nixpkgs/pkgs/os-specific/linux/nvidia-x11/builder.sh at c00d587b1a1afbf200b1d8f0b0e4ba9deb1c7f0e · NixOS/nixpkgs · GitHub

Thanks for the hint. That helped. Though I have found a way to extract the archive using the script in a non-breaking way (instructing it not to do anything else)

This is the current state of the derivation:

{
  stdenv,
  fetchurl,
  lib,
  autoPatchelfHook,
  xorg,
  pango,
  libXrandr,
  mesa,
  libxkbcommon,
  nspr,
  atk,
  dbus,
  gtk3,
  alsa-lib,
  nss,
  musl,
  ...
}:
stdenv.mkDerivation rec {
  name = "teamwire";

  installer = fetchurl {
    url = "https://desktop.teamwire.eu/download.php?platform=linuxDebian";
    hash = "sha256-qFPG0Y1oX7fQKi28YNIvtAPVrhC837OfdMb/KFcmhsU=";
  };

  nativeBuildInputs = [autoPatchelfHook];

  buildInputs = [
    xorg.libXext
    xorg.libXfixes
    xorg.libxshmfence
    stdenv.cc.cc.libgcc
    stdenv.cc.cc.lib
    stdenv.cc.libc.out
    pango
    libXrandr
    mesa
    (lib.getLib libxkbcommon)
    nspr.out
    atk
    dbus.lib
    gtk3
    alsa-lib
    nss
    musl
  ];

  autoPatchelfIgnoreMissingDeps = [
    #"libc.musl-x86_64.so.1"
  ];

  #phases = ["installPhase"];

  #dontUnpack = true; # skip unpack phase
  unpackPhase = ''
    sh ${installer} --noexec --keep --target .
  '';

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    #runHook preInstall
    #cp ${installer} $out/installer.sh
    #chmod +x $out/installer.sh
    #$out/installer.sh --noexec --keep --target $out
    #rm $out/installer.sh

    mkdir -p $out
    cp -r Teamwire/* $out/


    echo "$out/nw $out/app" > $out/teamwire
    find "$out/" -type f -exec chmod 444 {} \;
    find $out/ -type d -exec chmod 555 {} \;
    chmod -f 555 $out/{nw,teamwire,app/ffmpeg,nacl_*}

    #mv /usr/share/Teamwire/teamwire.desktop /usr/share/applications/

    #runHook postInstall
  '';

  meta = with lib; {
    homepage = "https://teamwire.eu";
    description = "team collaboration software";
    platforms = platforms.linux;
  };
}

As far as I can tell, it almost works.

This is the error I get when trying to run the resulting teamwire script:

[131604:131612:0621/010658.246948:FATAL:udev_loader.cc(38)] Check failed: false. 
#0 0x7fd9e5fa05a9 (/nix/store/q7ckyq940hl3ldps8kkfn9bvbrn8njad-teamwire/lib/libnw.so+0x4da05a8)
Task trace:
#0 0x7fd9e3b99ba6 (/nix/store/q7ckyq940hl3ldps8kkfn9bvbrn8njad-teamwire/lib/libnw.so+0x2999ba5)

[131628:131628:0621/010658.306973:ERROR:gl_implementation.cc(394)] Failed to load libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[131628:131628:0621/010658.313583:ERROR:viz_main_impl.cc(160)] Exiting GPU process due to errors during initialization
./teamwire: line 1: 131604 Aborted                 (core dumped) /nix/store/q7ckyq940hl3ldps8kkfn9bvbrn8njad-teamwire/nw /nix/store/q7ckyq940hl3ldps8kkfn9bvbrn8njad-teamwire/app

I believe there is still a library missing?! Why didn’t patchelf catch that?

Another question is this: It has been quite terrible to iteratively take patchelf’s complaints about missing dependencies (*.so) or similar files and figure out which nixpkgs correspond to that. What helped most was simply grepping (well, ripgrepping for speed) the nixpkgs repo, but not everything came up. Finding musl was the biggest challenge :smiley:. Google helped a bit, too. So I wonder if there is a smarter approach to doing this, for non-C people?

Your process is what I’ve done. I don’t know of another way. Regarding the error, add the libGL package to your build inputs. If it still fails with the same error, then the app is likely loading libGL dynamically. In that case, add the runtimeDependencies attribute (which is a list) and add libGL to it. See this: erosanix/pkgs/gossip/default.nix at 5e88489ed290fe8f7e0c6813de12c54ea009acad · emmanuelrosa/erosanix · GitHub

I’ve tried adding libGL to both buildInputs and runtimeDependencies. No change. Since this is a different topic, I’ve created a follow up question here