Skip to content

Commit

Permalink
nixos/xdg: add portal option
Browse files Browse the repository at this point in the history
This factors the configuration out of the flatpak module.
  • Loading branch information
pasqui23 authored and worldofpeace committed Jul 18, 2019
1 parent 2ce67ce commit 90b1197
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 20 deletions.
38 changes: 38 additions & 0 deletions nixos/modules/config/xdg/portal.nix
@@ -0,0 +1,38 @@
{ config, pkgs ,lib ,... }:
with lib;
{
options.xdg.portal = {
enable =
mkEnableOption "<link xlink:href='https://github.com/flatpak/xdg-desktop-portal'>xdg desktop integration</link>"//{
default = true;
};

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 and KDE already
adds <package>xdg-desktop-portal-gtk</package>; and
<package>xdg-desktop-portal-kde</package> respectively. On other desktop
environments you probably want to add them yourself.
'';
};
};

config =
let
cfg = config.xdg.portal;
packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;

in mkIf cfg.enable {

services.dbus.packages = packages;
systemd.packages = packages;
environment.variables = {
GTK_USE_PORTAL = "1";
XDG_DESKTOP_PORTAL_PATH = map (p: "${p}/share/xdg-desktop-portal/portals") cfg.extraPortals;
};
};
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -11,6 +11,7 @@
./config/xdg/icons.nix
./config/xdg/menus.nix
./config/xdg/mime.nix
./config/xdg/portal.nix
./config/appstream.nix
./config/xdg/sounds.nix
./config/gtk/gtk-icon-cache.nix
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/rename.nix
Expand Up @@ -19,6 +19,7 @@ with lib;
let value = getAttrFromPath [ "services" "ddclient" "domain" ] config;
in if value != "" then [ value ] else []))
(mkRemovedOptionModule [ "services" "ddclient" "homeDir" ] "")
(mkRenamedOptionModule [ "services" "flatpak" "extraPortals" ] [ "xdg" "portal" "extraPortals" ])
(mkRenamedOptionModule [ "services" "i2pd" "extIp" ] [ "services" "i2pd" "address" ])
(mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "admissionControl" ] [ "services" "kubernetes" "apiserver" "enableAdmissionPlugins" ])
(mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "address" ] ["services" "kubernetes" "apiserver" "bindAddress"])
Expand Down
22 changes: 3 additions & 19 deletions nixos/modules/services/desktops/flatpak.nix
Expand Up @@ -15,38 +15,22 @@ in {
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;
services.dbus.packages = [ pkgs.flatpak ];

systemd.packages = [ pkgs.flatpak pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;
systemd.packages = [ pkgs.flatpak ];

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;
};
};
}
2 changes: 1 addition & 1 deletion nixos/modules/services/x11/desktop-managers/gnome3.nix
Expand Up @@ -154,7 +154,7 @@ in {
services.hardware.bolt.enable = mkDefault true;
services.xserver.libinput.enable = mkDefault true; # for controlling touchpad settings via gnome control center
systemd.packages = [ pkgs.gnome3.vino ];
services.flatpak.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

# If gnome3 is installed, build vim for gtk3 too.
nixpkgs.config.vim.gui = "gtk3";
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/x11/desktop-managers/plasma5.nix
Expand Up @@ -224,6 +224,8 @@ in
security.pam.services.sddm.enableKwallet = true;
security.pam.services.slim.enableKwallet = true;

xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-kde ];

# Update the start menu for each user that is currently logged in
system.userActivationScripts.plasmaSetup = ''
# The KDE icon cache is supposed to update itself
Expand Down

0 comments on commit 90b1197

Please sign in to comment.