Skip to content

Commit ea2e6af

Browse files
committed
aerospace: add more tests and fix expected values
1 parent dbc10ec commit ea2e6af

File tree

8 files changed

+209
-78
lines changed

8 files changed

+209
-78
lines changed

tests/modules/programs/aerospace/aerospace-colemak.nix

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ config, pkgs, ... }:
2+
let
3+
hmPkgs = pkgs.extend (
4+
self: super: {
5+
aerospace = config.lib.test.mkStubPackage {
6+
name = "aerospace";
7+
buildScript = ''
8+
mkdir -p $out/bin
9+
touch $out/bin/aerospace
10+
chmod 755 $out/bin/aerospace
11+
'';
12+
};
13+
}
14+
);
15+
in
16+
{
17+
xdg.enable = false;
18+
19+
programs.aerospace = {
20+
enable = true;
21+
package = hmPkgs.aerospace;
22+
};
23+
24+
nmt.script = ''
25+
# aerospace just create the config file if we open it by hand, otherwise he's use directly the default config
26+
assertPathNotExists "home-files/.aerospace.toml"
27+
'';
28+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{ config, pkgs, ... }:
2+
let
3+
hmPkgs = pkgs.extend (
4+
self: super: {
5+
aerospace = config.lib.test.mkStubPackage {
6+
name = "aerospace";
7+
buildScript = ''
8+
mkdir -p $out/bin
9+
touch $out/bin/aerospace
10+
chmod 755 $out/bin/aerospace
11+
'';
12+
};
13+
}
14+
);
15+
in
16+
{
17+
xdg.enable = false;
18+
19+
programs.aerospace = {
20+
enable = true;
21+
package = hmPkgs.aerospace;
22+
23+
launchd.enable = true;
24+
25+
settings = {
26+
gaps = {
27+
outer.left = 8;
28+
outer.bottom = 8;
29+
outer.top = 8;
30+
outer.right = 8;
31+
};
32+
mode.main.binding = {
33+
alt-enter = ''
34+
exec-and-forget osascript -e '
35+
tell application "Terminal"
36+
do script
37+
activate
38+
end tell'
39+
'';
40+
alt-h = "focus left";
41+
alt-j = "focus down";
42+
alt-k = "focus up";
43+
alt-l = "focus right";
44+
};
45+
on-window-detected = [
46+
{
47+
"if".app-id = "com.apple.finder";
48+
run = "move-node-to-workspace 9";
49+
}
50+
51+
{
52+
"if" = {
53+
app-id = "com.apple.systempreferences";
54+
app-name-regex-substring = "settings";
55+
window-title-regex-substring = "substring";
56+
workspace = "workspace-name";
57+
during-aerospace-startup = true;
58+
};
59+
check-further-callbacks = true;
60+
run = [
61+
"layout floating"
62+
"move-node-to-workspace S"
63+
];
64+
}
65+
];
66+
};
67+
};
68+
69+
nmt.script = ''
70+
assertPathNotExists "home-files/.config/aerospace";
71+
assertFileExists "home-files/.aerospace.toml"
72+
assertFileContent "home-files/.aerospace.toml" ${./settings-expected.toml}
73+
74+
serviceFile=$(normalizeStorePaths LaunchAgents/org.nix-community.home.aerospace.plist)
75+
assertFileExists $serviceFile
76+
assertFileContent "$serviceFile" ${./aerospace-service-expected.plist}
77+
'';
78+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{ config, pkgs, ... }:
2+
let
3+
hmPkgs = pkgs.extend (
4+
self: super: {
5+
aerospace = config.lib.test.mkStubPackage {
6+
name = "aerospace";
7+
buildScript = ''
8+
mkdir -p $out/bin
9+
touch $out/bin/aerospace
10+
chmod 755 $out/bin/aerospace
11+
'';
12+
};
13+
}
14+
);
15+
in
16+
{
17+
xdg.enable = true;
18+
19+
programs.aerospace = {
20+
enable = true;
21+
package = hmPkgs.aerospace;
22+
23+
launchd.enable = true;
24+
25+
settings = {
26+
gaps = {
27+
outer.left = 8;
28+
outer.bottom = 8;
29+
outer.top = 8;
30+
outer.right = 8;
31+
};
32+
mode.main.binding = {
33+
alt-enter = ''
34+
exec-and-forget osascript -e '
35+
tell application "Terminal"
36+
do script
37+
activate
38+
end tell'
39+
'';
40+
alt-h = "focus left";
41+
alt-j = "focus down";
42+
alt-k = "focus up";
43+
alt-l = "focus right";
44+
};
45+
on-window-detected = [
46+
{
47+
"if".app-id = "com.apple.finder";
48+
run = "move-node-to-workspace 9";
49+
}
50+
51+
{
52+
"if" = {
53+
app-id = "com.apple.systempreferences";
54+
app-name-regex-substring = "settings";
55+
window-title-regex-substring = "substring";
56+
workspace = "workspace-name";
57+
during-aerospace-startup = true;
58+
};
59+
check-further-callbacks = true;
60+
run = [
61+
"layout floating"
62+
"move-node-to-workspace S"
63+
];
64+
}
65+
];
66+
};
67+
};
68+
69+
nmt.script = ''
70+
assertPathNotExists "home-files/.aerospace.toml";
71+
assertFileExists "home-files/.config/aerospace/aerospace.toml"
72+
assertFileContent "home-files/.config/aerospace/aerospace.toml" ${./settings-expected.toml}
73+
74+
serviceFile=$(normalizeStorePaths LaunchAgents/org.nix-community.home.aerospace.plist)
75+
assertFileExists $serviceFile
76+
assertFileContent "$serviceFile" ${./aerospace-service-expected.plist}
77+
'';
78+
}

tests/modules/programs/aerospace/aerospace.nix

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,15 @@ let
1414
);
1515
in
1616
{
17+
xdg.enable = true;
18+
1719
programs.aerospace = {
1820
enable = true;
1921
package = hmPkgs.aerospace;
20-
21-
launchd.enable = true;
22-
23-
userSettings = {
24-
gaps = {
25-
outer.left = 8;
26-
outer.bottom = 8;
27-
outer.top = 8;
28-
outer.right = 8;
29-
};
30-
mode.main.binding = {
31-
alt-h = "focus left";
32-
alt-j = "focus down";
33-
alt-k = "focus up";
34-
alt-l = "focus right";
35-
};
36-
};
3722
};
3823

3924
nmt.script = ''
40-
assertFileContent home-files/.config/aerospace/aerospace.toml ${./settings-expected.toml}
41-
42-
serviceFile=$(normalizeStorePaths LaunchAgents/org.nix-community.home.aerospace.plist)
43-
assertFileExists $serviceFile
44-
assertFileContent "$serviceFile" ${./aerospace-service-expected.plist}
25+
# aerospace just create the config file if we open it by hand, otherwise he's use directly the default config
26+
assertPathNotExists "home-files/.config/aerospace"
4527
'';
4628
}

tests/modules/programs/aerospace/colemak-settings-expected.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/modules/programs/aerospace/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
44
aerospace = ./aerospace.nix;
5-
aerospace-colemak = ./aerospace-colemak.nix;
5+
aerospace-no-xdg = ./aerospace-no-xdg.nix;
6+
aerospace-settings = ./aerospace-settings.nix;
7+
aerospace-settings-no-xdg = ./aerospace-settings-no-xdg.nix;
68
}

tests/modules/programs/aerospace/settings-expected.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,25 @@ right = 8
88
top = 8
99

1010
[mode.main.binding]
11+
alt-enter = "exec-and-forget osascript -e '\n tell application \"Terminal\"\n do script\n activate\n end tell'\n"
1112
alt-h = "focus left"
1213
alt-j = "focus down"
1314
alt-k = "focus up"
1415
alt-l = "focus right"
16+
17+
[[on-window-detected]]
18+
run = "move-node-to-workspace 9"
19+
20+
[on-window-detected.if]
21+
app-id = "com.apple.finder"
22+
23+
[[on-window-detected]]
24+
check-further-callbacks = true
25+
run = ["layout floating", "move-node-to-workspace S"]
26+
27+
[on-window-detected.if]
28+
app-id = "com.apple.systempreferences"
29+
app-name-regex-substring = "settings"
30+
during-aerospace-startup = true
31+
window-title-regex-substring = "substring"
32+
workspace = "workspace-name"

0 commit comments

Comments
 (0)