summary refs log tree commit diff
path: root/nixos/tests/slim.nix
blob: 42c87dfa039d240b10bb68fccc5374573ab35075 (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
import ./make-test.nix ({ pkgs, ...} : {
  name = "slim";

  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ aszlig ];
  };

  machine = { pkgs, ... }: {
    imports = [ ./common/user-account.nix ];
    services.xserver.enable = true;
    services.xserver.windowManager.default = "icewm";
    services.xserver.windowManager.icewm.enable = true;
    services.xserver.desktopManager.default = "none";
    services.xserver.displayManager.slim = {
      enable = true;

      # Use a custom theme in order to get best OCR results
      theme = pkgs.runCommand "slim-theme-ocr" {
        nativeBuildInputs = [ pkgs.imagemagick ];
      } ''
        mkdir "$out"
        convert -size 1x1 xc:white "$out/background.jpg"
        convert -size 200x100 xc:white "$out/panel.jpg"
        cat > "$out/slim.theme" <<EOF
        background_color #ffffff
        background_style tile

        input_fgcolor #000000
        msg_color #000000

        session_color #000000
        session_font Verdana:size=16:bold

        username_msg Username:
        username_font Verdana:size=16:bold
        username_color #000000
        username_x 50%
        username_y 40%

        password_msg Password:
        password_x 50%
        password_y 40%
        EOF
      '';
    };
  };

  enableOCR = true;

  testScript = { nodes, ... }: let
    user = nodes.machine.config.users.users.alice;
  in ''
    startAll;
    $machine->waitForText(qr/Username:/);
    $machine->sendChars("${user.name}\n");
    $machine->waitForText(qr/Password:/);
    $machine->sendChars("${user.password}\n");

    $machine->waitForFile('${user.home}/.Xauthority');
    $machine->succeed('xauth merge ${user.home}/.Xauthority');
    $machine->waitForWindow('^IceWM ');

    # Make sure SLiM doesn't create a log file
    $machine->fail('test -e /var/log/slim.log');
  '';
})