mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
ssh: add includes option (#2453)
This commit is contained in:
parent
42915b78af
commit
5559ef0023
6 changed files with 38 additions and 13 deletions
|
@ -414,6 +414,22 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
includes = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
File globs of ssh config files that should be included via the
|
||||||
|
<literal>Include</literal> directive.
|
||||||
|
</para><para>
|
||||||
|
See
|
||||||
|
<citerefentry>
|
||||||
|
<refentrytitle>ssh_config</refentrytitle>
|
||||||
|
<manvolnum>5</manvolnum>
|
||||||
|
</citerefentry>
|
||||||
|
for more information.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
matchBlocks = mkOption {
|
matchBlocks = mkOption {
|
||||||
type = hm.types.listOrDagOf matchBlockModule;
|
type = hm.types.listOrDagOf matchBlockModule;
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -474,9 +490,12 @@ in
|
||||||
else abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}";
|
else abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}";
|
||||||
in ''
|
in ''
|
||||||
${concatStringsSep "\n" (
|
${concatStringsSep "\n" (
|
||||||
mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)}
|
(mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)
|
||||||
|
++ (optional (cfg.includes != [ ]) ''
|
||||||
${concatStringsSep "\n\n" (map (block: matchBlockStr block.data) matchBlocks)}
|
Include ${concatStringsSep " " cfg.includes}
|
||||||
|
'')
|
||||||
|
++ (map (block: matchBlockStr block.data) matchBlocks)
|
||||||
|
)}
|
||||||
|
|
||||||
Host *
|
Host *
|
||||||
ForwardAgent ${yn cfg.forwardAgent}
|
ForwardAgent ${yn cfg.forwardAgent}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Host *
|
Host *
|
||||||
ForwardAgent no
|
ForwardAgent no
|
||||||
Compression no
|
Compression no
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
ssh-defaults = ./default-config.nix;
|
ssh-defaults = ./default-config.nix;
|
||||||
|
ssh-includes = ./includes.nix;
|
||||||
ssh-match-blocks = ./match-blocks-attrs.nix;
|
ssh-match-blocks = ./match-blocks-attrs.nix;
|
||||||
|
|
||||||
ssh-forwards-dynamic-valid-bind-no-asserts =
|
ssh-forwards-dynamic-valid-bind-no-asserts =
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
Host dynamicBindAddressWithPort
|
Host dynamicBindAddressWithPort
|
||||||
DynamicForward [127.0.0.1]:3000
|
DynamicForward [127.0.0.1]:3000
|
||||||
|
|
||||||
Host dynamicBindPathNoPort
|
Host dynamicBindPathNoPort
|
||||||
DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra
|
DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra
|
||||||
|
|
||||||
|
|
15
tests/modules/programs/ssh/includes.nix
Normal file
15
tests/modules/programs/ssh/includes.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.ssh = {
|
||||||
|
enable = true;
|
||||||
|
includes = [ "config.d/*" "other/dir" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.ssh/config
|
||||||
|
assertFileContains home-files/.ssh/config "Include config.d/* other/dir"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,13 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
Host * !github.com
|
Host * !github.com
|
||||||
Port 516
|
Port 516
|
||||||
IdentityFile file1
|
IdentityFile file1
|
||||||
IdentityFile file2
|
IdentityFile file2
|
||||||
|
|
||||||
Host abc
|
Host abc
|
||||||
ProxyJump jump-host
|
ProxyJump jump-host
|
||||||
|
|
||||||
Host xyz
|
Host xyz
|
||||||
ServerAliveInterval 60
|
ServerAliveInterval 60
|
||||||
ServerAliveCountMax 10
|
ServerAliveCountMax 10
|
||||||
|
@ -16,7 +12,6 @@ Host xyz
|
||||||
RemoteForward [localhost]:8081 [10.0.0.2]:80
|
RemoteForward [localhost]:8081 [10.0.0.2]:80
|
||||||
RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent
|
RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent
|
||||||
DynamicForward [localhost]:2839
|
DynamicForward [localhost]:2839
|
||||||
|
|
||||||
Host ordered
|
Host ordered
|
||||||
Port 1
|
Port 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue