summaryrefslogtreecommitdiff
path: root/users/seth/programs/ssh.nix
blob: 080a60e2158479a4ad674874e16281644f9a0909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.getchoo.programs.ssh;
  inherit (lib) mkEnableOption mkIf;
in {
  options.getchoo.programs.ssh.enable = mkEnableOption "ssh" // {default = true;};

  config = mkIf cfg.enable {
    programs.ssh = {
      enable = true;
      package = pkgs.openssh;

      matchBlocks = let
        sshDir = "${config.home.homeDirectory}/.ssh";
      in {
        # git forges
        "codeberg.org" = {
          identityFile = "${sshDir}/codeberg";
          user = "git";
        };

        # linux packaging
        "aur.archlinux.org" = {
          identityFile = "${sshDir}/aur";
          user = "aur";
        };

        "pagure.io" = {
          identityFile = "${sshDir}/copr";
          user = "git";
        };

        # router
        "192.168.1.1" = {
          identityFile = "${sshDir}/openwrt";
          user = "root";
        };

        # servers
        "atlas".user = "atlas";
      };
    };

    services.ssh-agent.enable = pkgs.stdenv.isLinux;
  };
}