Merge pull request #218171 from Izorkin/update-gitea-static
gitea/forgejo: create static gzip and brotli files
This commit is contained in:
commit
36cf3d89f7
|
@ -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,46 +70,60 @@ 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 "forgejo-data-compressed" {
|
||||||
|
nativeBuildInputs = [ brotli xorg.lndir ];
|
||||||
|
} ''
|
||||||
|
mkdir $out
|
||||||
|
lndir ${forgejo.data}/ $out/
|
||||||
|
|
||||||
passthru.updateScript = lib.getExe (writeShellApplication {
|
# Create static gzip and brotli files
|
||||||
name = "update-forgejo";
|
find -L $out -type f -regextype posix-extended -iregex '.*\.(css|html|js|svg|ttf|txt)' \
|
||||||
runtimeInputs = [
|
-exec gzip --best --keep --force {} ';' \
|
||||||
common-updater-scripts
|
-exec brotli --best --keep --no-copy-stat {} ';'
|
||||||
coreutils
|
|
||||||
curl
|
|
||||||
jq
|
|
||||||
nix
|
|
||||||
];
|
|
||||||
text = ''
|
|
||||||
releases=$(curl "https://codeberg.org/api/v1/repos/forgejo/forgejo/releases?draft=false&pre-release=false&limit=1" \
|
|
||||||
--silent \
|
|
||||||
--header "accept: application/json")
|
|
||||||
|
|
||||||
stable=$(jq '.[0]
|
|
||||||
| .tag_name[1:] as $version
|
|
||||||
| ("forgejo-src-\($version).tar.gz") as $filename
|
|
||||||
| { $version, html_url } + (.assets | map(select(.name | startswith($filename)) | {(.name | split(".") | last): .browser_download_url}) | add)' \
|
|
||||||
<<< "$releases")
|
|
||||||
|
|
||||||
archive_url=$(jq -r .gz <<< "$stable")
|
|
||||||
checksum_url=$(jq -r .sha256 <<< "$stable")
|
|
||||||
release_url=$(jq -r .html_url <<< "$stable")
|
|
||||||
version=$(jq -r .version <<< "$stable")
|
|
||||||
|
|
||||||
if [[ "${version}" = "$version" ]]; then
|
|
||||||
echo "No new version found (already at $version)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Release: $release_url"
|
|
||||||
|
|
||||||
sha256=$(curl "$checksum_url" --silent | cut --delimiter " " --fields 1)
|
|
||||||
sri_hash=$(nix hash to-sri --type sha256 "$sha256")
|
|
||||||
|
|
||||||
update-source-version "${pname}" "$version" "$sri_hash" "$archive_url"
|
|
||||||
'';
|
'';
|
||||||
});
|
|
||||||
|
tests = nixosTests.forgejo;
|
||||||
|
|
||||||
|
updateScript = lib.getExe (writeShellApplication {
|
||||||
|
name = "update-forgejo";
|
||||||
|
runtimeInputs = [
|
||||||
|
common-updater-scripts
|
||||||
|
coreutils
|
||||||
|
curl
|
||||||
|
jq
|
||||||
|
nix
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
releases=$(curl "https://codeberg.org/api/v1/repos/forgejo/forgejo/releases?draft=false&pre-release=false&limit=1" \
|
||||||
|
--silent \
|
||||||
|
--header "accept: application/json")
|
||||||
|
|
||||||
|
stable=$(jq '.[0]
|
||||||
|
| .tag_name[1:] as $version
|
||||||
|
| ("forgejo-src-\($version).tar.gz") as $filename
|
||||||
|
| { $version, html_url } + (.assets | map(select(.name | startswith($filename)) | {(.name | split(".") | last): .browser_download_url}) | add)' \
|
||||||
|
<<< "$releases")
|
||||||
|
|
||||||
|
archive_url=$(jq -r .gz <<< "$stable")
|
||||||
|
checksum_url=$(jq -r .sha256 <<< "$stable")
|
||||||
|
release_url=$(jq -r .html_url <<< "$stable")
|
||||||
|
version=$(jq -r .version <<< "$stable")
|
||||||
|
|
||||||
|
if [[ "${version}" = "$version" ]]; then
|
||||||
|
echo "No new version found (already at $version)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release: $release_url"
|
||||||
|
|
||||||
|
sha256=$(curl "$checksum_url" --silent | cut --delimiter " " --fields 1)
|
||||||
|
sri_hash=$(nix hash to-sri --type sha256 "$sha256")
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
|
@ -5,11 +5,15 @@
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, git
|
, git
|
||||||
, bash
|
, bash
|
||||||
|
, gitea
|
||||||
, gzip
|
, gzip
|
||||||
, openssh
|
, openssh
|
||||||
, pam
|
, pam
|
||||||
, sqliteSupport ? true
|
, sqliteSupport ? true
|
||||||
, pamSupport ? true
|
, pamSupport ? true
|
||||||
|
, runCommand
|
||||||
|
, brotli
|
||||||
|
, xorg
|
||||||
, nixosTests
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -61,7 +65,21 @@ buildGoModule rec {
|
||||||
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
--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; {
|
meta = with lib; {
|
||||||
description = "Git with a cup of tea";
|
description = "Git with a cup of tea";
|
||||||
|
|
Loading…
Reference in a new issue