Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / fl / flatpak / package.nix
blob226ea755e184b6c4aadca0180c38c56bc0e0e2f8
2   lib,
3   stdenv,
4   fetchurl,
5   runCommand,
6   appstream,
7   autoreconfHook,
8   bison,
9   bubblewrap,
10   bzip2,
11   coreutils,
12   curl,
13   dbus,
14   dconf,
15   desktop-file-utils,
16   docbook_xml_dtd_45,
17   docbook-xsl-nons,
18   fuse3,
19   gettext,
20   glib,
21   glib-networking,
22   gobject-introspection,
23   gpgme,
24   gsettings-desktop-schemas,
25   gtk3,
26   gtk-doc,
27   hicolor-icon-theme,
28   intltool,
29   json-glib,
30   libarchive,
31   libcap,
32   librsvg,
33   libseccomp,
34   libxml2,
35   libxslt,
36   nix-update-script,
37   nixosTests,
38   nixos-icons,
39   ostree,
40   p11-kit,
41   pkg-config,
42   polkit,
43   python3,
44   shared-mime-info,
45   socat,
46   substituteAll,
47   systemd,
48   testers,
49   valgrind,
50   which,
51   wrapGAppsNoGuiHook,
52   xdg-dbus-proxy,
53   xmlto,
54   xorg,
55   xz,
56   zstd,
59 stdenv.mkDerivation (finalAttrs: {
60   pname = "flatpak";
61   version = "1.14.8";
63   # TODO: split out lib once we figure out what to do with triggerdir
64   outputs = [
65     "out"
66     "dev"
67     "man"
68     "doc"
69     "devdoc"
70     "installedTests"
71   ];
73   src = fetchurl {
74     url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz";
75     hash = "sha256-EBa3Mn96+HiW+VRl9+WBN1DTtwSaN0ChpN3LX6jFNI4=";
76   };
78   patches = [
79     # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
80     # https://github.com/flatpak/flatpak/issues/1460
81     (substituteAll {
82       src = ./fix-test-paths.patch;
83       inherit
84         coreutils
85         gettext
86         socat
87         gtk3
88         ;
89       smi = shared-mime-info;
90       dfu = desktop-file-utils;
91       hicolorIconTheme = hicolor-icon-theme;
92     })
94     # Hardcode paths used by Flatpak itself.
95     (substituteAll {
96       src = ./fix-paths.patch;
97       p11kit = "${p11-kit.bin}/bin/p11-kit";
98     })
100     # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
101     # Patch taken from gtk-doc expression.
102     ./respect-xml-catalog-files-var.patch
104     # Nix environment hacks should not leak into the apps.
105     # https://github.com/NixOS/nixpkgs/issues/53441
106     ./unset-env-vars.patch
108     # Use flatpak from PATH to avoid references to `/nix/store` in `/desktop` files.
109     # Applications containing `DBusActivatable` entries should be able to find the flatpak binary.
110     # https://github.com/NixOS/nixpkgs/issues/138956
111     ./binary-path.patch
113     # The icon validator needs to access the gdk-pixbuf loaders in the Nix store
114     # and cannot bind FHS paths since those are not available on NixOS.
115     finalAttrs.passthru.icon-validator-patch
117     # Try mounting fonts and icons from NixOS locations if FHS locations don't exist.
118     # https://github.com/NixOS/nixpkgs/issues/119433
119     ./fix-fonts-icons.patch
120   ];
122   nativeBuildInputs = [
123     autoreconfHook
124     libxml2
125     docbook_xml_dtd_45
126     docbook-xsl-nons
127     which
128     gobject-introspection
129     gtk-doc
130     intltool
131     libxslt
132     pkg-config
133     xmlto
134     bison
135     wrapGAppsNoGuiHook
136   ];
138   buildInputs = [
139     appstream
140     bubblewrap
141     bzip2
142     curl
143     dbus
144     dconf
145     gpgme
146     json-glib
147     libarchive
148     libcap
149     libseccomp
150     xz
151     zstd
152     polkit
153     python3
154     systemd
155     xorg.libXau
156     fuse3
157     gsettings-desktop-schemas
158     glib-networking
159     librsvg # for flatpak-validate-icon
160   ];
162   # Required by flatpak.pc
163   propagatedBuildInputs = [
164     glib
165     ostree
166   ];
168   nativeCheckInputs = [ valgrind ];
170   # TODO: some issues with temporary files
171   doCheck = false;
173   NIX_LDFLAGS = "-lpthread";
175   enableParallelBuilding = true;
177   configureFlags = [
178     "--with-curl"
179     "--with-system-bubblewrap=${lib.getExe bubblewrap}"
180     "--with-system-dbus-proxy=${lib.getExe xdg-dbus-proxy}"
181     "--with-dbus-config-dir=${placeholder "out"}/share/dbus-1/system.d"
182     "--with-profile-dir=${placeholder "out"}/etc/profile.d"
183     "--localstatedir=/var"
184     "--sysconfdir=/etc"
185     "--enable-gtk-doc"
186     "--enable-installed-tests"
187   ];
189   makeFlags = [
190     "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
191     "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
192   ];
194   postPatch =
195     let
196       vsc-py = python3.withPackages (pp: [ pp.pyparsing ]);
197     in
198     ''
199       patchShebangs buildutil
200       patchShebangs tests
201       PATH=${lib.makeBinPath [ vsc-py ]}:$PATH patchShebangs --build subprojects/variant-schema-compiler/variant-schema-compiler
202     '';
204   passthru = {
205     icon-validator-patch = substituteAll {
206       src = ./fix-icon-validation.patch;
207       inherit (builtins) storeDir;
208     };
210     updateScript = nix-update-script { };
212     tests = {
213       installedTests = nixosTests.installed-tests.flatpak;
215       validate-icon = runCommand "test-icon-validation" { } ''
216         ${finalAttrs.finalPackage}/libexec/flatpak-validate-icon \
217           --sandbox 512 512 \
218           "${nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake-white.svg" > "$out"
220         grep format=svg "$out"
221       '';
223       version = testers.testVersion { package = finalAttrs.finalPackage; };
224     };
225   };
227   meta = {
228     description = "Linux application sandboxing and distribution framework";
229     homepage = "https://flatpak.org/";
230     changelog = "https://github.com/flatpak/flatpak/releases/tag/${finalAttrs.version}";
231     license = lib.licenses.lgpl21Plus;
232     maintainers = with lib.maintainers; [ getchoo ];
233     platforms = lib.platforms.linux;
234   };