nixos/home/modules/ssh.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

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-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
};
config = lib.mkIf cfg.enable {
programs.ssh = {
enable = true;
includes = [
"conf.d/*"
];
2024-07-09 05:03:34 +00:00
matchBlocks = {
"git.zynh.me" = {
hostname = "git.zynh.me";
user = "git";
port = 2221;
identityFile = "${config.home.homeDirectory}/.ssh/personal_git";
};
2024-07-09 08:30:45 +00:00
msiserver = {
hostname = "scarlet.zynh.me";
user = "zynh";
2024-07-09 08:47:23 +00:00
identityFile = "${config.home.homeDirectory}/.ssh/msiserver";
};
2024-07-11 12:13:00 +00:00
"msiserver.local" = lib.mkIf cfg.homeNetwork {
2024-07-09 08:47:23 +00:00
hostname = "msiserver";
user = "zynh";
identityFile = "${config.home.homeDirectory}/.ssh/msiserver";
2024-07-09 08:30:45 +00:00
};
2024-07-11 12:58:16 +00:00
caveserver = {
identityFile = "${config.home.homeDirectory}/.ssh/caveserver";
};
2024-07-09 05:03:34 +00:00
};
};
sops.secrets =
2024-07-24 06:57:37 +00:00
let home = config.home.homeDirectory;
2024-07-24 07:24:16 +00:00
in lib.mkIf sops {
"private_keys/msiserver" = {
path = "${home}/.ssh/msiserver";
};
"private_keys/caveserver" = {
path = "${home}/.ssh/caveserver";
};
"ssh_hosts/caveserver" = {
path = "${home}/.ssh/conf.d/caveserver_config";
};
};
2024-07-09 05:03:34 +00:00
};
}