aboutsummaryrefslogtreecommitdiff
path: root/home-manager/tests/modules/programs/ssh/match-blocks-attrs.nix
blob: eaa20c6e32d9354d3c02cf5b9259d07b80c80858 (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
{ config, lib, pkgs, ... }:

with lib;

{
  config = {
    programs.ssh = {
      enable = true;
      matchBlocks = {
        abc = {
          identityFile = null;
          proxyJump = "jump-host";
        };

        ordered = hm.dag.entryAfter [ "xyz" ] { port = 1; };

        xyz = {
          identityFile = "file";
          serverAliveInterval = 60;
          serverAliveCountMax = 10;
          localForwards = [{
            bind.port = 8080;
            host.address = "10.0.0.1";
            host.port = 80;
          }];
          remoteForwards = [
            {
              bind.port = 8081;
              host.address = "10.0.0.2";
              host.port = 80;
            }
            {
              bind.address = "/run/user/1000/gnupg/S.gpg-agent.extra";
              host.address = "/run/user/1000/gnupg/S.gpg-agent";
            }
          ];
          dynamicForwards = [{ port = 2839; }];
        };

        "* !github.com" = {
          identityFile = [ "file1" "file2" ];
          port = 516;
        };
      };
    };

    home.file.assertions.text = builtins.toJSON
      (map (a: a.message) (filter (a: !a.assertion) config.assertions));

    nmt.script = ''
      assertFileExists home-files/.ssh/config
      assertFileContent \
        home-files/.ssh/config \
        ${./match-blocks-attrs-expected.conf}
      assertFileContent home-files/assertions ${./no-assertions.json}
    '';
  };
}