Add rbw SSH socket support in home-manager modules

- 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.
This commit is contained in:
2026-06-22 12:28:25 -03:00
parent 1524100ff5
commit 3b5c031619
4 changed files with 39 additions and 31 deletions
+4 -19
View File
@@ -1,9 +1,10 @@
{ ... }: {
{ self, ... }: {
flake.homeManagerModules.wisdomShellBash =
{ config, lib, ... }:
let
root = config.chiasson.home;
cfg = config.chiasson.home.shell.bash;
rbw = self.lib.rbwSshSocket;
in
{
options.chiasson.home.shell.bash.enable = lib.mkEnableOption "Bash + rbw SSH socket env in profile/init." // {
@@ -13,24 +14,8 @@
config = lib.mkIf (root.enable && cfg.enable) {
programs.bash = {
enable = true;
profileExtra = ''
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
'';
initExtra = ''
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
'';
profileExtra = rbw.bashSnippet;
initExtra = rbw.bashSnippet;
};
};
};
+3 -10
View File
@@ -1,9 +1,10 @@
{ ... }: {
{ self, ... }: {
flake.homeManagerModules.wisdomShellFish =
{ config, lib, pkgs, ... }:
let
root = config.chiasson.home;
cfg = config.chiasson.home.shell.fish;
rbw = self.lib.rbwSshSocket;
in
{
options.chiasson.home.shell.fish = {
@@ -19,21 +20,13 @@
};
config = lib.mkIf (root.enable && cfg.enable) {
# `fishPlugins.grc` only installs the plugin; the wrapper invokes the `grc` binary.
home.packages = [ pkgs.grc ];
programs.fish = {
enable = true;
interactiveShellInit = ''
set fish_greeting ""
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
${rbw.fishSnippet pkgs}
'';
plugins = [
{