1import ./make-test.nix ({ pkgs, ...} : {
2 name = "emacs-daemon";
3 meta = with pkgs.stdenv.lib.maintainers; {
4 maintainers = [ DamienCassou ];
5 };
6
7 enableOCR = true;
8
9 machine =
10 { config, pkgs, ... }:
11
12 { imports = [ ./common/x11.nix ];
13 services.emacs = {
14 enable = true;
15 defaultEditor = true;
16 };
17
18 # Important to get the systemd service running for root
19 environment.variables.XDG_RUNTIME_DIR = "/run/user/0";
20
21 environment.variables.TEST_SYSTEM_VARIABLE = "system variable";
22 };
23
24 testScript =
25 ''
26 $machine->waitForUnit("multi-user.target");
27
28 # checks that the EDITOR environment variable is set
29 $machine->succeed("test \$(basename \"\$EDITOR\") = emacseditor");
30
31 # waits for the emacs service to be ready
32 $machine->waitUntilSucceeds("systemctl --user status emacs.service | grep 'Active: active'");
33
34 # connects to the daemon
35 $machine->succeed("emacsclient --create-frame \$EDITOR &");
36
37 # checks that Emacs shows the edited filename
38 $machine->waitForText("emacseditor");
39
40 # makes sure environment variables are accessible from Emacs
41 $machine->succeed("emacsclient --eval '(getenv \"TEST_SYSTEM_VARIABLE\")'") =~ /system variable/ or die;
42
43 $machine->screenshot("emacsclient");
44 '';
45})