From cf39ba5e07cf38a4171265c66a3fdfbca1c90c7a Mon Sep 17 00:00:00 2001 From: Bobby Rong Date: Sun, 15 Jun 2025 13:17:46 +0800 Subject: [PATCH] nixos/{budgie,cinnamon,mate}: Hack around SSH_AUTH_SOCK Make sure SSH_AUTH_SOCK is known by these sessions, which are not systemd managed. It should not be a problem for users who know this environment variable and use multiple desktops environments to opt-out of this and I would prefer a more out-of-the-box experience for those who don't. --- .../services/x11/desktop-managers/budgie.nix | 28 ++++++++++++------- .../x11/desktop-managers/cinnamon.nix | 28 ++++++++++++------- .../services/x11/desktop-managers/mate.nix | 8 ++++++ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/x11/desktop-managers/budgie.nix b/nixos/modules/services/x11/desktop-managers/budgie.nix index cdd2e9453133..9d7161a7560c 100644 --- a/nixos/modules/services/x11/desktop-managers/budgie.nix +++ b/nixos/modules/services/x11/desktop-managers/budgie.nix @@ -130,17 +130,25 @@ in services.xserver.desktopManager.budgie.sessionPath = [ pkgs.budgie-desktop-view ]; - environment.extraInit = '' - ${concatMapStrings (p: '' - if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then - export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name} + environment.extraInit = + '' + ${concatMapStrings (p: '' + if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then + export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name} + fi + if [ -d "${p}/lib/girepository-1.0" ]; then + export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0 + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib + fi + '') cfg.sessionPath} + '' + + lib.optionalString config.services.gnome.gcr-ssh-agent.enable '' + # Hack: https://bugzilla.redhat.com/show_bug.cgi?id=2250704 still + # applies to sessions not managed by systemd. + if [ -z "$SSH_AUTH_SOCK" ] && [ -n "$XDG_RUNTIME_DIR" ]; then + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gcr/ssh" fi - if [ -d "${p}/lib/girepository-1.0" ]; then - export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0 - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib - fi - '') cfg.sessionPath} - ''; + ''; environment.systemPackages = with pkgs; diff --git a/nixos/modules/services/x11/desktop-managers/cinnamon.nix b/nixos/modules/services/x11/desktop-managers/cinnamon.nix index 60880d826962..44068bfb62d6 100644 --- a/nixos/modules/services/x11/desktop-managers/cinnamon.nix +++ b/nixos/modules/services/x11/desktop-managers/cinnamon.nix @@ -87,18 +87,26 @@ in }; # Have to take care of GDM + Cinnamon on Wayland users - environment.extraInit = '' - ${concatMapStrings (p: '' - if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then - export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name} - fi + environment.extraInit = + '' + ${concatMapStrings (p: '' + if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then + export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name} + fi - if [ -d "${p}/lib/girepository-1.0" ]; then - export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0 - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib + if [ -d "${p}/lib/girepository-1.0" ]; then + export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0 + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib + fi + '') cfg.sessionPath} + '' + + lib.optionalString config.services.gnome.gcr-ssh-agent.enable '' + # Hack: https://bugzilla.redhat.com/show_bug.cgi?id=2250704 still + # applies to sessions not managed by systemd. + if [ -z "$SSH_AUTH_SOCK" ] && [ -n "$XDG_RUNTIME_DIR" ]; then + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gcr/ssh" fi - '') cfg.sessionPath} - ''; + ''; # Default services services.blueman.enable = mkDefault (notExcluded pkgs.blueman); diff --git a/nixos/modules/services/x11/desktop-managers/mate.nix b/nixos/modules/services/x11/desktop-managers/mate.nix index dd8f10061910..74cbca78e6b2 100644 --- a/nixos/modules/services/x11/desktop-managers/mate.nix +++ b/nixos/modules/services/x11/desktop-managers/mate.nix @@ -59,6 +59,14 @@ in pkgs.mate.mate-session-manager ]; + environment.extraInit = lib.optionalString config.services.gnome.gcr-ssh-agent.enable '' + # Hack: https://bugzilla.redhat.com/show_bug.cgi?id=2250704 still + # applies to sessions not managed by systemd. + if [ -z "$SSH_AUTH_SOCK" ] && [ -n "$XDG_RUNTIME_DIR" ]; then + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gcr/ssh" + fi + ''; + # Debugging environment.sessionVariables.MATE_SESSION_DEBUG = mkIf cfg.debug "1";