forgejo: create static gzip and brotli files

This commit is contained in:
Izorkin 2023-03-02 20:41:59 +03:00
parent 57a7270642
commit 6b9d81b953
No known key found for this signature in database
GPG Key ID: 1436C1B3F3679F09

View File

@ -1,9 +1,11 @@
{ bash { bash
, brotli
, buildGoModule , buildGoModule
, common-updater-scripts , common-updater-scripts
, coreutils , coreutils
, curl , curl
, fetchurl , fetchurl
, forgejo
, git , git
, gzip , gzip
, jq , jq
@ -15,6 +17,8 @@
, pam , pam
, pamSupport ? true , pamSupport ? true
, sqliteSupport ? true , sqliteSupport ? true
, xorg
, runCommand
, stdenv , stdenv
, writeShellApplication , writeShellApplication
}: }:
@ -66,9 +70,22 @@ buildGoModule rec {
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]} --prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
''; '';
passthru.tests = nixosTests.forgejo; passthru = {
data-compressed = runCommand "data-compressed" {
nativeBuildInputs = [ brotli xorg.lndir ];
} ''
mkdir $out
lndir ${forgejo.data}/ $out/
passthru.updateScript = lib.getExe (writeShellApplication { # Create static gzip and brotli files
find -L $out -type f -regextype posix-extended -iregex '.*\.(css|html|js|svg|ttf|txt)' \
-exec gzip --best --keep --force {} ';' \
-exec brotli --best --keep --no-copy-stat {} ';'
'';
tests = nixosTests.forgejo;
updateScript = lib.getExe (writeShellApplication {
name = "update-forgejo"; name = "update-forgejo";
runtimeInputs = [ runtimeInputs = [
common-updater-scripts common-updater-scripts
@ -106,6 +123,7 @@ buildGoModule rec {
update-source-version "${pname}" "$version" "$sri_hash" "$archive_url" update-source-version "${pname}" "$version" "$sri_hash" "$archive_url"
''; '';
}); });
};
meta = with lib; { meta = with lib; {
description = "A self-hosted lightweight software forge"; description = "A self-hosted lightweight software forge";