Skip to content
Open
Changes from 1 commit
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
21 changes: 19 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,23 @@
'';
};

enableSSHSupport = lib.mkOption {
Comment thread
Scrumplex marked this conversation as resolved.
Outdated
type = lib.types.bool;
default = false;
description = ''
Enable SSH agent support in Gnome Keyring by setting SSH_AUTH_SOCK
environment variable correctly.
'';
};

};

};


###### 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 +59,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
'';

};

}