Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions nixos/modules/services/desktops/gnome/gnome-keyring.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# GNOME Keyring daemon.

{ config, pkgs, lib, ... }:

let
cfg = config.services.gnome.gnome-keyring;
in
{

meta = {
Expand All @@ -24,14 +26,16 @@
'';
};

enableSSHSupport = lib.mkEnableOption "SSH agent support for GNOME Keyring by setting the SSH_AUTH_SOCK environment variable";

};

};


###### implementation

config = lib.mkIf config.services.gnome.gnome-keyring.enable {
config = lib.mkIf cfg.enable {

environment.systemPackages = [ pkgs.gnome.gnome-keyring ];

Expand All @@ -48,6 +52,12 @@
source = "${pkgs.gnome.gnome-keyring}/bin/gnome-keyring-daemon";
};

environment.extraInit = lib.mkIf cfg.enableSSHSupport ''

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Is there no easy way to express this with environment.sessionVariables or environment.variables?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I was trying to use something like this:

environment.sessionVariables = {
  SSH_AUTH_SOCK = "${builtins.getEnv "XDG_RUNTIME_DIR"}/keyring/ssh";
};

Then I relied on what is done with SSH and GnuPG, I thought it was a better practice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ${builtins.getEnv "XDG_RUNTIME_DIR"} is $XDG_RUNTIME_DIR in eval, not in activation.

The current way is not that bad though:

environment.extraInit = ''
if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/yubikey-agent/yubikey-agent.sock"
fi
'';

if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/keyring/ssh"
fi
'';

};

}