You typically get this error when the dynamic loader cannot be found. There are several options: package the game and use e.g. autoPatchelfHook, patch the binary manually, or run the binary in a FHS environment. For the former two, see:
The simplest is to try steam-run ./robo_instructus as already mentioned here but there are other solutions in the thread that might interest you as well
So I’m able to run the binary! Now I’d like to write a default.nix for it. I tried to adapt the given one, but the unpacking phase fails:
with import <nixpkgs> { };
stdenv.mkDerivation rec {
buildInputs = [ pkgs.unzip ];
name = "robo-instructus-demo";
version = "1.0";
src = [ ./robo-instructus-linux-demo.zip ];
sourceRoot = ".";
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/{bin,lib}
mv robo-instructus $out/bin/
mv lib/* $out/lib/
'';
preFixup = let
libPath = lib.makeLibraryPath [
pkgs.alsaLib
pkgs.glibc
pkgs.xlibs.libxcb
pkgs.xlibs.libX11
pkgs.xlibs.libXcursor
pkgs.xlibs.libXi
pkgs.xlibs.libXrandr
pkgs.libglvnd
# FIXME:
#
# Somehow also include the path to the lib directory of the current
# derivation's output path.
];
in ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath}" \
$out/bin/robo-instructus
'';
meta = with stdenv.lib; {
homepage = "https://code-industry.net/masterpdfeditor/";
description = "A programming game";
# FIXME: build fails if we set this to unfree, although in
# /etc/nixos/configuration.nix I have:
#
# nixpkgs.config.allowUnfree = true;
#
# license = licenses.unfree;
platforms = platforms.linux;
maintainers = [ "little-dude" ];
};
}
The error:
[nix-shell:~/robo-instructus-demo/test]$ ls
default.nix robo-instructus-linux-demo.zip
[nix-shell:~/robo-instructus-demo/test]$ nix-build
these derivations will be built:
/nix/store/sd4gw8ai7jh257yara3sj8k4m27978s3-robo-instructus-demo.drv
building '/nix/store/sd4gw8ai7jh257yara3sj8k4m27978s3-robo-instructus-demo.drv'...
unpacking sources
unpacking source archive /nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip
[/nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of /nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip or
/nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip.zip, and cannot find /nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip.ZIP, period.
do not know how to unpack source archive /nix/store/mlf7jja8ns59hm7rwj611pjkxjppvagv-robo-instructus-linux-demo.zip
builder for '/nix/store/sd4gw8ai7jh257yara3sj8k4m27978s3-robo-instructus-demo.drv' failed with exit code 1
error: build of '/nix/store/sd4gw8ai7jh257yara3sj8k4m27978s3-robo-instructus-demo.drv' failed