Skip to content

Commit 662dd8a

Browse files
committed
stylix/testbed/modules/application: allow re-running test code
Allow re-running test code via deskop items and stylix-testbed-${name} CLIs.
1 parent dc4a88d commit 662dd8a

File tree

1 file changed

+60
-34
lines changed

1 file changed

+60
-34
lines changed

stylix/testbed/modules/application.nix

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -99,46 +99,72 @@ in
9999
user = user.username;
100100
};
101101

102-
# for use when application is set
103102
environment.systemPackages =
104-
lib.optional (config.stylix.testbed.ui.command != null) (
105-
pkgs.makeAutostartItem {
106-
name = "stylix-testbed";
107-
package = pkgs.makeDesktopItem {
108-
name = "stylix-testbed";
109-
desktopName = "stylix-testbed";
110-
exec = toString (
111-
pkgs.writeShellScript "startup" config.stylix.testbed.ui.command.text
112-
);
103+
builtins.concatMap
104+
(
105+
{
106+
condition,
107+
name,
108+
text,
109+
packages ? [ ],
110+
terminal ? false,
111+
}:
112+
let
113+
application = pkgs.writeShellApplication {
114+
inherit text;
115+
116+
name = name';
117+
runtimeInputs = packages;
118+
};
119+
120+
autostartItem = pkgs.makeAutostartItem {
121+
name = name';
122+
package = desktopItem;
123+
};
124+
125+
desktopItem = pkgs.makeDesktopItem {
126+
inherit terminal;
127+
128+
desktopName = name';
129+
exec = lib.getExe application;
130+
name = name';
131+
};
132+
133+
name' = "stylix-testbed-${name}";
134+
in
135+
lib.optionals condition [
136+
application
137+
autostartItem
138+
desktopItem
139+
]
140+
)
141+
[
142+
{
143+
inherit (config.stylix.testbed.ui.command) text;
144+
145+
condition = config.stylix.testbed.ui.command != null;
146+
name = "command";
113147
terminal = config.stylix.testbed.ui.command.useTerminal;
114-
};
115-
}
116-
)
117-
++ lib.optional config.stylix.testbed.ui.sendNotifications (
118-
pkgs.makeAutostartItem {
119-
name = "stylix-notification-check";
120-
package = pkgs.makeDesktopItem {
121-
name = "stylix-notification-check";
122-
desktopName = "stylix-notification-check";
123-
terminal = false;
124-
exec = pkgs.writeShellScript "stylix-send-notifications" (
148+
}
149+
{
150+
condition = config.stylix.testbed.ui.sendNotifications;
151+
name = "notification";
152+
packages = [ pkgs.libnotify ];
153+
154+
text =
125155
lib.concatMapStringsSep " && "
126-
(
127-
urgency: "${lib.getExe pkgs.libnotify} --urgency ${urgency} ${urgency} urgency"
128-
)
156+
(urgency: "notify-send --urgency ${urgency} ${urgency} urgency")
129157
[
130158
"low"
131159
"normal"
132160
"critical"
133-
]
134-
);
135-
};
136-
}
137-
)
138-
++ lib.optional (config.stylix.testbed.ui.application != null) (
139-
pkgs.makeAutostartItem {
140-
inherit (config.stylix.testbed.ui.application) name package;
141-
}
142-
);
161+
];
162+
}
163+
{
164+
condition = config.stylix.testbed.ui.application != null;
165+
name = "application";
166+
text = lib.getExe config.stylix.testbed.ui.application.package;
167+
}
168+
];
143169
};
144170
}

0 commit comments

Comments
 (0)