summaryrefslogtreecommitdiff
path: root/users/seth/mixins/ssh.nix
blob: 3ae26b23868278d60f74b558b3baba7062ad4db4 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (pkgs.stdenv.hostPlatform) isLinux;
in

{
  config = lib.mkMerge [
    {
      programs.ssh = {
        package = pkgs.openssh;

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

            "github.com" = {
              identityFile = "${sshDir}/github";
              user = "git";
            };

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

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

            # macstadium m1
            "mini.scrumplex.net" = {
              identityFile = "${sshDir}/macstadium";
              user = "bob-the-builder";
            };

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

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

    (lib.mkIf config.programs.ssh.enable {
      services.ssh-agent.enable = lib.mkDefault isLinux;
    })
  ];
}