summaryrefslogtreecommitdiff
path: root/users/seth/programs/ssh.nix
blob: 2e0d3f4b7f09f28c8457dcc051eb1ac8e8dbbaef (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
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.seth.programs.ssh;
in
{
  options.seth.programs.ssh = {
    enable = lib.mkEnableOption "SSH configuration" // {
      default = config.seth.enable;
    };
  };

  config = lib.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;
  };
}