diff --git a/nixos/modules/config/xdg/portal.nix b/nixos/modules/config/xdg/portal.nix
index 088f2af59e22..1e6ddd7c4a26 100644
--- a/nixos/modules/config/xdg/portal.nix
+++ b/nixos/modules/config/xdg/portal.nix
@@ -1,10 +1,30 @@
{ config, pkgs, lib, ... }:
-with lib;
+let
+ inherit (lib)
+ mkEnableOption
+ mkIf
+ mkOption
+ mkRenamedOptionModule
+ teams
+ types;
+in
{
imports = [
(mkRenamedOptionModule [ "services" "flatpak" "extraPortals" ] [ "xdg" "portal" "extraPortals" ])
+
+ ({ config, lib, options, ... }:
+ let
+ from = [ "xdg" "portal" "gtkUsePortal" ];
+ fromOpt = lib.getAttrFromPath from options;
+ in
+ {
+ warnings = lib.mkIf config.xdg.portal.gtkUsePortal [
+ "The option `${lib.showOption from}' defined in ${lib.showFiles fromOpt.files} has been deprecated. Setting the variable globally with `environment.sessionVariables' NixOS option can have unforseen side-effects."
+ ];
+ }
+ )
];
meta = {
@@ -32,11 +52,12 @@ with lib;
gtkUsePortal = mkOption {
type = types.bool;
+ visible = false;
default = false;
description = ''
Sets environment variable GTK_USE_PORTAL to 1.
- This is needed for packages ran outside Flatpak to respect and use XDG Desktop Portals.
- For example, you'd need to set this for non-flatpak Firefox to use native filechoosers.
+ This will force GTK-based programs ran outside Flatpak to respect and use XDG Desktop Portals
+ for features like file chooser but it is an unsupported hack that can easily break things.
Defaults to false to respect its opt-in nature.
'';
};