This commit is contained in:
2023-02-25 05:36:06 +00:00
parent b37e1ad042
commit d66e0951d4
4 changed files with 91 additions and 45 deletions

View File

@@ -3,5 +3,5 @@
{
# List your module files here
# my-module = import ./my-module.nix;
ssh-proxy = import ./ssh-proxy.nix;
}

View File

@@ -0,0 +1,43 @@
{ lib, pkgs, config, ... }:
with lib;
let cfg = config.services.ssh-proxy;
in {
options.services.ssh-proxy = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable ssh-proxy for WSL
'';
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
npiperelay
socat
];
systemd.user = {
startServices = true;
services.ssh-proxy = {
Unit = { Description = "WSL Proxy"; };
Service = {
ExecStart = "${pkgs.writeShellScript "start-proxy" ''
set -x
${pkgs.coreutils}/bin/rm -f /home/sstent/.ssh/wsl-ssh-agent.sock
${pkgs.util-linux}/bin/setsid ${pkgs.socat}/bin/socat UNIX-LISTEN:/home/sstent/.ssh/wsl-ssh-agent.sock,fork EXEC:"${pkgs.npiperelay}/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork
''}";
};
#Install = { WantedBy = [ "default.target" ]; };
};
};
};
}