Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / flatpak / default.nix
blob0c44b99db8d9b02999d61738be311576bccf1c87
1 { lib, stdenv
2 , fetchurl
3 , autoreconfHook
4 , docbook_xml_dtd_45
5 , docbook-xsl-nons
6 , which
7 , libxml2
8 , gobject-introspection
9 , gtk-doc
10 , intltool
11 , libxslt
12 , pkg-config
13 , xmlto
14 , substituteAll
15 , runCommand
16 , bison
17 , xdg-dbus-proxy
18 , p11-kit
19 , appstream
20 , bubblewrap
21 , bzip2
22 , curl
23 , dbus
24 , glib
25 , gpgme
26 , json-glib
27 , libarchive
28 , libcap
29 , libseccomp
30 , coreutils
31 , socat
32 , gettext
33 , hicolor-icon-theme
34 , shared-mime-info
35 , desktop-file-utils
36 , gtk3
37 , fuse3
38 , nixosTests
39 , xz
40 , zstd
41 , ostree
42 , polkit
43 , python3
44 , systemd
45 , xorg
46 , valgrind
47 , glib-networking
48 , wrapGAppsNoGuiHook
49 , dconf
50 , gsettings-desktop-schemas
51 , librsvg
52 , makeWrapper
55 stdenv.mkDerivation (finalAttrs: {
56   pname = "flatpak";
57   version = "1.14.4";
59   # TODO: split out lib once we figure out what to do with triggerdir
60   outputs = [ "out" "dev" "man" "doc" "devdoc" "installedTests" ];
62   src = fetchurl {
63     url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz";
64     sha256 = "sha256-ijTb0LZ8Q051mLmOxpCVPQRvDbJuSArq+0bXKuxxZ5k="; # Taken from https://github.com/flatpak/flatpak/releases/
65   };
67   patches = [
68     # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
69     # https://github.com/flatpak/flatpak/issues/1460
70     (substituteAll {
71       src = ./fix-test-paths.patch;
72       inherit coreutils gettext socat gtk3;
73       smi = shared-mime-info;
74       dfu = desktop-file-utils;
75       hicolorIconTheme = hicolor-icon-theme;
76     })
78     # Hardcode paths used by Flatpak itself.
79     (substituteAll {
80       src = ./fix-paths.patch;
81       p11kit = "${p11-kit.bin}/bin/p11-kit";
82     })
84     # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
85     # Patch taken from gtk-doc expression.
86     ./respect-xml-catalog-files-var.patch
88     # Nix environment hacks should not leak into the apps.
89     # https://github.com/NixOS/nixpkgs/issues/53441
90     ./unset-env-vars.patch
92     # Use flatpak from PATH to avoid references to `/nix/store` in `/desktop` files.
93     # Applications containing `DBusActivatable` entries should be able to find the flatpak binary.
94     # https://github.com/NixOS/nixpkgs/issues/138956
95     ./binary-path.patch
97     # The icon validator needs to access the gdk-pixbuf loaders in the Nix store
98     # and cannot bind FHS paths since those are not available on NixOS.
99     finalAttrs.passthru.icon-validator-patch
100   ];
102   nativeBuildInputs = [
103     autoreconfHook
104     libxml2
105     docbook_xml_dtd_45
106     docbook-xsl-nons
107     which
108     gobject-introspection
109     gtk-doc
110     intltool
111     libxslt
112     pkg-config
113     xmlto
114     bison
115     wrapGAppsNoGuiHook
116   ];
118   buildInputs = [
119     appstream
120     bubblewrap
121     bzip2
122     curl
123     dbus
124     dconf
125     gpgme
126     json-glib
127     libarchive
128     libcap
129     libseccomp
130     xz
131     zstd
132     polkit
133     python3
134     systemd
135     xorg.libXau
136     fuse3
137     gsettings-desktop-schemas
138     glib-networking
139     librsvg # for flatpak-validate-icon
140   ];
142   # Required by flatpak.pc
143   propagatedBuildInputs = [
144     glib
145     ostree
146   ];
148   nativeCheckInputs = [
149     valgrind
150   ];
152   # TODO: some issues with temporary files
153   doCheck = false;
155   NIX_LDFLAGS = "-lpthread";
157   enableParallelBuilding = true;
159   configureFlags = [
160     "--with-curl"
161     "--with-system-bubblewrap=${bubblewrap}/bin/bwrap"
162     "--with-system-dbus-proxy=${xdg-dbus-proxy}/bin/xdg-dbus-proxy"
163     "--with-dbus-config-dir=${placeholder "out"}/share/dbus-1/system.d"
164     "--localstatedir=/var"
165     "--enable-gtk-doc"
166     "--enable-installed-tests"
167   ];
169   makeFlags = [
170     "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
171     "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
172   ];
174   postPatch = let
175     vsc-py = python3.withPackages (pp: [
176       pp.pyparsing
177     ]);
178   in ''
179     patchShebangs buildutil
180     patchShebangs tests
181     PATH=${lib.makeBinPath [vsc-py]}:$PATH patchShebangs --build subprojects/variant-schema-compiler/variant-schema-compiler
182   '';
184   passthru = {
185     icon-validator-patch = substituteAll {
186       src = ./fix-icon-validation.patch;
187       inherit (builtins) storeDir;
188     };
190     tests = {
191       installedTests = nixosTests.installed-tests.flatpak;
193       validate-icon = runCommand "test-icon-validation" { } ''
194         ${finalAttrs.finalPackage}/libexec/flatpak-validate-icon --sandbox 512 512 ${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out"
195         grep format=svg "$out"
196       '';
197     };
198   };
200   meta = with lib; {
201     description = "Linux application sandboxing and distribution framework";
202     homepage = "https://flatpak.org/";
203     license = licenses.lgpl21Plus;
204     maintainers = with maintainers; [ ];
205     platforms = platforms.linux;
206   };