ssh: remove top level options
This commit is contained in:
parent
59aabcd3db
commit
3882f88691
23 changed files with 370 additions and 226 deletions
|
|
@ -1,18 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
home.file.assertions.text = builtins.toJSON (
|
||||
map (a: a.message) (lib.filter (a: !a.assertion) config.assertions)
|
||||
);
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.ssh/config
|
||||
assertFileContent home-files/.ssh/config ${./default-config-expected.conf}
|
||||
assertFileContent home-files/assertions ${./no-assertions.json}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
ssh-defaults = ./default-config.nix;
|
||||
ssh-old-defaults = ./old-defaults.nix;
|
||||
ssh-old-defaults-extra-config = ./old-defaults-extra-config.nix;
|
||||
ssh-extra-config-no-default-host = ./extra-config-no-default-host.nix;
|
||||
ssh-renamed-options = ./renamed-options.nix;
|
||||
ssh-includes = ./includes.nix;
|
||||
ssh-match-blocks = ./match-blocks-attrs.nix;
|
||||
ssh-match-blocks-match-and-hosts = ./match-blocks-match-and-hosts.nix;
|
||||
|
||||
ssh-forwards-dynamic-valid-bind-no-asserts = ./forwards-dynamic-valid-bind-no-asserts.nix;
|
||||
ssh-forwards-dynamic-bind-path-with-port-asserts = ./forwards-dynamic-bind-path-with-port-asserts.nix;
|
||||
ssh-forwards-local-bind-path-with-port-asserts = ./forwards-local-bind-path-with-port-asserts.nix;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
Compression no
|
||||
AddKeysToAgent no
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
MyExtraOption no
|
||||
AnotherOption 3
|
||||
|
||||
14
tests/modules/programs/ssh/extra-config-no-default-host.nix
Normal file
14
tests/modules/programs/ssh/extra-config-no-default-host.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
extraConfig = ''
|
||||
MyExtraOption no
|
||||
AnotherOption 3
|
||||
'';
|
||||
};
|
||||
|
||||
test.asserts.assertions.expected = [
|
||||
''Cannot set `programs.ssh.extraConfig` if `programs.ssh.matchBlocks."*"` (default host config) is not declared.''
|
||||
];
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
dynamicBindPathWithPort = {
|
||||
dynamicForwards = [
|
||||
|
|
|
|||
|
|
@ -3,16 +3,5 @@ Host dynamicBindAddressWithPort
|
|||
Host dynamicBindPathNoPort
|
||||
DynamicForward /run/user/1000/gnupg/S.gpg-agent.extra
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
AddKeysToAgent no
|
||||
Compression no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
dynamicBindPathNoPort = {
|
||||
dynamicForwards = [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
localBindPathWithPort = {
|
||||
localForwards = [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
localHostPathWithPort = {
|
||||
localForwards = [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
remoteBindPathWithPort = {
|
||||
remoteForwards = [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
remoteHostPathWithPort = {
|
||||
remoteForwards = [
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
includes = [
|
||||
"config.d/*"
|
||||
"other/dir"
|
||||
|
|
|
|||
|
|
@ -16,16 +16,5 @@ Host xyz
|
|||
Host ordered
|
||||
Port 1
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
AddKeysToAgent no
|
||||
Compression no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
abc = {
|
||||
identityFile = null;
|
||||
|
|
|
|||
|
|
@ -5,16 +5,5 @@ Host abc
|
|||
Match host xyz canonical
|
||||
Port 2223
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
AddKeysToAgent no
|
||||
Compression no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
config = {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
abc = {
|
||||
port = 2222;
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
AddKeysToAgent no
|
||||
Compression no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
Compression no
|
||||
AddKeysToAgent no
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
ServerAliveInterval 0
|
||||
ServerAliveCountMax 3
|
||||
Compression no
|
||||
AddKeysToAgent no
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
MyExtraOption no
|
||||
AnotherOption 3
|
||||
|
||||
24
tests/modules/programs/ssh/old-defaults-extra-config.nix
Normal file
24
tests/modules/programs/ssh/old-defaults-extra-config.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
MyExtraOption no
|
||||
AnotherOption 3
|
||||
'';
|
||||
};
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
''
|
||||
`programs.ssh` default values will be removed in the future.
|
||||
Consider setting `programs.ssh.enableDefaultConfig` to false,
|
||||
and manually set the default values you want to keep at
|
||||
`programs.ssh.matchBlocks."*"`.
|
||||
''
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.ssh/config
|
||||
assertFileContent home-files/.ssh/config \
|
||||
${./old-defaults-extra-config-expected.conf}
|
||||
'';
|
||||
}
|
||||
18
tests/modules/programs/ssh/old-defaults.nix
Normal file
18
tests/modules/programs/ssh/old-defaults.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
programs.ssh.enable = true;
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
''
|
||||
`programs.ssh` default values will be removed in the future.
|
||||
Consider setting `programs.ssh.enableDefaultConfig` to false,
|
||||
and manually set the default values you want to keep at
|
||||
`programs.ssh.matchBlocks."*"`.
|
||||
''
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.ssh/config
|
||||
assertFileContent home-files/.ssh/config \
|
||||
${./old-defaults-expected.conf}
|
||||
'';
|
||||
}
|
||||
14
tests/modules/programs/ssh/renamed-options-expected.conf
Normal file
14
tests/modules/programs/ssh/renamed-options-expected.conf
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
Host *
|
||||
ForwardAgent yes
|
||||
ServerAliveInterval 1
|
||||
ServerAliveCountMax 2
|
||||
Compression yes
|
||||
AddKeysToAgent yes
|
||||
HashKnownHosts yes
|
||||
UserKnownHostsFile ~/.ssh/my_known_hosts
|
||||
ControlMaster yes
|
||||
ControlPath ~/.ssh/myfile-%r@%n:%p
|
||||
ControlPersist 10m
|
||||
|
||||
46
tests/modules/programs/ssh/renamed-options.nix
Normal file
46
tests/modules/programs/ssh/renamed-options.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{ lib, options, ... }:
|
||||
|
||||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
forwardAgent = true;
|
||||
addKeysToAgent = "yes";
|
||||
compression = true;
|
||||
serverAliveInterval = 1;
|
||||
serverAliveCountMax = 2;
|
||||
hashKnownHosts = true;
|
||||
userKnownHostsFile = "~/.ssh/my_known_hosts";
|
||||
controlMaster = "yes";
|
||||
controlPath = "~/.ssh/myfile-%r@%n:%p";
|
||||
controlPersist = "10m";
|
||||
};
|
||||
|
||||
test.asserts.warnings.expected =
|
||||
let
|
||||
renamedOptions = [
|
||||
"controlPersist"
|
||||
"controlPath"
|
||||
"controlMaster"
|
||||
"userKnownHostsFile"
|
||||
"hashKnownHosts"
|
||||
"serverAliveCountMax"
|
||||
"serverAliveInterval"
|
||||
"compression"
|
||||
"addKeysToAgent"
|
||||
"forwardAgent"
|
||||
];
|
||||
in
|
||||
map (
|
||||
o:
|
||||
"The option `programs.ssh.${o}' defined in ${
|
||||
lib.showFiles options.programs.ssh.${o}.files
|
||||
} has been renamed to `programs.ssh.matchBlocks.*.${o}'."
|
||||
) renamedOptions;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.ssh/config
|
||||
assertFileContent home-files/.ssh/config \
|
||||
${./renamed-options-expected.conf}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue