ssh matchset options
This commit is contained in:
@@ -5,18 +5,23 @@ in
|
|||||||
{
|
{
|
||||||
flake.homeModules.ssh = { pkgs, config, lib, ... }:
|
flake.homeModules.ssh = { pkgs, config, lib, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options.ssh = {
|
||||||
sshIdentityFile = lib.mkOption {
|
IdentityFile = lib.mkOption {
|
||||||
# Intentionally not using a path type here because that will end up with the private key getting copied into the store
|
# Intentionally not using a path type here because that will end up with the private key getting copied into the store
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "${config.home.homeDirectory}/.ssh/id_ed25519";
|
default = "${config.home.homeDirectory}/.ssh/id_ed25519";
|
||||||
description = "Path to the SSH identity file.";
|
description = "Path to the SSH identity file.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
matchSets = {
|
||||||
|
appdaemon = lib.mkEnableOption "Enable AppDaemon SSH targets";
|
||||||
|
certs = lib.mkEnableOption "Enable Janus and Soteria SSH targets";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# All this stuff has to be wrapped in a config attribute because of the presence of the options here?
|
# All this stuff has to be wrapped in a config attribute because of the presence of the options here?
|
||||||
config = let
|
config = let
|
||||||
identityFile = config.sshIdentityFile;
|
identityFile = config.ssh.IdentityFile;
|
||||||
publicKeyFile = "${identityFile}.pub";
|
publicKeyFile = "${identityFile}.pub";
|
||||||
certificateFile = "${identityFile}-cert.pub";
|
certificateFile = "${identityFile}-cert.pub";
|
||||||
userKnownHostsFile = "${config.home.homeDirectory}/.ssh/known_hosts";
|
userKnownHostsFile = "${config.home.homeDirectory}/.ssh/known_hosts";
|
||||||
@@ -40,7 +45,8 @@ in
|
|||||||
IdentityAgent ~/.1password/agent.sock
|
IdentityAgent ~/.1password/agent.sock
|
||||||
'';
|
'';
|
||||||
|
|
||||||
matchBlocks = {
|
matchBlocks = lib.mkMerge [
|
||||||
|
{
|
||||||
"*" = {
|
"*" = {
|
||||||
user = "john";
|
user = "john";
|
||||||
|
|
||||||
@@ -57,7 +63,13 @@ in
|
|||||||
addKeysToAgent = "yes";
|
addKeysToAgent = "yes";
|
||||||
forwardAgent = false;
|
forwardAgent = false;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
(lib.mkIf config.ssh.matchsets.appdaemon {
|
||||||
|
"appdaemon" = {
|
||||||
|
hostname = "192.168.1.242";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
(lib.mkIf config.ssh.matchsets.certs {
|
||||||
"janus" = {
|
"janus" = {
|
||||||
hostname = "janus.john-stream.com";
|
hostname = "janus.john-stream.com";
|
||||||
user = "root";
|
user = "root";
|
||||||
@@ -66,7 +78,8 @@ in
|
|||||||
hostname = "soteria.john-stream.com";
|
hostname = "soteria.john-stream.com";
|
||||||
user = "john";
|
user = "john";
|
||||||
};
|
};
|
||||||
};
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user