3b5c031619
- Introduced a new module `rbw-ssh-socket.nix` to manage SSH_AUTH_SOCK for rbw. - Updated `default.nix` to utilize the new SSH socket variable for session management. - Refactored Bash and Fish shell configurations to use the new module for setting SSH_AUTH_SOCK, improving maintainability and consistency across shell environments.
31 lines
945 B
Nix
31 lines
945 B
Nix
{ ... }: {
|
|
flake.lib.rbwSshSocket =
|
|
let
|
|
bashSnippet = ''
|
|
if [ -z "''${SSH_AUTH_SOCK:-}" ]; then
|
|
if [ -n "''${XDG_RUNTIME_DIR:-}" ]; then
|
|
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/rbw/ssh-agent-socket"
|
|
else
|
|
export SSH_AUTH_SOCK="/run/user/$(id -u)/rbw/ssh-agent-socket"
|
|
fi
|
|
fi
|
|
'';
|
|
fishSnippet =
|
|
pkgs: ''
|
|
if test -z "$SSH_AUTH_SOCK"
|
|
if test -n "$XDG_RUNTIME_DIR"
|
|
set -gx SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/rbw/ssh-agent-socket"
|
|
else
|
|
set -l _hm_uid (${pkgs.coreutils}/bin/id -u)
|
|
set -gx SSH_AUTH_SOCK "/run/user/$_hm_uid/rbw/ssh-agent-socket"
|
|
end
|
|
end
|
|
'';
|
|
in
|
|
{
|
|
inherit bashSnippet fishSnippet;
|
|
sessionVariable = "$XDG_RUNTIME_DIR/rbw/ssh-agent-socket";
|
|
activationPath = "/run/user/$(id -u)/rbw/ssh-agent-socket";
|
|
};
|
|
}
|