2020-04-24 23:36:52 +00:00
|
|
|
# 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";
|
2020-10-27 00:29:36 +00:00
|
|
|
|
|
|
|
guiPackages = mkOption {
|
|
|
|
internal = true;
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
example = literalExample "[ pkgs.gnome3.gnome-software ]";
|
|
|
|
description = ''
|
|
|
|
Packages that provide an interface for flatpak
|
|
|
|
(like gnome-software) that will be automatically available
|
|
|
|
to all users when flatpak is enabled.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{ assertion = (config.xdg.portal.enable == true);
|
|
|
|
message = "To use Flatpak you must enable XDG Desktop Portals with xdg.portal.enable.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-10-27 00:29:36 +00:00
|
|
|
environment.systemPackages = [ pkgs.flatpak ] ++ cfg.guiPackages;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
services.dbus.packages = [ pkgs.flatpak ];
|
|
|
|
|
|
|
|
systemd.packages = [ pkgs.flatpak ];
|
|
|
|
|
|
|
|
environment.profiles = [
|
|
|
|
"$HOME/.local/share/flatpak/exports"
|
|
|
|
"/var/lib/flatpak/exports"
|
|
|
|
];
|
|
|
|
|
|
|
|
# It has been possible since https://github.com/flatpak/flatpak/releases/tag/1.3.2
|
|
|
|
# to build a SELinux policy module.
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# TODO: use sysusers.d
|
2020-04-24 23:36:52 +00:00
|
|
|
users.users.flatpak = {
|
|
|
|
description = "Flatpak system helper";
|
|
|
|
group = "flatpak";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.flatpak = { };
|
|
|
|
};
|
|
|
|
}
|