about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/desktops/flatpak.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/desktops/flatpak.nix')
-rw-r--r--nixpkgs/nixos/modules/services/desktops/flatpak.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/desktops/flatpak.nix b/nixpkgs/nixos/modules/services/desktops/flatpak.nix
new file mode 100644
index 000000000000..cfca1893bd82
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/desktops/flatpak.nix
@@ -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.profiles = [
+      "$HOME/.local/share/flatpak/exports"
+      "/var/lib/flatpak/exports"
+    ];
+
+    environment.variables = {
+      XDG_DESKTOP_PORTAL_PATH = map (p: "${p}/share/xdg-desktop-portal/portals") cfg.extraPortals;
+    };
+  };
+}