mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-31 09:10:11 +00:00
The RFC 42 settings option derives the Host/Match line from the attribute name. That makes it impossible to express headers that carry Nix string context (e.g. Match exec referring to a store path), and forces long computed patterns into attribute names where a stable logical name would be nicer for dag ordering. Add an explicit `header` option on each block that defaults to the attribute name (with the existing Host/Match prefix detection), and have the legacy matchBlocks shim populate it instead of the __hmSshBlockHeader internal.
44 lines
1.2 KiB
Nix
44 lines
1.2 KiB
Nix
{ config, lib, ... }:
|
|
{
|
|
config = {
|
|
programs.ssh = {
|
|
enable = true;
|
|
enableDefaultConfig = false;
|
|
settings = {
|
|
# Stable name for dag ordering, header carries the actual pattern.
|
|
suffixed = lib.hm.dag.entryBefore [ "tmux" ] {
|
|
header = "Host foo foo-tmux bar bar-tmux";
|
|
ForwardAgent = true;
|
|
};
|
|
|
|
tmux = {
|
|
header = "Host *-tmux";
|
|
RemoteCommand = "tmux attach";
|
|
};
|
|
|
|
# Match condition referring to a store path; cannot be expressed
|
|
# as the attribute name because Nix forbids string context there.
|
|
local-exec = {
|
|
header = ''Match exec "${builtins.toFile "predicate" ''
|
|
#!/bin/sh
|
|
true
|
|
''}"'';
|
|
IdentityFile = "~/.ssh/id_ed25519_sk";
|
|
};
|
|
};
|
|
};
|
|
|
|
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 \
|
|
${./settings-header-expected.conf}
|
|
assertFileContent home-files/assertions ${./no-assertions.json}
|
|
'';
|
|
};
|
|
}
|