summary refs log tree commit diff
path: root/pkgs/tools/package-management/appimage-run/default.nix
blob: a7fb8da9966994f906aa41b6a261fde94689cf15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{ stdenv, writeScript, buildFHSUserEnv, coreutils
, extraPkgs ? pkgs: [] }:

buildFHSUserEnv {
  name = "appimage-run";

  # 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
  ] ++ extraPkgs pkgs;

  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
    gdk_pixbuf

    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
    libudev0-shim
    networkmanager098

    xorg.libXt
    xorg.libXmu
    xorg.libxcb
    libGLU
    libuuid
    libogg
    libvorbis
    SDL
    SDL2_image
    glew110
    openssl
    libidn
    tbb
    wayland
    mesa_noglu
    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
    strace
  ];

  runScript = writeScript "appimage-exec" ''
    #!${stdenv.shell}
    APPIMAGE="$(realpath "$1")"

    if [ ! -x "$APPIMAGE" ]; then
      echo "fatal: $APPIMAGE is not executable"
      exit 1
    fi

    SHA256="$(${coreutils}/bin/sha256sum "$APPIMAGE" | cut -d ' ' -f 1)"
    SQUASHFS_ROOT="''${XDG_CACHE_HOME:-$HOME/.cache}/appimage-run/$SHA256/"
    mkdir -p "$SQUASHFS_ROOT"

    export APPDIR="$SQUASHFS_ROOT/squashfs-root"
    if [ ! -x "$APPDIR" ]; then
      cd "$SQUASHFS_ROOT"
      "$APPIMAGE" --appimage-extract 2>/dev/null
    fi

    cd "$APPDIR"
    export PATH="$PATH:$PWD/usr/bin"
    export APPIMAGE_SILENT_INSTALL=1

    if [ -n "$APPIMAGE_DEBUG_EXEC" ]; then
      exec "$APPIMAGE_DEBUG_EXEC"
    fi

    exec ./AppRun
  '';
}