about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/maestral.nix
blob: ba2e0b2f3baab515ba542f7176e64f2f82d6e5a1 (plain) (blame)
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
68
69
70
71
72
import ./make-test-python.nix ({ pkgs, ... }: {
  name = "maestral";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ peterhoeg ];
  };

  nodes =
    let
      common = attrs:
        pkgs.lib.recursiveUpdate
          {
            imports = [ ./common/user-account.nix ];
            systemd.user.services.maestral = {
              description = "Maestral Dropbox Client";
              serviceConfig.Type = "exec";
            };
          }
          attrs;

    in
    {
      cli = { ... }: common {
        systemd.user.services.maestral = {
          wantedBy = [ "default.target" ];
          serviceConfig.ExecStart = "${pkgs.maestral}/bin/maestral start --foreground";
        };
      };

      gui = { ... }: common {
        services.xserver = {
          enable = true;
          displayManager.sddm.enable = true;
          displayManager.defaultSession = "plasma";
          desktopManager.plasma5.enable = true;
          desktopManager.plasma5.runUsingSystemd = true;
          displayManager.autoLogin = {
            enable = true;
            user = "alice";
          };
        };

        systemd.user.services = {
          maestral = {
            wantedBy = [ "graphical-session.target" ];
            serviceConfig.ExecStart = "${pkgs.maestral-gui}/bin/maestral_qt";
          };
          # PowerDevil doesn't like our VM
          plasma-powerdevil.enable = false;
        };
      };
    };

  testScript = { nodes, ... }:
    let
      user = nodes.cli.config.users.users.alice;
    in
    ''
      start_all()

      with subtest("CLI"):
        # we need SOME way to give the user an active login session
        cli.execute("loginctl enable-linger ${user.name}")
        cli.systemctl("start user@${toString user.uid}")
        cli.wait_for_unit("maestral.service", "${user.name}")

      with subtest("GUI"):
        gui.wait_for_x()
        gui.succeed("xauth merge ${user.home}/.Xauthority")
        gui.wait_for_window("^Desktop ")
        gui.wait_for_unit("maestral.service", "${user.name}")
    '';
})