2024-07-09 05:03:34 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.snowhawk.ssh;
|
2024-07-24 07:24:16 +00:00
|
|
|
sops = config.snowhawk.sops.enable;
|
2024-07-28 13:32:16 +00:00
|
|
|
secrets = config.sops.secrets;
|
|
|
|
|
|
|
|
ifSops = lib.mkIf sops;
|
2024-07-09 05:03:34 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.snowhawk.ssh = {
|
|
|
|
enable = lib.mkEnableOption "ssh";
|
2024-07-11 12:13:00 +00:00
|
|
|
|
|
|
|
homeNetwork = lib.mkEnableOption "include local hostnames for home network devices";
|
2024-07-09 05:03:34 +00:00
|
|
|
};
|
|
|
|
|
2024-07-28 13:08:59 +00:00
|
|
|
config =
|
2024-07-28 13:11:49 +00:00
|
|
|
let sshDir = config.home.homeDirectory + "/.ssh";
|
2024-07-28 13:08:59 +00:00
|
|
|
in lib.mkIf cfg.enable {
|
|
|
|
programs.ssh = {
|
|
|
|
enable = true;
|
|
|
|
includes = [ "conf.d/*" ];
|
|
|
|
matchBlocks = {
|
|
|
|
"git.zynh.me" = {
|
|
|
|
hostname = "git.zynh.me";
|
|
|
|
user = "git";
|
|
|
|
port = 2221;
|
2024-07-28 13:32:16 +00:00
|
|
|
identityFile = ifSops secrets."private_keys/personal_git".path;
|
2024-07-28 13:08:59 +00:00
|
|
|
};
|
2024-07-28 14:12:39 +00:00
|
|
|
snowhawk = {
|
|
|
|
identityFile = ifSops secrets."private_keys/snowhawk".path;
|
|
|
|
};
|
2024-07-28 13:08:59 +00:00
|
|
|
msiserver = {
|
|
|
|
hostname = "scarlet.zynh.me";
|
|
|
|
user = "zynh";
|
2024-07-28 13:32:16 +00:00
|
|
|
identityFile = ifSops secrets."private_keys/msiserver".path;
|
2024-07-28 13:08:59 +00:00
|
|
|
};
|
|
|
|
"msiserver.local" = lib.mkIf cfg.homeNetwork {
|
|
|
|
hostname = "msiserver";
|
|
|
|
user = "zynh";
|
2024-07-28 13:32:16 +00:00
|
|
|
identityFile = ifSops secrets."private_keys/msiserver".path;
|
2024-07-28 13:08:59 +00:00
|
|
|
};
|
|
|
|
caveserver = {
|
2024-07-28 13:32:16 +00:00
|
|
|
identityFile = ifSops secrets."private_keys/caveserver".path;
|
2024-07-28 13:08:59 +00:00
|
|
|
};
|
2024-07-11 12:58:16 +00:00
|
|
|
};
|
2024-07-09 05:03:34 +00:00
|
|
|
};
|
2024-07-24 06:40:58 +00:00
|
|
|
|
2024-07-28 13:11:49 +00:00
|
|
|
sops.secrets = ifSops {
|
|
|
|
"private_keys/msiserver" = { };
|
|
|
|
"private_keys/caveserver" = { };
|
2024-07-28 14:12:39 +00:00
|
|
|
"private_keys/snowhawk" = { };
|
2024-07-28 13:53:41 +00:00
|
|
|
"private_keys/personal_git" = { };
|
2024-07-28 13:11:49 +00:00
|
|
|
|
|
|
|
"ssh_hosts/caveserver".path = "${sshDir}/conf.d/caveserver_config";
|
2024-07-24 06:40:58 +00:00
|
|
|
};
|
2024-07-28 13:08:59 +00:00
|
|
|
};
|
2024-07-09 05:03:34 +00:00
|
|
|
}
|