Merge pull request #218171 from Izorkin/update-gitea-static

gitea/forgejo: create static gzip and brotli files
This commit is contained in:
Maximilian Bosch 2023-03-20 23:35:17 +01:00 committed by GitHub
commit 36cf3d89f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 39 deletions

View file

@ -1,9 +1,11 @@
{ bash
, brotli
, buildGoModule
, common-updater-scripts
, coreutils
, curl
, fetchurl
, forgejo
, git
, gzip
, jq
@ -15,6 +17,8 @@
, pam
, pamSupport ? true
, sqliteSupport ? true
, xorg
, runCommand
, stdenv
, writeShellApplication
}:
@ -66,9 +70,22 @@ buildGoModule rec {
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
'';
passthru.tests = nixosTests.forgejo;
passthru = {
data-compressed = runCommand "forgejo-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";
runtimeInputs = [
common-updater-scripts
@ -106,6 +123,7 @@ buildGoModule rec {
update-source-version "${pname}" "$version" "$sri_hash" "$archive_url"
'';
});
};
meta = with lib; {
description = "A self-hosted lightweight software forge";

View file

@ -5,11 +5,15 @@
, makeWrapper
, git
, bash
, gitea
, gzip
, openssh
, pam
, sqliteSupport ? true
, pamSupport ? true
, runCommand
, brotli
, xorg
, nixosTests
}:
@ -61,7 +65,21 @@ buildGoModule rec {
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
'';
passthru.tests = nixosTests.gitea;
passthru = {
data-compressed = runCommand "gitea-data-compressed" {
nativeBuildInputs = [ brotli xorg.lndir ];
} ''
mkdir $out
lndir ${gitea.data}/ $out/
# 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.gitea;
};
meta = with lib; {
description = "Git with a cup of tea";