Hello folks. Second post to the discourse and still really enjoying NixOS overall. There’s one application that I use for work that has FHS requirements and hasn’t been overly friendly on NixOS called Splashtop Remote Access.
I was able to get the application working using nix-alien though it seems like I should also be able to make it work declaratively by writing a derivation and although I’m linking in the same dependencies that work when run under nix-alien, it’s encountering a problem with libavcodec.so
.
Here’s the default.nix file that nix-alien generated with the exception that I manually added ffmpeg in the targetPkgs, since nix-alien didn’t find this automatically and caused things to crash. It’s my understanding that ffmpeg provides libavcodec.so
.
cat ~/.cache/nix-alien/6e43d9ad-dcb5-55e4-8e7f-43bbb4bdae7e/fhs-env/default.nix
{ pkgs ? import
(builtins.fetchTarball {
name = "nixpkgs-unstable-20240410231924";
url = "https://github.com/NixOS/nixpkgs/archive/1042fd8b148a9105f3c0aca3a6177fd1d9360ba5.tar.gz";
sha256 = "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=";
})
{ }
}:
let
inherit (pkgs) buildFHSUserEnv;
in
buildFHSUserEnv {
name = "splashtop-business-fhs";
targetPkgs = p: with p; [
keyutils.lib
libcap.lib
libgcc.lib
libsForQt5.qt5.qtbase.out
libuuid.lib
pulseaudio.out
xdotool.out
xorg.libxcb.out
xorg.xcbutil.out
xorg.xcbutilkeysyms.out
zlib.out
ffmpeg
];
runScript = "/home/User/Downloads/splashtop/opt/splashtop-business/splashtop-business";
}
With that in mind, I began on my derivation. I know it can be improved to download the tarball from Splashtop but for development purposes, I have a copy of it downloaded locally.
cat default.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./derivation.nix {}
cat derivation.nix
{ stdenv, lib, dpkg, autoPatchelfHook, pkgs }:
let
# Please keep the version x.y.0.z and do not update to x.y.76.z because the
# source of the latter disappears much faster.
version = "3.6.4.1";
src = ./splashtop-business_Ubuntu_amd64.deb;
in stdenv.mkDerivation {
name = "splashtop-business-linux-${version}";
system = "x86_64-linux";
inherit src;
# Required for compilation
nativeBuildInputs = [
autoPatchelfHook # Automatically setup the loader, and do the magic
dpkg
];
# Required at running time
buildInputs = with pkgs; [
keyutils.lib
libcap.lib
libgcc.lib
libsForQt5.qt5.qtbase.out
libuuid.lib
pulseaudio.out
xdotool.out
xorg.libxcb.out
xorg.xcbutil.out
xorg.xcbutilkeysyms.out
zlib.out
ffmpeg
];
unpackPhase = "true";
# Extract and copy executable in $out/bin
installPhase = ''
mkdir -p $out
dpkg -x $src $out
cp -av $out/opt/splashtop-business/* $out
rm -rf $out/opt
ln -s /tmp $out/log
'';
meta = with lib; {
description = "Splashtop Business for Linux";
homepage = "https://support-splashtopbusiness.splashtop.com/hc/en-us/articles/4404715685147-Download-Splashtop-Business-app-for-Linux";
license = licenses.mit;
maintainers = with lib.maintainers; [ ];
platforms = [ "x86_64-linux" ];
};
}
When I run the application, I am able to do most things but crashes when trying to render a remote desktop (presumably because of ffmpeg). This is an excerpt of the logs the program writes to the console during my testing that I see before the crash occurs.
[04/23/24 17:41:07] [STB.I]:[StartStreaming] Start streaming...
[04/23/24 17:41:07] [STB.I]:[Init] MediaPlayer Init
[04/23/24 17:41:07] [STB.I]:[operator()] tlv handle thread start
[04/23/24 17:41:07] [STB.I]:[operator()] Consume video data thread start
[04/23/24 17:41:07] [STB.I]:[operator()] Consume audio data thread start
[04/23/24 17:41:07] [STB.I]:[RecvAudioSampleFormat] RecvAudioSampleFormat
[04/23/24 17:41:07] [STB.I]:[InitAudioPlayer] InitAudioPlayer
[04/23/24 17:41:07] [STB.I]:[AudioPlayer] AudioPlayer created
[04/23/24 17:41:07] [STB.I]:[Init] AudioPlayer::Init
[04/23/24 17:41:07] [STB.I]:[Init] AudioDecoderCelt init success sample_rate: 48000, frame_size: 960
[04/23/24 17:41:07] [STB.I]:[InitVideoPlayer] InitVideoPlayer
[04/23/24 17:41:07] [STB.I]:[VideoPlayer] VideoPlayer created
[04/23/24 17:41:07] [STB.I]:[Init] VideoPlayer::Init
[04/23/24 17:41:07] [STB.I]:[Init] VideoDecoderFfmpeg init
terminate called after throwing an instance of 'std::runtime_error'
what(): libavcodec.so: cannot open shared object file: No such file or directory
Failed to write crash dump
Aborted (core dumped)
Given that it works through nix-alien, this is more about learning and simplifying things on a go forward basis. Thanks!