File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 ./docker-desktop.nix
55 ./interop.nix
66 ./recovery.nix
7+ ./ssh-agent.nix
78 ./systemd
89 ./usbip.nix
910 ./version.nix
Original file line number Diff line number Diff line change 1+ { config
2+ , lib
3+ , pkgs
4+ , ...
5+ } :
6+
7+ let
8+ cfg = config . wsl . ssh-agent ;
9+ in
10+ {
11+ options . wsl . ssh-agent = {
12+ enable = lib . mkEnableOption "ssh-agent passthrough to Windows" ;
13+
14+ package = lib . mkPackageOption pkgs "wsl2-ssh-agent" { } ;
15+
16+ users = lib . mkOption {
17+ type =
18+ let
19+ inherit ( lib . types ) either enum listOf ;
20+ userNames = lib . attrNames config . users . users ;
21+ in
22+ either
23+ ( enum [
24+ "!@system"
25+ "@system"
26+ ] )
27+ ( listOf ( enum userNames ) ) ;
28+ default = "!@system" ;
29+ description = ''
30+ Users to activate the service for. Defaults to all non-system users.
31+ '' ;
32+ } ;
33+ } ;
34+
35+ config = lib . mkIf ( config . wsl . enable && cfg . enable ) {
36+ systemd . user . services . wsl2-ssh-agent = {
37+ description = "WSL2 SSH Agent Bridge" ;
38+ after = [ "network.target" ] ;
39+ wantedBy = [ "default.target" ] ;
40+ unitConfig = {
41+ ConditionUser = lib . join "|" ( lib . toList cfg . users ) ;
42+ } ;
43+ serviceConfig = {
44+ ExecStart = "${ cfg . package } /bin/wsl2-ssh-agent --verbose --foreground --socket=%t/wsl2-ssh-agent.sock" ;
45+ Restart = "on-failure" ;
46+ } ;
47+ } ;
48+
49+ environment . variables . SSH_AUTH_SOCK = "$XDG_RUNTIME_DIR/wsl2-ssh-agent.sock" ;
50+ } ;
51+ }
You can’t perform that action at this time.
0 commit comments