|
61 | 61 | // lib.optionalAttrs (cfg.database.type == "mysql") { |
62 | 62 | withMySQL = true; |
63 | 63 | } |
64 | | - // lib.optionalAttrs (lib.isAttrs cfg.minifyStaticFiles) ( |
65 | | - with cfg.minifyStaticFiles; |
66 | | - { |
67 | | - esbuild = esbuild.package; |
68 | | - lightningcss = lightningcss.package; |
69 | | - scour = scour.package; |
70 | | - } |
71 | | - ) |
72 | 64 | ); |
73 | 65 | in |
74 | 66 | p.overrideAttrs ( |
|
258 | 250 | }; |
259 | 251 |
|
260 | 252 | minifyStaticFiles = mkOption { |
261 | | - type = |
262 | | - with types; |
263 | | - either bool (submodule { |
| 253 | + type = types.either types.bool ( |
| 254 | + types.submodule { |
264 | 255 | options = { |
265 | 256 | script = mkOption { |
266 | 257 | type = types.submodule { |
267 | 258 | options = { |
268 | | - enable = mkEnableOption "Script minification"; |
269 | | - package = mkPackageOption pkgs "esbuild" { }; |
| 259 | + enable = mkEnableOption "Script minification via esbuild"; |
270 | 260 | target = mkOption { |
271 | | - type = with types; nullOr nonEmptyStr; |
| 261 | + type = types.nullOr types.nonEmptyStr; |
272 | 262 | default = null; |
| 263 | + description = '' |
| 264 | + esbuild target environment string. If not set, a sane |
| 265 | + default will be provided. See: |
| 266 | + <https://esbuild.github.io/api/#target>. |
| 267 | + ''; |
273 | 268 | }; |
274 | 269 | }; |
275 | 270 | }; |
276 | 271 | }; |
277 | 272 | style = mkOption { |
278 | 273 | type = types.submodule { |
279 | 274 | options = { |
280 | | - enable = mkEnableOption "Script minification"; |
281 | | - package = mkPackageOption pkgs "lightningcss" { }; |
| 275 | + enable = mkEnableOption "Script minification via Lightning CSS"; |
282 | 276 | target = mkOption { |
283 | | - type = with types; nullOr nonEmptyStr; |
| 277 | + type = types.nullOr types.nonEmptyStr; |
284 | 278 | default = null; |
| 279 | + description = '' |
| 280 | + Browserslists string target for browser compatibility. |
| 281 | + If not set, a sane default will be provided. See: |
| 282 | + <https://browsersl.ist>. |
| 283 | + ''; |
285 | 284 | }; |
286 | 285 | }; |
287 | 286 | }; |
288 | 287 | }; |
289 | 288 | svg = mkOption { |
290 | 289 | type = types.submodule { |
291 | 290 | options = { |
292 | | - enable = mkEnableOption "SVG minification"; |
293 | | - package = mkPackageOption pkgs "scour" { }; |
| 291 | + enable = mkEnableOption "SVG minification via Scour"; |
294 | 292 | }; |
295 | 293 | }; |
296 | 294 | }; |
297 | 295 | }; |
298 | | - }); |
| 296 | + } |
| 297 | + ); |
299 | 298 | default = true; |
300 | | - description = "Do minification on public static files"; |
| 299 | + description = '' |
| 300 | + Do minification on public static files which reduces the size of |
| 301 | + assets — saving data for the server & users as well as offering a |
| 302 | + performance improvement. This adds typing for the `minifyStaticFiles` |
| 303 | + attribute for the Movim package which *will* override any existing |
| 304 | + override value. The default `true` will enable minification for all |
| 305 | + supported asset types with sane defaults. |
| 306 | + ''; |
| 307 | + example = |
| 308 | + lib.literalExpression # nix |
| 309 | + '' |
| 310 | + { |
| 311 | + script.enable = false; |
| 312 | + style = { |
| 313 | + enable = true; |
| 314 | + target = "> 0.5%, last 2 versions, Firefox ESR, not dead"; |
| 315 | + }; |
| 316 | + svg.enable = true; |
| 317 | + } |
| 318 | + ''; |
301 | 319 | }; |
302 | 320 |
|
303 | 321 | precompressStaticFiles = mkOption { |
|
818 | 836 | }; |
819 | 837 | }; |
820 | 838 | }; |
| 839 | + |
| 840 | + imports = [ |
| 841 | + (lib.mkRemovedOptionModule [ "minifyStaticFiles" "script" "package" ] '' |
| 842 | + Override services.movim.package instead. |
| 843 | + '') |
| 844 | + (lib.mkRemovedOptionModule [ "minifyStaticFiles" "style" "package" ] '' |
| 845 | + Override services.movim.package instead. |
| 846 | + '') |
| 847 | + (lib.mkRemovedOptionModule [ "minifyStaticFiles" "svg" "package" ] '' |
| 848 | + Override services.movim.package instead. |
| 849 | + '') |
| 850 | + ]; |
821 | 851 | } |
0 commit comments