From c7e8ec06286287a8f9a45f83815f456156895735 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 27 Aug 2025 21:59:49 +0200 Subject: [PATCH] feat(desktop): make portals installation configurable --- hosts/work/home-config.nix | 1 + modules/home-manager/desktop/sway/default.nix | 33 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/hosts/work/home-config.nix b/hosts/work/home-config.nix index d637898..0155435 100644 --- a/hosts/work/home-config.nix +++ b/hosts/work/home-config.nix @@ -42,6 +42,7 @@ inputFilename = "temp1_input"; }; }; + xdg.useDistributionPortals = true; }; web.firefox = { enable = true; diff --git a/modules/home-manager/desktop/sway/default.nix b/modules/home-manager/desktop/sway/default.nix index 776b0e9..643e192 100644 --- a/modules/home-manager/desktop/sway/default.nix +++ b/modules/home-manager/desktop/sway/default.nix @@ -23,6 +23,16 @@ in ''; }; + xdg.useDistributionPortals = mkOption { + type = types.bool; + default = false; + description = '' + This prevent installing xdg-desktop-portal from nixpkgs. These + Useful when using Home-Manager on third-party distribution with old + version of portals (coucou Ubuntu LTS) + ''; + }; + wallpapers = { lockscreen = mkOption { type = types.str; @@ -170,21 +180,32 @@ in desktop = "${config.home.homeDirectory}/documents"; publicShare = "${config.home.homeDirectory}/tmp/public"; }; - portal = { + portal = mkIf (cfg.xdg.useDistributionPortals == false) { enable = true; extraPortals = with pkgs; [ - xdg-desktop-portal xdg-desktop-portal-wlr xdg-desktop-portal-gtk ]; xdgOpenUsePortal = true; config = { - sway.default = [ - "wlr" - "gtk" - ]; + sway = { + default = [ + "wlr" + "gtk" + ]; + }; }; }; }; + + # When using `useDistributionPackage`, create wlr configuration to let user + # choose the right screen. This is a workarount to not have to configure + # it manually. + home.file."${config.xdg.configHome}/xdg-desktop-portal-wlr/config".text = mkIf cfg.xdg.useDistributionPortals '' + [screencast] + max_fps=30 + chooser_type=simple + chooser_cmd=${pkgs.slurp}/bin/slurp -f %o -or + ''; }; }