|
8 | 8 |
|
9 | 9 | cfg = config.programs.ssh; |
10 | 10 |
|
11 | | - askPassword = cfg.askPassword; |
12 | | - |
13 | 11 | askPasswordWrapper = pkgs.writeScript "ssh-askpass-wrapper" |
14 | 12 | '' |
15 | 13 | #! ${pkgs.runtimeShell} -e |
16 | 14 | export DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^DISPLAY=\(.*\)/\1/; t; d')" |
17 | 15 | export WAYLAND_DISPLAY="$(systemctl --user show-environment | ${pkgs.gnused}/bin/sed 's/^WAYLAND_DISPLAY=\(.*\)/\1/; t; d')" |
18 | | - exec ${askPassword} "$@" |
| 16 | + exec ${cfg.askPassword} "$@" |
19 | 17 | ''; |
20 | 18 |
|
21 | 19 | knownHosts = attrValues cfg.knownHosts; |
|
52 | 50 | }; |
53 | 51 |
|
54 | 52 | forwardX11 = mkOption { |
55 | | - type = types.bool; |
| 53 | + type = with lib.types; nullOr bool; |
56 | 54 | default = false; |
57 | 55 | description = lib.mdDoc '' |
58 | 56 | Whether to request X11 forwarding on outgoing connections by default. |
| 57 | + If set to null, the option is not set at all. |
59 | 58 | This is useful for running graphical programs on the remote machine and have them display to your local X11 server. |
60 | 59 | Historically, this value has depended on the value used by the local sshd daemon, but there really isn't a relation between the two. |
61 | 60 | Note: there are some security risks to forwarding an X11 connection. |
|
274 | 273 | config = { |
275 | 274 |
|
276 | 275 | programs.ssh.setXAuthLocation = |
277 | | - mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 || config.services.openssh.settings.X11Forwarding); |
| 276 | + mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 == true || config.services.openssh.settings.X11Forwarding); |
278 | 277 |
|
279 | 278 | assertions = |
280 | | - [ { assertion = cfg.forwardX11 -> cfg.setXAuthLocation; |
| 279 | + [ { assertion = cfg.forwardX11 == true -> cfg.setXAuthLocation; |
281 | 280 | message = "cannot enable X11 forwarding without setting XAuth location"; |
282 | 281 | } |
283 | 282 | ] ++ flip mapAttrsToList cfg.knownHosts (name: data: { |
|
298 | 297 | AddressFamily ${if config.networking.enableIPv6 then "any" else "inet"} |
299 | 298 | GlobalKnownHostsFile ${concatStringsSep " " knownHostsFiles} |
300 | 299 |
|
301 | | - ${optionalString cfg.setXAuthLocation '' |
302 | | - XAuthLocation ${pkgs.xorg.xauth}/bin/xauth |
303 | | - ''} |
304 | | -
|
305 | | - ForwardX11 ${if cfg.forwardX11 then "yes" else "no"} |
| 300 | + ${optionalString cfg.setXAuthLocation "XAuthLocation ${pkgs.xorg.xauth}/bin/xauth"} |
| 301 | + ${lib.optionalString (cfg.forwardX11 != null) "ForwardX11 ${if cfg.forwardX11 then "yes" else "no"}"} |
306 | 302 |
|
307 | 303 | ${optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"} |
308 | 304 | ${optionalString (cfg.hostKeyAlgorithms != []) "HostKeyAlgorithms ${concatStringsSep "," cfg.hostKeyAlgorithms}"} |
|
344 | 340 | fi |
345 | 341 | ''; |
346 | 342 |
|
347 | | - environment.variables.SSH_ASKPASS = optionalString cfg.enableAskPassword askPassword; |
| 343 | + environment.variables.SSH_ASKPASS = optionalString cfg.enableAskPassword cfg.askPassword; |
348 | 344 |
|
349 | 345 | }; |
350 | 346 | } |
0 commit comments