1{ lib, hostPkgs, ... }:
2
3let
4 # Make sure we don't have to go through the startup tutorial
5 customMuseScoreConfig = hostPkgs.writeText "MuseScore4.ini" ''
6 [application]
7 hasCompletedFirstLaunchSetup=true
8
9 [project]
10 preferredScoreCreationMode=1
11 '';
12in
13{
14 name = "musescore";
15 meta = with lib.maintainers; {
16 maintainers = [ turion ];
17 };
18
19 nodes.machine =
20 { pkgs, ... }:
21 {
22 imports = [
23 ./common/x11.nix
24 ];
25
26 services.xserver.enable = true;
27 environment.systemPackages = with pkgs; [
28 musescore
29 pdfgrep
30 ];
31 };
32
33 enableOCR = true;
34
35 testScript =
36 { ... }:
37 ''
38 start_all()
39 machine.wait_for_x()
40
41 # Inject custom settings
42 machine.succeed("mkdir -p /root/.config/MuseScore/")
43 machine.succeed(
44 "cp ${customMuseScoreConfig} /root/.config/MuseScore/MuseScore4.ini"
45 )
46
47 # Start MuseScore window
48 machine.execute("env XDG_RUNTIME_DIR=$PWD DISPLAY=:0.0 mscore >&2 &")
49
50 # Wait until MuseScore has launched
51 machine.wait_for_window("MuseScore Studio")
52
53 machine.screenshot("MuseScore0")
54
55 # Create a new score
56 machine.send_key("ctrl-n")
57
58 # Wait until the creation wizard appears
59 machine.wait_for_window("New score")
60
61 machine.screenshot("MuseScore1")
62
63 machine.send_key("tab")
64 machine.send_key("tab")
65 machine.send_key("ret")
66
67 machine.sleep(2)
68
69 machine.send_key("tab")
70 # Type the beginning of https://de.wikipedia.org/wiki/Alle_meine_Entchen
71 machine.send_chars("cdef6gg5aaaa7g")
72 machine.sleep(1)
73
74 machine.screenshot("MuseScore2")
75
76 # Go to the export dialogue and create a PDF
77 machine.send_key("ctrl-p")
78
79 # Wait until the Print dialogue appears.
80 machine.wait_for_window("Print")
81
82 machine.screenshot("MuseScore4")
83 machine.send_key("alt-p")
84 machine.sleep(1)
85
86 machine.screenshot("MuseScore5")
87
88 # Wait until PDF is exported
89 machine.wait_for_file('"/root/Untitled score.pdf"')
90
91 ## Check that it contains the title of the score
92 machine.succeed('pdfgrep "Untitled score" "/root/Untitled score.pdf"')
93 machine.copy_from_vm("/root/Untitled score.pdf")
94 '';
95}