~aasg/nixexprs

30ebec15183581a33bd0af48cbbcc082a8b35966 — Aluísio Augusto Silva Gonçalves 16 days ago 7837087
aasg-brotlify: New hook to auto-compress static websites

aasgBrotlifyHook can be passed in a derivation's `nativeBuildInputs`
to compress all HTML, CSS, and JS files in the output (as well as the
corrresponding source maps) with Brotli.  It is expected to be used by
packages that are or contain websites.
M flake.nix => flake.nix +1 -1
@@ 24,7 24,7 @@
          # Flatten package sets.
          flattenTree
          # Remove packages not compatible with this system.
          (filterAttrs (attr: drv: builtins.elem system drv.meta.platforms))
          (filterAttrs (attr: drv: drv ? meta.platforms -> builtins.elem system drv.meta.platforms))
        ]);
      nixosModules = mapAttrs (name: path: import path) (import ./modules);
      overlays = {

A pkgs/build-support/aasg-brotlify/default.nix => pkgs/build-support/aasg-brotlify/default.nix +2 -0
@@ 0,0 1,2 @@
{ makeSetupHook, brotli, fd }:
(makeSetupHook { name = "brotlify-setup-hook.sh"; deps = [ brotli fd ]; }) ./setup-hook.sh

A pkgs/build-support/aasg-brotlify/setup-hook.sh => pkgs/build-support/aasg-brotlify/setup-hook.sh +6 -0
@@ 0,0 1,6 @@
postInstallHooks+=(aasg-brotlify)

aasg-brotlify() {
	if [[ -n "${dontBrotlify:-}" ]]; then return; fi
	fd "" "$out" -t f -e html -e css -e js -e css.map -e js.map -X brotli --best
}

M pkgs/manifest.nix => pkgs/manifest.nix +1 -0
@@ 1,4 1,5 @@
[
  [ "aasgBrotlifyHook" ]
  [ "dma" ]
  [ "drep" ]
  [ "dyndnsc" ]

M pkgs/overlay.nix => pkgs/overlay.nix +2 -0
@@ 2,6 2,8 @@ final: prev:

{

  aasgBrotlifyHook = final.callPackage ./build-support/aasg-brotlify { };

  dma = final.callPackage ./tools/networking/dma { };

  drep = final.callPackage ./tools/text/drep {