summaryrefslogtreecommitdiffstats
path: root/nixos/tests/starship.nix
blob: bfa758218d550db81abd3036708236594dcf4a1b (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
{ pkgs, ... }:
{
  name = "starship";
  meta.maintainers = pkgs.starship.meta.maintainers;

  nodes.machine = {
    programs = {
      fish.enable = true;
      zsh.enable = true;

      starship = {
        enable = true;
        settings.format = "<starship>";
      };
    };

    environment.systemPackages =
      map
        (
          shell:
          pkgs.writeScriptBin "expect-${shell}" ''
            #!${pkgs.expect}/bin/expect -f

            spawn env TERM=xterm ${shell} -i

            expect "<starship>" {
              send "exit\n"
            } timeout {
              send_user "\n${shell} failed to display Starship\n"
              exit 1
            }

            expect eof
          ''
        )
        [
          "bash"
          "fish"
          "zsh"
        ];
  };

  testScript = ''
    start_all()
    machine.wait_for_unit("default.target")

    machine.succeed("expect-bash")
    # FIXME: Fish test fails to display Starship while inside the test environment; works on real systems.
    # machine.succeed("expect-fish")
    machine.succeed("expect-zsh")
  '';
}