modules/desktop: add nixpak-tricks

This commit is contained in:
Max Headroom 2023-01-22 16:26:50 +01:00
parent 31b42cfd44
commit a28f6eb487
2 changed files with 33 additions and 0 deletions

View file

@ -6,6 +6,7 @@
in { in {
imports = [ imports = [
./package-sets.nix ./package-sets.nix
./nixpak-tricks.nix
]; ];
services.xserver = { services.xserver = {

View file

@ -0,0 +1,32 @@
{ pkgs, ... }:
let
# tricks xdg-document-portal into not using the document portal for pointless things
# note that we report read-write even if the access is supposed to be read-only,
# because ticking the checkbox in the dialog every time is annoying, ro status
# is enforced by the sandbox anyway
# example call: flatpak info --file-access=/srv/file.txt com.nixpak.Whatever
documentPortalFileAccessTrick = pkgs.writeShellScriptBin "flatpak" ''
[[ "$1" == "info" ]] || exit 1
case "$3" in
org.chromium.Chromium)
case "''${2#--file-access=}" in
$HOME/Downloads*) echo read-write;;
*) echo hidden;;
esac;;
io.bassi.Amberol)
case "''${2#--file-access=}" in
$HOME/Music*) echo read-write;;
/srv/data/music*) echo read-write;;
*) echo hidden;;
esac;;
*)
echo hidden;;
esac
'';
in
{
environment.systemPackages = [
documentPortalFileAccessTrick
];
}