Initial experimental commit

This commit is contained in:
ooks-io 2024-01-13 22:52:45 +13:00
parent b848f9d893
commit 682a19b13c
146 changed files with 2463 additions and 2389 deletions

View file

@ -1,5 +1,6 @@
{
fonts = import ./fonts.nix;
monitors = import ./monitors.nix;
wallpaper = import ./wallpaper.nix;
xdg-portal = import ./xdg-portal.nix;
}

View file

@ -0,0 +1,12 @@
{ lib, ... }:
let inherit (lib) types mkOption;
in
{
options.wallpaper = mkOption {
type = types.path;
default = "";
description = ''
Wallpaper path
'';
};
}

View file

@ -14,33 +14,19 @@ in {
options.xdg.portal = {
enable = mkEnableOption (lib.mdDoc
"[xdg desktop integration](https://github.com/flatpak/xdg-desktop-portal)")
// {
default = false;
};
"[XDG desktop integration](https://github.com/flatpak/xdg-desktop-portal)");
extraPortals = mkOption {
type = types.listOf types.package;
default = [ ];
description = lib.mdDoc ''
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 `xdg-desktop-portal-gtk`; and
`xdg-desktop-portal-kde` respectively. On other desktop
environments you probably want to add them yourself.
'';
};
List of additional portals that should be passed to the
`xdg-desktop-portal.service`, via the `XDG_DESKTOP_PORTAL_DIR`
variable.
gtkUsePortal = mkOption {
type = types.bool;
visible = false;
default = false;
description = lib.mdDoc ''
Sets environment variable `GTK_USE_PORTAL` to `1`.
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.
Portals allow interaction with system, like choosing files or taking
screenshots. At minimum, a desktop portal implementation should be
listed.
'';
};
@ -70,9 +56,13 @@ in {
Sets which portal backend should be used to provide the implementation
for the requested interface. For details check {manpage}`portals.conf(5)`.
Configs will be linked to `/etx/xdg/xdg-desktop-portal/` with the name `$desktop-portals.conf`
for `xdg.portal.config.$desktop` and `portals.conf` for `xdg.portal.config.common`
as an exception.
These will be written with the name `$desktop-portals.conf` for
`xdg.portal.config.$desktop` and `portals.conf` for
`xdg.portal.config.common` as an exception.
These, together with `xdg.portal.configPackages`, will be joined into a
directory and passed to `xdg-desktop-portal.service` through a
`NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR` variable.
'';
};
@ -113,52 +103,48 @@ in {
paths = (mapAttrsToList mkPortalConfig cfg.config) ++ cfg.configPackages;
pathsToLink = [ "/share/xdg-desktop-portal" ];
};
in mkIf cfg.enable (mkMerge [
{
warnings = optional (cfg.configPackages == [ ] && cfg.config == { }) ''
xdg-desktop-portal 1.17 reworked how portal implementations are loaded, you
should either set `xdg.portal.config` or `xdg.portal.configPackages`
to specify which portal backend to use for the requested interface.
in mkIf cfg.enable {
warnings = optional (cfg.configPackages == [ ] && cfg.config == { }) ''
xdg-desktop-portal 1.17 reworked how portal implementations are loaded, you
should either set `xdg.portal.config` or `xdg.portal.configPackages`
to specify which portal backend to use for the requested interface.
https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in
https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in
If you simply want to keep the behaviour in < 1.17, which uses the first
portal implementation found in lexicographical order, use the following:
If you simply want to keep the behaviour in < 1.17, which uses the first
portal implementation found in lexicographical order, use the following:
xdg.portal.config.common.default = "*";
'';
xdg.portal.config.common.default = "*";
'';
assertions = [{
assertion = cfg.extraPortals != [ ];
message =
"Setting xdg.portal.enable to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
}];
assertions = [{
assertion = cfg.extraPortals != [ ];
message =
"Setting xdg.portal.enable to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
}];
home = {
sessionVariables =
mkIf cfg.xdgOpenUsePortal { NIXOS_XDG_OPEN_USE_PORTAL = "1"; };
# Make extraPortals systemd units available to the user
home.packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;
packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;
};
systemd.user.services.xdg-desktop-portal = {
Unit = {
Description = "Portal service";
PartOf = "graphical-session.target";
};
Service = {
Environment = [
"XDG_DESKTOP_PORTAL_DIR=${joinedPortals}/share/xdg-desktop-portal/portals"
] ++ (optional (cfg.configPackages != [ ])
"NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR=${joinedPortalConfigs}/share/xdg-desktop-portal");
Type = "dbus";
BusName = "org.freedesktop-portal.Desktop";
ExecStart = "${pkgs.xdg-desktop-portal}/libexec/xdg-desktop-portal";
Slice = "session.slice";
};
systemd.user.services.xdg-desktop-portal = {
Unit = {
Description = "Portal service";
PartOf = "graphical-session.target";
};
}
# This module uses mkMerge because HM's home.sessionVariables are (at the
# time of writing) scalars, which do not work with mkIf
(mkIf cfg.gtkUsePortal { home.sessionVariables.GTK_USE_PORTAL = "1"; })
(mkIf cfg.xdgOpenUsePortal {
home.sessionVariables.NIXOS_XDG_OPEN_USE_PORTAL = "1";
})
]);
Service = {
Environment = [
"XDG_DESKTOP_PORTAL_DIR=${joinedPortals}/share/xdg-desktop-portal/portals"
] ++ (optional (cfg.configPackages != [ ])
"NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR=${joinedPortalConfigs}/share/xdg-desktop-portal");
Type = "dbus";
BusName = "org.freedesktop.portal.Desktop";
ExecStart = "${pkgs.xdg-desktop-portal}/libexec/xdg-desktop-portal";
Slice = "session.slice";
};
};
};
}