feat(desktop): make portals installation configurable

This commit is contained in:
Yorick Barbanneau 2025-08-27 21:59:49 +02:00
parent 308d6fca81
commit c7e8ec0628
Signed by: ephase
GPG key ID: 246042E52B41FFCF
2 changed files with 28 additions and 6 deletions

View file

@ -42,6 +42,7 @@
inputFilename = "temp1_input"; inputFilename = "temp1_input";
}; };
}; };
xdg.useDistributionPortals = true;
}; };
web.firefox = { web.firefox = {
enable = true; enable = true;

View file

@ -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 = { wallpapers = {
lockscreen = mkOption { lockscreen = mkOption {
type = types.str; type = types.str;
@ -170,21 +180,32 @@ in
desktop = "${config.home.homeDirectory}/documents"; desktop = "${config.home.homeDirectory}/documents";
publicShare = "${config.home.homeDirectory}/tmp/public"; publicShare = "${config.home.homeDirectory}/tmp/public";
}; };
portal = { portal = mkIf (cfg.xdg.useDistributionPortals == false) {
enable = true; enable = true;
extraPortals = with pkgs; [ extraPortals = with pkgs; [
xdg-desktop-portal
xdg-desktop-portal-wlr xdg-desktop-portal-wlr
xdg-desktop-portal-gtk xdg-desktop-portal-gtk
]; ];
xdgOpenUsePortal = true; xdgOpenUsePortal = true;
config = { config = {
sway.default = [ sway = {
"wlr" default = [
"gtk" "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
'';
}; };
} }