1{
2 lib,
3 bash,
4 binutils-unwrapped,
5 coreutils,
6 gawk,
7 libarchive,
8 pv,
9 squashfsTools,
10 buildFHSEnv,
11 pkgs,
12}:
13
14rec {
15 appimage-exec = pkgs.replaceVarsWith {
16 src = ./appimage-exec.sh;
17 isExecutable = true;
18 dir = "bin";
19 replacements = {
20 inherit (pkgs) runtimeShell;
21 path = lib.makeBinPath [
22 bash
23 binutils-unwrapped
24 coreutils
25 gawk
26 libarchive
27 pv
28 squashfsTools
29 ];
30 };
31 };
32
33 extract =
34 args@{
35 pname,
36 version,
37 name ? null,
38 postExtract ? "",
39 src,
40 ...
41 }:
42 assert lib.assertMsg (
43 name == null
44 ) "The `name` argument is deprecated. Use `pname` and `version` instead to construct the name.";
45 pkgs.runCommand "${pname}-${version}-extracted"
46 {
47 nativeBuildInputs = [ appimage-exec ];
48 strictDeps = true;
49 }
50 ''
51 appimage-exec.sh -x $out ${src}
52 ${postExtract}
53 '';
54
55 # for compatibility, deprecated
56 extractType1 = extract;
57 extractType2 = extract;
58 wrapType1 = wrapType2;
59
60 wrapAppImage =
61 args@{
62 src,
63 extraPkgs ? pkgs: [ ],
64 meta ? { },
65 ...
66 }:
67 buildFHSEnv (
68 defaultFhsEnvArgs
69 // {
70 targetPkgs = pkgs: [ appimage-exec ] ++ defaultFhsEnvArgs.targetPkgs pkgs ++ extraPkgs pkgs;
71
72 runScript = "appimage-exec.sh -w ${src} --";
73
74 meta = {
75 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
76 }
77 // meta;
78 }
79 // (removeAttrs args (builtins.attrNames (builtins.functionArgs wrapAppImage)))
80 );
81
82 wrapType2 =
83 args@{
84 src,
85 extraPkgs ? pkgs: [ ],
86 ...
87 }:
88 wrapAppImage (
89 args
90 // {
91 inherit extraPkgs;
92 src = extract (
93 lib.filterAttrs (
94 key: value:
95 builtins.elem key [
96 "pname"
97 "version"
98 "src"
99 ]
100 ) args
101 );
102
103 # passthru src to make nix-update work
104 # hack to keep the origin position (unsafeGetAttrPos)
105 passthru =
106 lib.pipe args [
107 lib.attrNames
108 (lib.remove "src")
109 (removeAttrs args)
110 ]
111 // args.passthru or { };
112 }
113 );
114
115 defaultFhsEnvArgs = {
116 # Most of the packages were taken from the Steam chroot
117 targetPkgs =
118 pkgs: with pkgs; [
119 gtk3
120 bashInteractive
121 zenity
122 xorg.xrandr
123 which
124 perl
125 xdg-user-dirs # flutter desktop apps
126 xdg-utils
127 iana-etc
128 krb5
129 gsettings-desktop-schemas
130 hicolor-icon-theme # dont show a gtk warning about hicolor not being installed
131
132 # libraries not on the upstream include list, but nevertheless expected
133 # by at least one appimage
134 libsecret # For bitwarden, appimage is x86_64 only
135 ];
136
137 # list of libraries expected in an appimage environment:
138 # https://github.com/AppImage/pkg2appimage/blob/master/excludelist
139 multiPkgs =
140 pkgs: with pkgs; [
141 desktop-file-utils
142 xorg.libXcomposite
143 xorg.libXtst
144 xorg.libXrandr
145 xorg.libXext
146 xorg.libX11
147 xorg.libXfixes
148 libGL
149
150 gst_all_1.gstreamer
151 gst_all_1.gst-plugins-ugly
152 gst_all_1.gst-plugins-base
153 libdrm
154 xorg.xkeyboardconfig
155 xorg.libpciaccess
156
157 glib
158 bzip2
159 zlib
160 gdk-pixbuf
161
162 xorg.libXinerama
163 xorg.libXdamage
164 xorg.libXcursor
165 xorg.libXrender
166 xorg.libXScrnSaver
167 xorg.libXxf86vm
168 xorg.libXi
169 xorg.libSM
170 xorg.libICE
171 freetype
172 curlWithGnuTls
173 nspr
174 nss
175 fontconfig
176 cairo
177 pango
178 expat
179 dbus
180 cups
181 libcap
182 SDL2
183 libusb1
184 udev
185 dbus-glib
186 atk
187 at-spi2-atk
188 libudev0-shim
189
190 xorg.libXt
191 xorg.libXmu
192 xorg.libxcb
193 xorg.xcbutil
194 xorg.xcbutilwm
195 xorg.xcbutilimage
196 xorg.xcbutilkeysyms
197 xorg.xcbutilrenderutil
198 libGLU
199 libuuid
200 libogg
201 libvorbis
202 SDL2_image
203 glew110
204 openssl
205 libidn
206 tbb
207 wayland
208 libgbm
209 libxkbcommon
210 vulkan-loader
211
212 flac
213 libglut
214 libjpeg
215 libpng12
216 libpulseaudio
217 libsamplerate
218 libmikmod
219 libthai
220 libtheora
221 libtiff
222 pixman
223 speex
224 SDL2_ttf
225 SDL2_mixer
226 libcaca
227 libcanberra
228 libgcrypt
229 libvpx
230 librsvg
231 xorg.libXft
232 libvdpau
233 alsa-lib
234
235 harfbuzz
236 e2fsprogs
237 libgpg-error
238 keyutils.lib
239 libjack2
240 fribidi
241 p11-kit
242
243 gmp
244
245 # libraries not on the upstream include list, but nevertheless expected
246 # by at least one appimage
247 libtool.lib # for Synfigstudio
248 at-spi2-core
249 pciutils # for FreeCAD
250 pipewire # immersed-vr wayland support
251 libmpg123 # Slippi launcher
252 brotli # TwitchDropsMiner
253 ];
254 };
255}