|
99 | 99 | user = user.username;
|
100 | 100 | };
|
101 | 101 |
|
102 |
| - # for use when application is set |
103 | 102 | 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"; |
113 | 147 | 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 = |
125 | 155 | lib.concatMapStringsSep " && "
|
126 |
| - ( |
127 |
| - urgency: "${lib.getExe pkgs.libnotify} --urgency ${urgency} ${urgency} urgency" |
128 |
| - ) |
| 156 | + (urgency: "notify-send --urgency ${urgency} ${urgency} urgency") |
129 | 157 | [
|
130 | 158 | "low"
|
131 | 159 | "normal"
|
132 | 160 | "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 | + ]; |
143 | 169 | };
|
144 | 170 | }
|
0 commit comments