1{ pkgs, ... }:
2{
3 name = "maestral";
4 meta = with pkgs.lib.maintainers; {
5 maintainers = [ peterhoeg ];
6 };
7
8 nodes =
9 let
10 common =
11 attrs:
12 pkgs.lib.recursiveUpdate {
13 imports = [ ./common/user-account.nix ];
14 systemd.user.services.maestral = {
15 description = "Maestral Dropbox Client";
16 serviceConfig.Type = "exec";
17 };
18 } attrs;
19
20 in
21 {
22 cli =
23 { ... }:
24 common {
25 systemd.user.services.maestral = {
26 wantedBy = [ "default.target" ];
27 serviceConfig.ExecStart = "${pkgs.maestral}/bin/maestral start --foreground";
28 };
29 };
30
31 gui =
32 { ... }:
33 common {
34 services.xserver.enable = true;
35 services.desktopManager.plasma6.enable = true;
36
37 services.displayManager = {
38 sddm.enable = true;
39 defaultSession = "plasma";
40 autoLogin = {
41 enable = true;
42 user = "alice";
43 };
44 };
45
46 systemd.user.services = {
47 maestral = {
48 wantedBy = [ "graphical-session.target" ];
49 serviceConfig.ExecStart = "${pkgs.maestral-gui}/bin/maestral_qt";
50 };
51 # PowerDevil doesn't like our VM
52 plasma-powerdevil.enable = false;
53 };
54 };
55 };
56
57 testScript =
58 { nodes, ... }:
59 let
60 user = nodes.cli.users.users.alice;
61 in
62 ''
63 start_all()
64
65 with subtest("CLI"):
66 # we need SOME way to give the user an active login session
67 cli.execute("loginctl enable-linger ${user.name}")
68 cli.systemctl("start user@${toString user.uid}")
69 cli.wait_for_unit("maestral.service", "${user.name}")
70
71 with subtest("GUI"):
72 gui.wait_for_x()
73 gui.wait_for_file("/run/user/1000/xauth_*")
74 gui.wait_until_succeeds("test -s /run/user/1000/xauth_*")
75 gui.succeed("xauth merge /run/user/1000/xauth_*")
76 gui.wait_for_window("^Desktop ")
77 gui.wait_for_unit("maestral.service", "${user.name}")
78 '';
79}