-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33371 from jtojnar/flatpak
Flatpak
- Loading branch information
Showing
19 changed files
with
763 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# flatpak service. | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.flatpak; | ||
in { | ||
meta = { | ||
doc = ./flatpak.xml; | ||
maintainers = pkgs.flatpak.meta.maintainers; | ||
}; | ||
|
||
###### interface | ||
options = { | ||
services.flatpak = { | ||
enable = mkEnableOption "flatpak"; | ||
|
||
extraPortals = mkOption { | ||
type = types.listOf types.package; | ||
default = []; | ||
description = '' | ||
List of additional portals to add to path. Portals allow interaction | ||
with system, like choosing files or taking screenshots. At minimum, | ||
a desktop portal implementation should be listed. GNOME already | ||
adds <package>xdg-desktop-portal-gtk</package>; for KDE, there | ||
is <package>xdg-desktop-portal-kde</package>. Other desktop | ||
environments will probably want to do the same. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
###### implementation | ||
config = mkIf cfg.enable { | ||
environment.systemPackages = [ pkgs.flatpak ]; | ||
|
||
services.dbus.packages = [ pkgs.flatpak pkgs.xdg-desktop-portal ] ++ cfg.extraPortals; | ||
|
||
systemd.packages = [ pkgs.flatpak pkgs.xdg-desktop-portal ] ++ cfg.extraPortals; | ||
|
||
environment.variables = { | ||
PATH = [ | ||
"$HOME/.local/share/flatpak/exports/bin" | ||
"/var/lib/flatpak/exports/bin" | ||
]; | ||
|
||
XDG_DESKTOP_PORTAL_PATH = map (p: "${p}/share/xdg-desktop-portal/portals") cfg.extraPortals; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<chapter xmlns="http://docbook.org/ns/docbook" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:xi="http://www.w3.org/2001/XInclude" | ||
version="5.0" | ||
xml:id="module-services-flatpak"> | ||
|
||
<title>Flatpak</title> | ||
|
||
<para><emphasis>Source:</emphasis> <filename>modules/services/desktop/flatpak.nix</filename></para> | ||
|
||
<para><emphasis>Upstream documentation:</emphasis> <link xlink:href="https://github.com/flatpak/flatpak/wiki"/></para> | ||
|
||
<para>Flatpak is a system for building, distributing, and running sandboxed desktop applications on Linux.</para> | ||
|
||
<para> | ||
To enable Flatpak, add the following to your <filename>configuration.nix</filename>: | ||
|
||
<programlisting> | ||
<xref linkend="opt-services.flatpak.enable"/> = true; | ||
</programlisting> | ||
</para> | ||
|
||
<para> | ||
For the sandboxed apps to work correctly, desktop integration portals need to be installed. If you run GNOME, this will be handled automatically for you; in other cases, you will need to add something like the following to your <filename>configuration.nix</filename>: | ||
|
||
<programlisting> | ||
<xref linkend="opt-services.flatpak.extraPortals"/> = [ pkgs.xdg-desktop-portal-gtk ]; | ||
</programlisting> | ||
</para> | ||
|
||
<para> | ||
Then, you will need to add a repository, for example, <link xlink:href="https://github.com/flatpak/flatpak/wiki">Flathub</link>, either using the following commands: | ||
|
||
<programlisting> | ||
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | ||
flatpak update | ||
</programlisting> | ||
|
||
or by opening the <link xlink:href="https://flathub.org/repo/flathub.flatpakrepo">repository file</link> in GNOME Software. | ||
</para> | ||
|
||
<para> | ||
Finally, you can search and install programs: | ||
|
||
<programlisting> | ||
flatpak search bustle | ||
flatpak install flathub org.freedesktop.Bustle | ||
flatpak run org.freedesktop.Bustle | ||
</programlisting> | ||
|
||
Again, GNOME Software offers graphical interface for these tasks. | ||
</para> | ||
</chapter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# run installed tests | ||
import ./make-test.nix ({ pkgs, ... }: | ||
|
||
{ | ||
name = "flatpak"; | ||
meta = { | ||
maintainers = pkgs.flatpak.meta.maintainers; | ||
}; | ||
|
||
machine = { config, pkgs, ... }: { | ||
imports = [ ./common/x11.nix ]; | ||
services.xserver.desktopManager.gnome3.enable = true; # TODO: figure out minimal environment where the tests work | ||
services.flatpak.enable = true; | ||
environment.systemPackages = with pkgs; [ gnupg gnome-desktop-testing ostree python2 ]; | ||
virtualisation.memorySize = 2047; | ||
virtualisation.diskSize = 1024; | ||
}; | ||
|
||
testScript = '' | ||
$machine->waitForX(); | ||
$machine->succeed("gnome-desktop-testing-runner -d '${pkgs.flatpak.installedTests}/share' --timeout 3600"); | ||
''; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# run installed tests | ||
import ./make-test.nix ({ pkgs, ... }: | ||
|
||
{ | ||
name = "xdg-desktop-portal"; | ||
meta = { | ||
maintainers = pkgs.xdg-desktop-portal.meta.maintainers; | ||
}; | ||
|
||
machine = { config, pkgs, ... }: { | ||
environment.systemPackages = with pkgs; [ gnome-desktop-testing ]; | ||
}; | ||
|
||
testScript = '' | ||
$machine->succeed("gnome-desktop-testing-runner -d '${pkgs.xdg-desktop-portal.installedTests}/share'"); | ||
''; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ stdenv, fetchurl, autoreconfHook, docbook_xml_dtd_412, docbook_xml_dtd_42, docbook_xml_dtd_43, docbook_xsl, which, libxml2 | ||
, gobjectIntrospection, gtk_doc, intltool, libxslt, pkgconfig, xmlto, appstream-glib, substituteAll, glibcLocales, yacc | ||
, bubblewrap, bzip2, dbus, glib, gpgme, json_glib, libarchive, libcap, libseccomp, coreutils, python2, hicolor-icon-theme | ||
, libsoup, lzma, ostree, polkit, python3, systemd, xlibs, valgrind, glib_networking, makeWrapper, gnome3 }: | ||
|
||
let | ||
version = "0.11.7"; | ||
desktop_schemas = gnome3.gsettings_desktop_schemas; | ||
in stdenv.mkDerivation rec { | ||
name = "flatpak-${version}"; | ||
|
||
outputs = [ "out" "man" "doc" "installedTests" ]; | ||
|
||
src = fetchurl { | ||
url = "https://github.com/flatpak/flatpak/releases/download/${version}/${name}.tar.xz"; | ||
sha256 = "1vq4j7v68lp4fsvpas1bcsx1z4snpj0mkbq2mi00kx3jb48z768h"; | ||
}; | ||
|
||
patches = [ | ||
(substituteAll { | ||
src = ./fix-test-paths.patch; | ||
inherit coreutils python2 glibcLocales; | ||
hicolorIconTheme = hicolor-icon-theme; | ||
}) | ||
# patch taken from gtk_doc | ||
./respect-xml-catalog-files-var.patch | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
autoreconfHook libxml2 docbook_xml_dtd_412 docbook_xml_dtd_42 docbook_xml_dtd_43 docbook_xsl which gobjectIntrospection | ||
gtk_doc intltool libxslt pkgconfig xmlto appstream-glib yacc makeWrapper | ||
] ++ stdenv.lib.optionals doCheck checkInputs; | ||
|
||
buildInputs = [ | ||
bubblewrap bzip2 dbus glib gpgme json_glib libarchive libcap libseccomp | ||
libsoup lzma ostree polkit python3 systemd xlibs.libXau | ||
]; | ||
|
||
checkInputs = [ valgrind ]; | ||
|
||
doCheck = false; # TODO: some issues with temporary files | ||
|
||
enableParallelBuilding = true; | ||
|
||
configureFlags = [ | ||
"--with-system-bubblewrap=${bubblewrap}/bin/bwrap" | ||
"--localstatedir=/var" | ||
"--enable-installed-tests" | ||
]; | ||
|
||
makeFlags = [ | ||
"installed_testdir=$(installedTests)/libexec/installed-tests/flatpak" | ||
"installed_test_metadir=$(installedTests)/share/installed-tests/flatpak" | ||
]; | ||
|
||
postPatch = '' | ||
patchShebangs buildutil | ||
patchShebangs tests | ||
''; | ||
|
||
postFixup = '' | ||
wrapProgram $out/bin/flatpak \ | ||
--prefix GIO_EXTRA_MODULES : "${glib_networking.out}/lib/gio/modules" \ | ||
--prefix XDG_DATA_DIRS : "${desktop_schemas}/share/gsettings-schemas/${desktop_schemas.name}" | ||
''; | ||
|
||
meta = with stdenv.lib; { | ||
description = "Linux application sandboxing and distribution framework"; | ||
homepage = https://flatpak.org/; | ||
license = licenses.lgpl21; | ||
maintainers = with maintainers; [ jtojnar ]; | ||
platforms = platforms.linux; | ||
}; | ||
} |
Oops, something went wrong.