mirror of
https://github.com/sstent/vmimages.git
synced 2026-04-04 03:53:38 +00:00
sync
This commit is contained in:
@@ -28,10 +28,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
[ pkgs.socat pkgs.npiperelay];
|
[ pkgs.socat pkgs.npiperelay pkgs.wsl-ssh-agent-forward];
|
||||||
|
|
||||||
|
|
||||||
nixpkgs.config.packageOverrides = pkgs: with pkgs; rec {
|
nixpkgs.config.packageOverrides = pkgs: with pkgs; rec {
|
||||||
npiperelay = callPackage ../../pkgs/npiperelay { };
|
npiperelay = callPackage ../../pkgs/npiperelay { };
|
||||||
|
wsl-ssh-agent-forward = callPackage ../../pkgs/wsl-ssh-agent-forward { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -51,6 +53,7 @@ nixpkgs.config.packageOverrides = pkgs: with pkgs; rec {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
systemd.services.nixs-wsl-systemd-fix = {
|
systemd.services.nixs-wsl-systemd-fix = {
|
||||||
description = "Fix the /dev/shm symlink to be a mount";
|
description = "Fix the /dev/shm symlink to be a mount";
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
|
|||||||
11
pkgs/wsl-ssh-agent-forward/default.nix
Normal file
11
pkgs/wsl-ssh-agent-forward/default.nix
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{ lib, stdenv }:
|
||||||
|
|
||||||
|
let
|
||||||
|
script = pkgs.writeShellScriptBin "helloWorld" builtins.readFile ./wsl-ssh-agent-forward.sh;
|
||||||
|
name = "wsl-ssh-agent-forward"
|
||||||
|
in stdenv.mkDerivation rec {
|
||||||
|
pname = name;
|
||||||
|
# Add the derivation to the PATH
|
||||||
|
buildInputs = [ script ];
|
||||||
|
|
||||||
|
}
|
||||||
27
pkgs/wsl-ssh-agent-forward/wsl-ssh-agent-forward.sh
Normal file
27
pkgs/wsl-ssh-agent-forward/wsl-ssh-agent-forward.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Usage: wsl-ssh-agent-forward [ -k | -r ]
|
||||||
|
# Options:
|
||||||
|
# -k Kill the current process (if exists) and do not restart it.
|
||||||
|
# -r Kill the current process (if exists) and restart it.
|
||||||
|
# Default operation is to start a process only if it does not exist.
|
||||||
|
|
||||||
|
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
|
||||||
|
|
||||||
|
sshpid=$(ss -ap | grep "$SSH_AUTH_SOCK")
|
||||||
|
if [ "$1" = "-k" ] || [ "$1" = "-r" ]; then
|
||||||
|
sshpid=${sshpid//*pid=/}
|
||||||
|
sshpid=${sshpid%%,*}
|
||||||
|
if [ -n "${sshpid}" ]; then
|
||||||
|
kill "${sshpid}"
|
||||||
|
else
|
||||||
|
echo "'socat' not found or PID not found"
|
||||||
|
fi
|
||||||
|
if [ "$1" = "-k" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
unset sshpid
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${sshpid}" ]; then
|
||||||
|
rm -f $SSH_AUTH_SOCK
|
||||||
|
( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"${pkgs.npiperelay} -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/de>fi
|
||||||
Reference in New Issue
Block a user