···
5
-
meta.maintainers = with lib.maintainers; [ rnhmjoj ];
5
+
declarative = runTest {
7
+
meta.maintainers = with pkgs.lib.maintainers; [ rnhmjoj ];
10
-
services.getty.autologinUser = "root";
12
+
services.getty.autologinUser = "root";
12
-
environment.systemPackages = with pkgs; [
14
+
environment.systemPackages = with pkgs; [
17
-
programs.bash.promptInit = "PS1='# '";
19
+
programs.bash.promptInit = "PS1='# '";
19
-
# startx+bspwm setup
20
-
services.xserver = {
22
-
windowManager.bspwm = {
21
+
# startx+bspwm setup
22
+
services.xserver = {
24
-
configFile = pkgs.writeShellScript "bspwrc" ''
25
-
bspc config border_width 2
26
-
bspc config window_gap 12
27
-
bspc rule -a xclock state=floating sticky=on
29
-
sxhkd.configFile = pkgs.writeText "sxhkdrc" ''
34
-
super + alt + Escape
24
+
windowManager.bspwm = {
26
+
configFile = pkgs.writeShellScript "bspwrc" ''
27
+
bspc config border_width 2
28
+
bspc config window_gap 12
29
+
bspc rule -a xclock state=floating sticky=on
31
+
sxhkd.configFile = pkgs.writeText "sxhkdrc" ''
36
+
super + alt + Escape
40
+
displayManager.startx = {
42
+
generateScript = true;
44
+
xrdb -load ~/.Xresources
45
+
xsetroot -solid '#343d46'
46
+
xsetroot -cursor_name trek
38
-
displayManager.startx = {
52
+
# enable some user services
53
+
security.polkit.enable = true;
54
+
services.urxvtd.enable = true;
55
+
programs.xss-lock.enable = true;
61
+
sysu = "env XDG_RUNTIME_DIR=/run/user/0 systemctl --user";
64
+
with subtest("Wait for the autologin"):
65
+
machine.wait_until_tty_matches("1", prompt)
67
+
with subtest("Setup dotfiles"):
68
+
machine.execute(textwrap.dedent("""
69
+
cat <<EOF > ~/.Xresources
70
+
urxvt*foreground: #9b9081
71
+
urxvt*background: #181b20
72
+
urxvt*scrollBar: false
74
+
urxvt*geometry: 80x240+0+0
75
+
xclock*geometry: 164x164+24+440
79
+
with subtest("Can start the X server"):
80
+
machine.send_chars("startx\n")
81
+
machine.wait_for_x()
82
+
machine.wait_for_window("xclock")
84
+
with subtest("Graphical services are running"):
85
+
machine.succeed(f"{sysu} is-active graphical-session.target")
86
+
machine.succeed(f"{sysu} is-active urxvtd")
87
+
machine.succeed(f"{sysu} is-active xss-lock")
89
+
with subtest("Can interact with the WM"):
90
+
machine.wait_until_succeeds("pgrep sxhkd")
91
+
machine.wait_until_succeeds("pgrep bspwm")
92
+
# spawn some terminals
93
+
machine.send_key("meta_l-ret", delay=0.5)
94
+
machine.send_key("meta_l-ret", delay=0.5)
95
+
machine.send_key("meta_l-ret", delay=0.5)
96
+
# Note: this tests that resources have beeen loaded
97
+
machine.wait_for_window("myterm")
98
+
machine.screenshot("screenshot.png")
100
+
with subtest("Can stop the X server"):
102
+
machine.send_key("meta_l-alt-esc")
103
+
machine.wait_until_tty_matches("1", prompt)
105
+
with subtest("Graphical session has stopped"):
106
+
machine.fail(f"{sysu} is-active graphical-session.target")
107
+
machine.fail(f"{sysu} is-active urxvtd")
108
+
machine.fail(f"{sysu} is-active xss-lock")
112
+
imperative = runTest {
113
+
name = "startx-imperative";
114
+
meta.maintainers = with pkgs.lib.maintainers; [ rnhmjoj ];
119
+
services.getty.autologinUser = "root";
120
+
programs.bash.promptInit = "PS1='# '";
123
+
services.xserver = {
40
-
generateScript = true;
42
-
xrdb -load ~/.Xresources
43
-
xsetroot -solid '#343d46'
44
-
xsetroot -cursor_name trek
125
+
windowManager.twm.enable = true;
126
+
displayManager.startx.enable = true;
127
+
displayManager.startx.generateScript = false;
130
+
# enable some user services
131
+
security.polkit.enable = true;
132
+
services.urxvtd.enable = true;
133
+
programs.xss-lock.enable = true;
50
-
# enable some user services
51
-
security.polkit.enable = true;
52
-
services.urxvtd.enable = true;
53
-
programs.xss-lock.enable = true;
59
-
sysu = "env XDG_RUNTIME_DIR=/run/user/0 systemctl --user";
139
+
sysu = "env XDG_RUNTIME_DIR=/run/user/0 systemctl --user";
62
-
with subtest("Wait for the autologin"):
63
-
machine.wait_until_tty_matches("1", prompt)
142
+
with subtest("Wait for the autologin"):
143
+
machine.wait_until_tty_matches("1", prompt)
65
-
with subtest("Setup dotfiles"):
66
-
machine.execute(textwrap.dedent("""
67
-
cat <<EOF > ~/.Xresources
145
+
with subtest("Setup dotfiles"):
146
+
machine.execute(textwrap.dedent("""
147
+
cat <<EOF > ~/.Xresources
urxvt*foreground: #9b9081
urxvt*background: #181b20
72
-
urxvt*geometry: 80x240+0+0
73
-
xclock*geometry: 164x164+24+440
152
+
urxvt*geometry: 20x20+40+40
154
+
cat <<EOF > ~/.twmrc
155
+
"Return" = meta : all : f.exec "urxvtc"
156
+
"Escape" = meta : all : f.quit
158
+
cat <<EOF > ~/.xinitrc
159
+
xrdb -load ~/.Xresources
160
+
xsetroot -solid '#343d46'
161
+
xsetroot -cursor_name trek
162
+
# start user services
163
+
systemctl --user import-environment DISPLAY XDG_SESSION_ID
164
+
systemctl --user start nixos-fake-graphical-session.target
165
+
# run the window manager
167
+
# stop services and all subprocesses
168
+
systemctl --user stop nixos-fake-graphical-session.target
77
-
with subtest("Can start the X server"):
78
-
machine.send_chars("startx\n")
79
-
machine.wait_for_x()
80
-
machine.wait_for_window("xclock")
172
+
with subtest("Can start the X server"):
173
+
machine.send_chars("startx\n")
174
+
machine.wait_for_x()
82
-
with subtest("Graphical services are running"):
83
-
machine.succeed(f"{sysu} is-active graphical-session.target")
84
-
machine.succeed(f"{sysu} is-active urxvtd")
85
-
machine.succeed(f"{sysu} is-active xss-lock")
176
+
with subtest("Graphical services are running"):
177
+
machine.succeed(f"{sysu} is-active graphical-session.target")
178
+
machine.succeed(f"{sysu} is-active urxvtd")
179
+
machine.succeed(f"{sysu} is-active xss-lock")
87
-
with subtest("Can interact with the WM"):
88
-
machine.wait_until_succeeds("pgrep sxhkd")
89
-
machine.wait_until_succeeds("pgrep bspwm")
90
-
# spawn some terminals
91
-
machine.send_key("meta_l-ret", delay=0.5)
92
-
machine.send_key("meta_l-ret", delay=0.5)
93
-
machine.send_key("meta_l-ret", delay=0.5)
94
-
# Note: this tests that resources have beeen loaded
95
-
machine.wait_for_window("myterm")
96
-
machine.screenshot("screenshot.png")
181
+
with subtest("Can interact with the WM"):
182
+
machine.wait_until_succeeds("pgrep twm")
184
+
machine.send_key("alt-ret")
185
+
machine.wait_for_window("myterm")
186
+
machine.screenshot("screenshot.png")
98
-
with subtest("Can stop the X server"):
100
-
machine.send_key("meta_l-alt-esc")
101
-
machine.wait_until_tty_matches("1", prompt)
188
+
with subtest("Can stop the X server"):
190
+
machine.send_key("alt-esc")
191
+
machine.wait_until_tty_matches("1", prompt)
103
-
with subtest("Graphical session has stopped"):
104
-
machine.fail(f"{sysu} is-active graphical-session.target")
105
-
machine.fail(f"{sysu} is-active urxvtd")
106
-
machine.fail(f"{sysu} is-active xss-lock")
193
+
with subtest("Graphical session has stopped"):
194
+
machine.fail(f"{sysu} is-active graphical-session.target")
195
+
machine.fail(f"{sysu} is-active urxvtd")
196
+
machine.fail(f"{sysu} is-active xss-lock")