Commit fe40e990 authored by Jan Tojnar's avatar Jan Tojnar
Browse files

nixos/xdg/portal: Use systemPackage instead of buildEnv

Portals are global so we can just link them globally.

There might, in theory, be some unexpected system-path contamination
(e.g. when a portal package installs its executables to `/bin`)
but I think the risk is relatively minor compared to the added complexity.

While at it, let’s point the environment variable to system-path.
That will allow changes to installed portals to apply without having to re-log in.
parent 3b2f55e8
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -119,12 +119,6 @@ in
    let
      cfg = config.xdg.portal;
      packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;

      joinedPortals = pkgs.buildEnv {
        name = "xdg-portals";
        paths = packages;
        pathsToLink = [ "/share/xdg-desktop-portal/portals" "/share/applications" ];
      };
    in
    mkIf cfg.enable {
      warnings = lib.optional (cfg.configPackages == [ ] && cfg.config == { }) ''
@@ -151,11 +145,9 @@ in
      systemd.packages = packages;

      environment = {
        systemPackages = [
          joinedPortals
        ] ++ cfg.configPackages;
        systemPackages = packages ++ cfg.configPackages;
        pathsToLink = [
          # Upstream desktop environment portal configurations.
          # Portal definitions and upstream desktop environment portal configurations.
          "/share/xdg-desktop-portal"
          # .desktop files to register fallback icon and app name.
          "/share/applications"
@@ -164,7 +156,7 @@ in
        sessionVariables = {
          GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1";
          NIXOS_XDG_OPEN_USE_PORTAL = mkIf cfg.xdgOpenUsePortal "1";
          NIX_XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
          NIX_XDG_DESKTOP_PORTAL_DIR = "/run/current-system/sw/share/xdg-desktop-portal/portals";
        };

        etc = lib.concatMapAttrs