nixos/home/modules/ssh.nix

50 lines
1.3 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
};
2024-07-28 13:08:59 +00:00
config =
let home = config.home.homeDirectory + "/.ssh";
in lib.mkIf cfg.enable {
programs.ssh = {
enable = true;
includes = [ "conf.d/*" ];
matchBlocks = {
"git.zynh.me" = {
hostname = "git.zynh.me";
user = "git";
port = 2221;
identityFile = "${home}/.ssh/personal_git";
};
msiserver = {
hostname = "scarlet.zynh.me";
user = "zynh";
identityFile = "${home}/.ssh/msiserver";
};
"msiserver.local" = lib.mkIf cfg.homeNetwork {
hostname = "msiserver";
user = "zynh";
identityFile = "${home}/.ssh/msiserver";
};
caveserver = {
identityFile = "${home}/.ssh/caveserver";
};
2024-07-11 12:58:16 +00:00
};
2024-07-09 05:03:34 +00:00
};
2024-07-28 13:08:59 +00:00
sops.secrets = lib.mkIf sops {
2024-07-26 10:28:09 +00:00
"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-28 13:08:59 +00:00
};
2024-07-09 05:03:34 +00:00
}