Skip to content

Commit 025225f

Browse files
authored
nixos/movim: fix minification options & document them (#388600)
2 parents 8515f6d + 5b820b6 commit 025225f

File tree

1 file changed

+51
-21
lines changed

1 file changed

+51
-21
lines changed

nixos/modules/services/web-apps/movim.nix

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ let
6161
// lib.optionalAttrs (cfg.database.type == "mysql") {
6262
withMySQL = true;
6363
}
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-
)
7264
);
7365
in
7466
p.overrideAttrs (
@@ -258,46 +250,72 @@ in
258250
};
259251

260252
minifyStaticFiles = mkOption {
261-
type =
262-
with types;
263-
either bool (submodule {
253+
type = types.either types.bool (
254+
types.submodule {
264255
options = {
265256
script = mkOption {
266257
type = types.submodule {
267258
options = {
268-
enable = mkEnableOption "Script minification";
269-
package = mkPackageOption pkgs "esbuild" { };
259+
enable = mkEnableOption "Script minification via esbuild";
270260
target = mkOption {
271-
type = with types; nullOr nonEmptyStr;
261+
type = types.nullOr types.nonEmptyStr;
272262
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+
'';
273268
};
274269
};
275270
};
276271
};
277272
style = mkOption {
278273
type = types.submodule {
279274
options = {
280-
enable = mkEnableOption "Script minification";
281-
package = mkPackageOption pkgs "lightningcss" { };
275+
enable = mkEnableOption "Script minification via Lightning CSS";
282276
target = mkOption {
283-
type = with types; nullOr nonEmptyStr;
277+
type = types.nullOr types.nonEmptyStr;
284278
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+
'';
285284
};
286285
};
287286
};
288287
};
289288
svg = mkOption {
290289
type = types.submodule {
291290
options = {
292-
enable = mkEnableOption "SVG minification";
293-
package = mkPackageOption pkgs "scour" { };
291+
enable = mkEnableOption "SVG minification via Scour";
294292
};
295293
};
296294
};
297295
};
298-
});
296+
}
297+
);
299298
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+
'';
301319
};
302320

303321
precompressStaticFiles = mkOption {
@@ -818,4 +836,16 @@ in
818836
};
819837
};
820838
};
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+
];
821851
}

0 commit comments

Comments
 (0)