···1+# pkgs.appimageTools {#sec-pkgs-appimageTools}
2+3+`pkgs.appimageTools` is a set of functions for extracting and wrapping [AppImage](https://appimage.org/) files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, `pkgs.appimage-run` can be used as well.
4+5+::: warning
6+The `appimageTools` API is unstable and may be subject to backwards-incompatible changes in the future.
7+:::
8+9+## AppImage formats {#ssec-pkgs-appimageTools-formats}
10+11+There are different formats for AppImages, see [the specification](https://github.com/AppImage/AppImageSpec/blob/74ad9ca2f94bf864a4a0dac1f369dd4f00bd1c28/draft.md#image-format) for details.
12+13+- Type 1 images are ISO 9660 files that are also ELF executables.
14+- Type 2 images are ELF executables with an appended filesystem.
15+16+They can be told apart with `file -k`:
17+18+```ShellSession
19+$ file -k type1.AppImage
20+type1.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) ISO 9660 CD-ROM filesystem data 'AppImage' (Lepton 3.x), scale 0-0,
21+spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=d629f6099d2344ad82818172add1d38c5e11bc6d, stripped\012- data
22+23+$ file -k type2.AppImage
24+type2.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) (Lepton 3.x), scale 232-60668, spot sensor temperature -4.187500, color scheme 15, show scale bar, calibration: offset -0.000000, slope 0.000000 (Lepton 2.x), scale 4111-45000, spot sensor temperature 412442.250000, color scheme 3, minimum point enabled, calibration: offset -75402534979642766821519867692934234112.000000, slope 5815371847733706829839455140374904832.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=79dcc4e55a61c293c5e19edbd8d65b202842579f, stripped\012- data
25+```
26+27+Note how the type 1 AppImage is described as an `ISO 9660 CD-ROM filesystem`, and the type 2 AppImage is not.
28+29+## Wrapping {#ssec-pkgs-appimageTools-wrapping}
30+31+Depending on the type of AppImage you're wrapping, you'll have to use `wrapType1` or `wrapType2`.
32+33+```nix
34+appimageTools.wrapType2 { # or wrapType1
35+ name = "patchwork";
36+ src = fetchurl {
37+ url = "https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage";
38+ sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s";
39+ };
40+ extraPkgs = pkgs: with pkgs; [ ];
41+}
42+```
43+44+- `name` specifies the name of the resulting image.
45+- `src` specifies the AppImage file to extract.
46+- `extraPkgs` allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs:
47+ - Looking through the extracted AppImage files, reading its scripts and running `patchelf` and `ldd` on its executables. This can also be done in `appimage-run`, by setting `APPIMAGE_DEBUG_EXEC=bash`.
48+ - Running `strace -vfefile` on the wrapped executable, looking for libraries that can't be found.
-102
doc/builders/images/appimagetools.xml
···1-<section xmlns="http://docbook.org/ns/docbook"
2- xmlns:xlink="http://www.w3.org/1999/xlink"
3- xmlns:xi="http://www.w3.org/2001/XInclude"
4- xml:id="sec-pkgs-appimageTools">
5- <title>pkgs.appimageTools</title>
6-7- <para>
8- <varname>pkgs.appimageTools</varname> is a set of functions for extracting and wrapping <link xlink:href="https://appimage.org/">AppImage</link> files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, <literal>pkgs.appimage-run</literal> can be used as well.
9- </para>
10-11- <warning>
12- <para>
13- The <varname>appimageTools</varname> API is unstable and may be subject to backwards-incompatible changes in the future.
14- </para>
15- </warning>
16-17- <section xml:id="ssec-pkgs-appimageTools-formats">
18- <title>AppImage formats</title>
19-20- <para>
21- There are different formats for AppImages, see <link xlink:href="https://github.com/AppImage/AppImageSpec/blob/74ad9ca2f94bf864a4a0dac1f369dd4f00bd1c28/draft.md#image-format">the specification</link> for details.
22- </para>
23-24- <itemizedlist>
25- <listitem>
26- <para>
27- Type 1 images are ISO 9660 files that are also ELF executables.
28- </para>
29- </listitem>
30- <listitem>
31- <para>
32- Type 2 images are ELF executables with an appended filesystem.
33- </para>
34- </listitem>
35- </itemizedlist>
36-37- <para>
38- They can be told apart with <command>file -k</command>:
39- </para>
40-41-<screen>
42-<prompt>$ </prompt>file -k type1.AppImage
43-type1.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) ISO 9660 CD-ROM filesystem data 'AppImage' (Lepton 3.x), scale 0-0,
44-spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=d629f6099d2344ad82818172add1d38c5e11bc6d, stripped\012- data
45-46-<prompt>$ </prompt>file -k type2.AppImage
47-type2.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) (Lepton 3.x), scale 232-60668, spot sensor temperature -4.187500, color scheme 15, show scale bar, calibration: offset -0.000000, slope 0.000000 (Lepton 2.x), scale 4111-45000, spot sensor temperature 412442.250000, color scheme 3, minimum point enabled, calibration: offset -75402534979642766821519867692934234112.000000, slope 5815371847733706829839455140374904832.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=79dcc4e55a61c293c5e19edbd8d65b202842579f, stripped\012- data
48-</screen>
49-50- <para>
51- Note how the type 1 AppImage is described as an <literal>ISO 9660 CD-ROM filesystem</literal>, and the type 2 AppImage is not.
52- </para>
53- </section>
54-55- <section xml:id="ssec-pkgs-appimageTools-wrapping">
56- <title>Wrapping</title>
57-58- <para>
59- Depending on the type of AppImage you're wrapping, you'll have to use <varname>wrapType1</varname> or <varname>wrapType2</varname>.
60- </para>
61-62-<programlisting>
63-appimageTools.wrapType2 { # or wrapType1
64- name = "patchwork"; <co xml:id='ex-appimageTools-wrapping-1' />
65- src = fetchurl { <co xml:id='ex-appimageTools-wrapping-2' />
66- url = "https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage";
67- sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s";
68- };
69- extraPkgs = pkgs: with pkgs; [ ]; <co xml:id='ex-appimageTools-wrapping-3' />
70-}</programlisting>
71-72- <calloutlist>
73- <callout arearefs='ex-appimageTools-wrapping-1'>
74- <para>
75- <varname>name</varname> specifies the name of the resulting image.
76- </para>
77- </callout>
78- <callout arearefs='ex-appimageTools-wrapping-2'>
79- <para>
80- <varname>src</varname> specifies the AppImage file to extract.
81- </para>
82- </callout>
83- <callout arearefs='ex-appimageTools-wrapping-3'>
84- <para>
85- <varname>extraPkgs</varname> allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs:
86- <itemizedlist>
87- <listitem>
88- <para>
89- Looking through the extracted AppImage files, reading its scripts and running <command>patchelf</command> and <command>ldd</command> on its executables. This can also be done in <command>appimage-run</command>, by setting <command>APPIMAGE_DEBUG_EXEC=bash</command>.
90- </para>
91- </listitem>
92- <listitem>
93- <para>
94- Running <command>strace -vfefile</command> on the wrapped executable, looking for libraries that can't be found.
95- </para>
96- </listitem>
97- </itemizedlist>
98- </para>
99- </callout>
100- </calloutlist>
101- </section>
102-</section>
···1+# pkgs.snapTools {#sec-pkgs-snapTools}
2+3+`pkgs.snapTools` is a set of functions for creating Snapcraft images. Snap and Snapcraft is not used to perform these operations.
4+5+## The makeSnap Function {#ssec-pkgs-snapTools-makeSnap-signature}
6+7+`makeSnap` takes a single named argument, `meta`. This argument mirrors [the upstream `snap.yaml` format](https://docs.snapcraft.io/snap-format) exactly.
8+9+The `base` should not be specified, as `makeSnap` will force set it.
10+11+Currently, `makeSnap` does not support creating GUI stubs.
12+13+## Build a Hello World Snap {#ssec-pkgs-snapTools-build-a-snap-hello}
14+15+The following expression packages GNU Hello as a Snapcraft snap.
16+17+```{#ex-snapTools-buildSnap-hello .nix}
18+let
19+ inherit (import <nixpkgs> { }) snapTools hello;
20+in snapTools.makeSnap {
21+ meta = {
22+ name = "hello";
23+ summary = hello.meta.description;
24+ description = hello.meta.longDescription;
25+ architectures = [ "amd64" ];
26+ confinement = "strict";
27+ apps.hello.command = "${hello}/bin/hello";
28+ };
29+}
30+```
31+32+`nix-build` this expression and install it with `snap install ./result --dangerous`. `hello` will now be the Snapcraft version of the package.
33+34+## Build a Graphical Snap {#ssec-pkgs-snapTools-build-a-snap-firefox}
35+36+Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package.
37+38+```{#ex-snapTools-buildSnap-firefox .nix}
39+let
40+ inherit (import <nixpkgs> { }) snapTools firefox;
41+in snapTools.makeSnap {
42+ meta = {
43+ name = "nix-example-firefox";
44+ summary = firefox.meta.description;
45+ architectures = [ "amd64" ];
46+ apps.nix-example-firefox = {
47+ command = "${firefox}/bin/firefox";
48+ plugs = [
49+ "pulseaudio"
50+ "camera"
51+ "browser-support"
52+ "avahi-observe"
53+ "cups-control"
54+ "desktop"
55+ "desktop-legacy"
56+ "gsettings"
57+ "home"
58+ "network"
59+ "mount-observe"
60+ "removable-media"
61+ "x11"
62+ ];
63+ };
64+ confinement = "strict";
65+ };
66+}
67+```
68+69+`nix-build` this expression and install it with `snap install ./result --dangerous`. `nix-example-firefox` will now be the Snapcraft version of the Firefox package.
70+71+The specific meaning behind plugs can be looked up in the [Snapcraft interface documentation](https://docs.snapcraft.io/supported-interfaces).
-59
doc/builders/images/snaptools.xml
···1-<section xmlns="http://docbook.org/ns/docbook"
2- xmlns:xlink="http://www.w3.org/1999/xlink"
3- xmlns:xi="http://www.w3.org/2001/XInclude"
4- xml:id="sec-pkgs-snapTools">
5- <title>pkgs.snapTools</title>
6-7- <para>
8- <varname>pkgs.snapTools</varname> is a set of functions for creating Snapcraft images. Snap and Snapcraft is not used to perform these operations.
9- </para>
10-11- <section xml:id="ssec-pkgs-snapTools-makeSnap-signature">
12- <title>The makeSnap Function</title>
13-14- <para>
15- <function>makeSnap</function> takes a single named argument, <parameter>meta</parameter>. This argument mirrors <link xlink:href="https://docs.snapcraft.io/snap-format">the upstream <filename>snap.yaml</filename> format</link> exactly.
16- </para>
17-18- <para>
19- The <parameter>base</parameter> should not be specified, as <function>makeSnap</function> will force set it.
20- </para>
21-22- <para>
23- Currently, <function>makeSnap</function> does not support creating GUI stubs.
24- </para>
25- </section>
26-27- <section xml:id="ssec-pkgs-snapTools-build-a-snap-hello">
28- <title>Build a Hello World Snap</title>
29-30- <example xml:id="ex-snapTools-buildSnap-hello">
31- <title>Making a Hello World Snap</title>
32- <para>
33- The following expression packages GNU Hello as a Snapcraft snap.
34- </para>
35-<programlisting><xi:include href="./snap/example-hello.nix" parse="text" /></programlisting>
36- <para>
37- <command>nix-build</command> this expression and install it with <command>snap install ./result --dangerous</command>. <command>hello</command> will now be the Snapcraft version of the package.
38- </para>
39- </example>
40- </section>
41-42- <section xml:id="ssec-pkgs-snapTools-build-a-snap-firefox">
43- <title>Build a Hello World Snap</title>
44-45- <example xml:id="ex-snapTools-buildSnap-firefox">
46- <title>Making a Graphical Snap</title>
47- <para>
48- Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package.
49- </para>
50-<programlisting><xi:include href="./snap/example-firefox.nix" parse="text" /></programlisting>
51- <para>
52- <command>nix-build</command> this expression and install it with <command>snap install ./result --dangerous</command>. <command>nix-example-firefox</command> will now be the Snapcraft version of the Firefox package.
53- </para>
54- <para>
55- The specific meaning behind plugs can be looked up in the <link xlink:href="https://docs.snapcraft.io/supported-interfaces">Snapcraft interface documentation</link>.
56- </para>
57- </example>
58- </section>
59-</section>
···110 buildPath = "out/${buildType}";
111 libExecPath = "$out/libexec/${packageName}";
112000000113 chromiumVersionAtLeast = min-version:
114- versionAtLeast upstream-info.version min-version;
0115 versionRange = min-version: upto-version:
116 let inherit (upstream-info) version;
117 result = versionAtLeast version min-version && versionOlder version upto-version;
118- ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version;
119- in if versionAtLeast ungoogled-version upto-version
120- then warn "chromium: ungoogled version ${ungoogled-version} is newer than a patchset bounded at ${upto-version}. You can safely delete it."
121- result
122- else result;
123124 ungoogler = ungoogled-chromium {
125 inherit (upstream-info.deps.ungoogled-patches) rev sha256;
···162 patches = [
163 ./patches/no-build-timestamps.patch # Optional patch to use SOURCE_DATE_EPOCH in compute_build_timestamp.py (should be upstreamed)
164 ./patches/widevine-79.patch # For bundling Widevine (DRM), might be replaceable via bundle_widevine_cdm=true in gnFlags
165- # ++ optional (versionRange "68" "72") (githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000")
166- ] ++ optional (versionRange "89" "90.0.4402.0") (githubPatch
167- # To fix the build of chromiumBeta and chromiumDev:
168- "b5b80df7dafba8cafa4c6c0ba2153dfda467dfc9" # add dependency on opus in webcodecs
169- "1r4wmwaxz5xbffmj5wspv2xj8s32j9p6jnwimjmalqg3al2ba64x"
170- ) ++ optional (versionRange "89" "90.0.4422.0") (fetchpatch {
171- url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/61b0ab526d2aa3c62fa20bb756461ca9a482f6c6/trunk/chromium-fix-libva-redef.patch";
172- sha256 = "1qj4sn1ngz0p1l1w3346kanr1sqlr3xdzk1f1i86lqa45mhv77ny";
173- }) ++ optional (chromiumVersionAtLeast "90")
174 ./patches/fix-missing-atspi2-dependency.patch
175- ++ optionals (chromiumVersionAtLeast "91") [
176 ./patches/closure_compiler-Use-the-Java-binary-from-the-system.patch
177 ];
178···285 } // optionalAttrs pulseSupport {
286 use_pulseaudio = true;
287 link_pulseaudio = true;
288- } // optionalAttrs (chromiumVersionAtLeast "89") {
289- rtc_pipewire_version = "0.3"; # TODO: Can be removed once ungoogled-chromium is at M90
290 # Disable PGO (defaults to 2 since M89) because it fails without additional changes:
291 # error: Could not read profile ../../chrome/build/pgo_profiles/chrome-linux-master-1610647094-405a32bcf15e5a84949640f99f84a5b9f61e2f2e.profdata: Unsupported instrumentation profile format version
292 chrome_pgo_phase = 0;
293- } // optionalAttrs (chromiumVersionAtLeast "90") {
294 # Disable build with TFLite library because it fails without additional changes:
295 # ninja: error: '../../chrome/test/data/simple_test.tflite', needed by 'test_data/simple_test.tflite', missing and no known rule to make it
296 # Note: chrome/test/data/simple_test.tflite is in the Git repository but not in chromium-90.0.4400.8.tar.xz
···110 buildPath = "out/${buildType}";
111 libExecPath = "$out/libexec/${packageName}";
112113+ warnObsoleteVersionConditional = min-version: result:
114+ let ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version;
115+ in if versionAtLeast ungoogled-version min-version
116+ then warn "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it."
117+ result
118+ else result;
119 chromiumVersionAtLeast = min-version:
120+ let result = versionAtLeast upstream-info.version min-version;
121+ in warnObsoleteVersionConditional min-version result;
122 versionRange = min-version: upto-version:
123 let inherit (upstream-info) version;
124 result = versionAtLeast version min-version && versionOlder version upto-version;
125+ in warnObsoleteVersionConditional upto-version result;
0000126127 ungoogler = ungoogled-chromium {
128 inherit (upstream-info.deps.ungoogled-patches) rev sha256;
···165 patches = [
166 ./patches/no-build-timestamps.patch # Optional patch to use SOURCE_DATE_EPOCH in compute_build_timestamp.py (should be upstreamed)
167 ./patches/widevine-79.patch # For bundling Widevine (DRM), might be replaceable via bundle_widevine_cdm=true in gnFlags
168+ # Fix the build by adding a missing dependency (s. https://crbug.com/1197837):
00000000169 ./patches/fix-missing-atspi2-dependency.patch
170+ ] ++ optionals (chromiumVersionAtLeast "91") [
171 ./patches/closure_compiler-Use-the-Java-binary-from-the-system.patch
172 ];
173···280 } // optionalAttrs pulseSupport {
281 use_pulseaudio = true;
282 link_pulseaudio = true;
00283 # Disable PGO (defaults to 2 since M89) because it fails without additional changes:
284 # error: Could not read profile ../../chrome/build/pgo_profiles/chrome-linux-master-1610647094-405a32bcf15e5a84949640f99f84a5b9f61e2f2e.profdata: Unsupported instrumentation profile format version
285 chrome_pgo_phase = 0;
0286 # Disable build with TFLite library because it fails without additional changes:
287 # ninja: error: '../../chrome/test/data/simple_test.tflite', needed by 'test_data/simple_test.tflite', missing and no known rule to make it
288 # Note: chrome/test/data/simple_test.tflite is in the Git repository but not in chromium-90.0.4400.8.tar.xz
···62 "-DBUILD_TESTING:BOOL=${if doCheck then "TRUE" else "FALSE"}"
63 ] ++ lib.optional doCheck "-DCMAKE_PREFIX_PATH=${gtest.dev}/lib/cmake";
6465- doCheck = true;
06667 checkPhase = ''
68 # Skip CMakeFiles directory and tests depending on fuse (does not work well with sandboxing)
···62 "-DBUILD_TESTING:BOOL=${if doCheck then "TRUE" else "FALSE"}"
63 ] ++ lib.optional doCheck "-DCMAKE_PREFIX_PATH=${gtest.dev}/lib/cmake";
6465+ # macFUSE needs to be installed for the test to succeed on Darwin
66+ doCheck = !stdenv.isDarwin;
6768 checkPhase = ''
69 # Skip CMakeFiles directory and tests depending on fuse (does not work well with sandboxing)