2020-03-03 00:40:57 +00:00
|
|
|
{ stdenv, libarchive, radare2, jq, buildFHSUserEnv, squashfsTools, writeScript }:
|
2019-01-27 13:02:50 +00:00
|
|
|
|
|
|
|
rec {
|
|
|
|
|
2020-03-03 23:46:00 +00:00
|
|
|
extract = { name, src }: stdenv.mkDerivation {
|
2019-01-27 13:02:50 +00:00
|
|
|
name = "${name}-extracted";
|
|
|
|
inherit src;
|
2020-03-03 23:46:00 +00:00
|
|
|
nativeBuildInputs = [ radare2 libarchive jq squashfsTools ];
|
2019-01-27 13:02:50 +00:00
|
|
|
buildCommand = ''
|
2020-03-03 23:46:00 +00:00
|
|
|
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
|
2020-03-04 04:40:19 +00:00
|
|
|
eval $(r2 $src -nn -Nqc "p8j 3 @ 8" |
|
|
|
|
jq -r '{appimageSignature: (.[:-1]|implode), appimageType: .[-1]}|
|
|
|
|
@sh "appimageSignature=\(.appimageSignature) appimageType=\(.appimageType)"')
|
|
|
|
|
|
|
|
# check AppImage signature
|
2020-03-04 14:10:11 +00:00
|
|
|
if [[ "$appimageSignature" != "AI" ]]; then
|
2020-03-04 04:40:19 +00:00
|
|
|
echo "Not an appimage."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-03-03 23:46:00 +00:00
|
|
|
case "$appimageType" in
|
2020-03-04 04:40:19 +00:00
|
|
|
1)
|
2020-03-03 23:46:00 +00:00
|
|
|
mkdir $out
|
2020-03-04 04:40:19 +00:00
|
|
|
bsdtar -x -C $out -f $src
|
|
|
|
;;
|
2019-01-27 13:02:50 +00:00
|
|
|
|
2020-03-04 04:40:19 +00:00
|
|
|
2)
|
2020-03-03 23:46:00 +00:00
|
|
|
# multiarch offset one-liner using same method as AppImage
|
|
|
|
# see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93
|
2020-03-04 14:10:11 +00:00
|
|
|
offset=$(r2 $src -nn -Nqc "pfj.elf_header @ 0" |\
|
2020-03-03 23:46:00 +00:00
|
|
|
jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)')
|
2019-01-27 13:02:50 +00:00
|
|
|
|
2020-03-04 14:10:11 +00:00
|
|
|
unsquashfs -q -d $out -o $offset $src
|
|
|
|
chmod go-w $out
|
2020-03-04 04:40:19 +00:00
|
|
|
;;
|
2019-01-27 13:02:50 +00:00
|
|
|
|
2020-03-04 04:40:19 +00:00
|
|
|
# 3) get ready, https://github.com/TheAssassin/type3-runtime
|
|
|
|
*) echo "Unsupported AppImage Type: $appimageType";;
|
2020-03-03 23:46:00 +00:00
|
|
|
esac
|
2019-01-27 13:02:50 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-03-03 23:46:00 +00:00
|
|
|
extractType1 = extract;
|
|
|
|
extractType2 = extract;
|
|
|
|
|
2019-02-13 04:31:35 +00:00
|
|
|
wrapAppImage = args@{ name, src, extraPkgs, ... }: buildFHSUserEnv (defaultFhsEnvArgs // {
|
2019-01-27 13:02:50 +00:00
|
|
|
inherit name;
|
|
|
|
|
|
|
|
targetPkgs = pkgs: defaultFhsEnvArgs.targetPkgs pkgs ++ extraPkgs pkgs;
|
|
|
|
|
|
|
|
runScript = writeScript "run" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
|
|
|
|
export APPDIR=${src}
|
|
|
|
export APPIMAGE_SILENT_INSTALL=1
|
|
|
|
cd $APPDIR
|
|
|
|
exec ./AppRun "$@"
|
|
|
|
'';
|
2019-02-24 00:08:38 +00:00
|
|
|
} // (removeAttrs args (builtins.attrNames (builtins.functionArgs wrapAppImage))));
|
2019-01-27 13:02:50 +00:00
|
|
|
|
2019-02-13 04:31:35 +00:00
|
|
|
wrapType1 = args@{ name, src, extraPkgs ? pkgs: [], ... }: wrapAppImage (args // {
|
2019-04-28 15:41:31 +01:00
|
|
|
inherit name extraPkgs;
|
2019-01-27 13:02:50 +00:00
|
|
|
src = extractType1 { inherit name src; };
|
2019-02-13 04:31:35 +00:00
|
|
|
});
|
2019-01-27 13:02:50 +00:00
|
|
|
|
2019-02-13 04:31:35 +00:00
|
|
|
wrapType2 = args@{ name, src, extraPkgs ? pkgs: [], ... }: wrapAppImage (args // {
|
2019-04-28 15:41:31 +01:00
|
|
|
inherit name extraPkgs;
|
2019-01-27 13:02:50 +00:00
|
|
|
src = extractType2 { inherit name src; };
|
2019-02-13 04:31:35 +00:00
|
|
|
});
|
2019-01-27 13:02:50 +00:00
|
|
|
|
|
|
|
defaultFhsEnvArgs = {
|
|
|
|
name = "appimage-env";
|
|
|
|
|
|
|
|
# Most of the packages were taken from the Steam chroot
|
|
|
|
targetPkgs = pkgs: with pkgs; [
|
|
|
|
gtk3
|
|
|
|
bashInteractive
|
|
|
|
gnome3.zenity
|
|
|
|
python2
|
|
|
|
xorg.xrandr
|
|
|
|
which
|
|
|
|
perl
|
|
|
|
xdg_utils
|
|
|
|
iana-etc
|
|
|
|
krb5
|
|
|
|
];
|
|
|
|
|
2019-03-09 21:03:26 +00:00
|
|
|
# list of libraries expected in an appimage environment:
|
|
|
|
# https://github.com/AppImage/pkg2appimage/blob/master/excludelist
|
2019-01-27 13:02:50 +00:00
|
|
|
multiPkgs = pkgs: with pkgs; [
|
|
|
|
desktop-file-utils
|
|
|
|
xorg.libXcomposite
|
|
|
|
xorg.libXtst
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXfixes
|
|
|
|
libGL
|
|
|
|
|
|
|
|
gst_all_1.gstreamer
|
|
|
|
gst_all_1.gst-plugins-ugly
|
|
|
|
libdrm
|
|
|
|
xorg.xkeyboardconfig
|
|
|
|
xorg.libpciaccess
|
|
|
|
|
|
|
|
glib
|
|
|
|
gtk2
|
|
|
|
bzip2
|
|
|
|
zlib
|
2019-05-22 12:03:39 +01:00
|
|
|
gdk-pixbuf
|
2019-01-27 13:02:50 +00:00
|
|
|
|
|
|
|
xorg.libXinerama
|
|
|
|
xorg.libXdamage
|
|
|
|
xorg.libXcursor
|
|
|
|
xorg.libXrender
|
|
|
|
xorg.libXScrnSaver
|
|
|
|
xorg.libXxf86vm
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libSM
|
|
|
|
xorg.libICE
|
|
|
|
gnome2.GConf
|
|
|
|
freetype
|
|
|
|
(curl.override { gnutlsSupport = true; sslSupport = false; })
|
|
|
|
nspr
|
|
|
|
nss
|
|
|
|
fontconfig
|
|
|
|
cairo
|
|
|
|
pango
|
|
|
|
expat
|
|
|
|
dbus
|
|
|
|
cups
|
|
|
|
libcap
|
|
|
|
SDL2
|
|
|
|
libusb1
|
|
|
|
udev
|
|
|
|
dbus-glib
|
|
|
|
libav
|
|
|
|
atk
|
|
|
|
at-spi2-atk
|
|
|
|
libudev0-shim
|
|
|
|
networkmanager098
|
|
|
|
|
|
|
|
xorg.libXt
|
|
|
|
xorg.libXmu
|
|
|
|
xorg.libxcb
|
2019-04-21 19:10:31 +01:00
|
|
|
xorg.xcbutil
|
|
|
|
xorg.xcbutilwm
|
|
|
|
xorg.xcbutilimage
|
|
|
|
xorg.xcbutilkeysyms
|
|
|
|
xorg.xcbutilrenderutil
|
2019-01-27 13:02:50 +00:00
|
|
|
libGLU
|
|
|
|
libuuid
|
|
|
|
libogg
|
|
|
|
libvorbis
|
|
|
|
SDL
|
|
|
|
SDL2_image
|
|
|
|
glew110
|
|
|
|
openssl
|
|
|
|
libidn
|
|
|
|
tbb
|
|
|
|
wayland
|
2019-05-28 20:09:34 +01:00
|
|
|
mesa
|
2019-01-27 13:02:50 +00:00
|
|
|
libxkbcommon
|
|
|
|
|
|
|
|
flac
|
|
|
|
freeglut
|
|
|
|
libjpeg
|
|
|
|
libpng12
|
|
|
|
libsamplerate
|
|
|
|
libmikmod
|
|
|
|
libtheora
|
|
|
|
libtiff
|
|
|
|
pixman
|
|
|
|
speex
|
|
|
|
SDL_image
|
|
|
|
SDL_ttf
|
|
|
|
SDL_mixer
|
|
|
|
SDL2_ttf
|
|
|
|
SDL2_mixer
|
|
|
|
gstreamer
|
|
|
|
gst-plugins-base
|
|
|
|
libappindicator-gtk2
|
|
|
|
libcaca
|
|
|
|
libcanberra
|
|
|
|
libgcrypt
|
|
|
|
libvpx
|
|
|
|
librsvg
|
|
|
|
xorg.libXft
|
|
|
|
libvdpau
|
|
|
|
alsaLib
|
2019-03-09 21:03:26 +00:00
|
|
|
|
|
|
|
harfbuzz
|
|
|
|
e2fsprogs
|
|
|
|
libgpgerror
|
|
|
|
keyutils.lib
|
|
|
|
libjack2
|
|
|
|
fribidi
|
2019-11-23 20:28:01 +00:00
|
|
|
p11-kit
|
2019-04-20 11:28:45 +01:00
|
|
|
|
|
|
|
# libraries not on the upstream include list, but nevertheless expected
|
|
|
|
# by at least one appimage
|
|
|
|
libtool.lib # for Synfigstudio
|
2019-09-16 01:33:15 +01:00
|
|
|
at-spi2-core
|
2019-01-27 13:02:50 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|