ssh-agent-switcher: init at 1.0.1 (plus shtk: init shtk at 1.7) (#487983)

This commit is contained in:
Sandro
2026-02-17 13:14:06 +00:00
committed by GitHub
5 changed files with 190 additions and 0 deletions
+6
View File
@@ -12593,6 +12593,12 @@
githubId = 43830312;
name = "Joël Miramon";
};
jmmv = {
email = "julio@meroh.net";
github = "jmmv";
githubId = 879272;
name = "Julio Merino";
};
jn-sena = {
email = "jn-sena@proton.me";
github = "jn-sena";
+1
View File
@@ -1515,6 +1515,7 @@
./services/security/reaction.nix
./services/security/shibboleth-sp.nix
./services/security/sks.nix
./services/security/ssh-agent-switcher.nix
./services/security/sshguard.nix
./services/security/sslmate-agent.nix
./services/security/step-ca.nix
@@ -0,0 +1,43 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.ssh-agent-switcher;
in
{
meta.maintainers = [ lib.maintainers.jmmv ];
options = {
services.ssh-agent-switcher = {
enable = lib.mkEnableOption "ssh-agent-switcher daemon" // {
description = ''
Whether to enable ssh-agent-switcher, a daemon that proxies SSH agent
connections to forwarded agents. This allows tmux/screen sessions to
access SSH agents across reconnections.
This is a per-user service that automatically starts when you log in
via SSH and sets SSH_AUTH_SOCK to point to a stable socket location.
Note: This only activates for SSH sessions, not graphical or console logins.
'';
};
package = lib.mkPackageOption pkgs "ssh-agent-switcher" { };
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.loginShellInit = ''
if [ -n "$SSH_CONNECTION" ]; then
mkdir -p "''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/ssh-agent-switcher.sock"
${lib.getExe cfg.package} --daemon --socket-path="$SSH_AUTH_SOCK" 2>/dev/null || true
fi
'';
};
}
+75
View File
@@ -0,0 +1,75 @@
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "shtk";
version = "1.7";
src = fetchFromGitHub {
owner = "jmmv";
repo = "shtk";
tag = "shtk-${finalAttrs.version}";
hash = "sha256-EnJpysBI00JqLsRzdrHW62gV0wXx/Q+tpLR26jrgukU=";
};
outputs = [
"out"
"dev"
"man"
];
nativeBuildInputs = [
autoreconfHook
];
configureFlags = [
"SHTK_SHELL=${stdenv.shell}"
];
enableParallelBuilding = true;
doCheck = true;
postInstall = ''
# The "shtk" binary is only used when building packages that need shtk at
# runtime, so it's only a developer tool.
moveToOutput bin "$dev"
moveToOutput share/aclocal "$dev"
moveToOutput lib/pkgconfig "$dev"
substituteInPlace "$dev/lib/pkgconfig/shtk.pc" \
--replace-fail "$out/bin/shtk" "$dev/bin/shtk"
# Do not install tests. This is a weird pattern that not many packages
# follow.
rm -rf "$out/tests"
'';
meta = {
description = "Application toolkit for programmers writing POSIX-compliant shell scripts";
longDescription = ''
The Shell Toolkit, or shtk for short, is an application toolkit
for programmers writing POSIX-compliant shell scripts.
shtk provides a collection of reusable modules that work on a wide
variety of operating systems and shell interpreters. These modules are all
ready to be used by calling the provided shtk_import primitive and
"compiling" the shell scripts into their final form using the shtk(1)
utility.
shtk is purely written in the shell scripting language so there are no
dependencies to be installed, and is known to be compatible with at least
bash, dash, pdksh and zsh.
'';
homepage = "https://github.com/jmmv/shtk";
license = lib.licenses.bsd3;
maintainers = [ lib.maintainers.jmmv ];
platforms = lib.platforms.unix;
mainProgram = "shtk";
};
})
@@ -0,0 +1,65 @@
{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
installShellFiles,
openssh,
shtk,
}:
rustPlatform.buildRustPackage rec {
pname = "ssh-agent-switcher";
version = "1.0.1";
src = fetchFromGitHub {
owner = "jmmv";
repo = "ssh-agent-switcher";
tag = "ssh-agent-switcher-${version}";
hash = "sha256-p9W0H25pWDB+GCrwLwuVruX9p8b8kICpp+6I11ym1aw=";
};
cargoHash = "sha256-WioA/RjXOAHM9QWl/lxnb7gqzcp76rus7Rv+IfCYceg=";
nativeBuildInputs = [
installShellFiles
shtk.dev
];
nativeCheckInputs = [ openssh ];
checkPhase = ''
runHook preCheck
cargoCheckHook
shtk build -m shtk_unittest_main -o inttest inttest.sh
MODE="${stdenv.hostPlatform.rust.rustcTarget}/release" ./inttest
runHook postCheck
'';
postInstall = ''
installManPage ssh-agent-switcher.1
install -Dm644 README.md -t $out/share/doc/ssh-agent-switcher/
install -Dm644 NEWS.md -t $out/share/doc/ssh-agent-switcher/
install -Dm644 COPYING -t $out/share/doc/ssh-agent-switcher/
'';
meta = {
description = "SSH agent forwarding and tmux done right";
longDescription = ''
ssh-agent-switcher is a daemon that proxies SSH agent connections to any
valid forwarded agent provided by sshd. This allows long-lived processes
such as terminal multiplexers like tmux or screen to access the
connection-specific forwarded agents.
'';
homepage = "https://github.com/jmmv/ssh-agent-switcher";
changelog = "https://github.com/jmmv/ssh-agent-switcher/blob/ssh-agent-switcher-${version}/NEWS.md";
license = lib.licenses.bsd3;
maintainers = [ lib.maintainers.jmmv ];
mainProgram = "ssh-agent-switcher";
platforms = lib.platforms.unix;
};
}