2023-02-09 11:40:11 +00:00
|
|
|
{ bash
|
2023-03-24 00:07:29 +00:00
|
|
|
, brotli
|
2023-02-02 18:25:31 +00:00
|
|
|
, buildGoModule
|
2023-02-09 11:40:11 +00:00
|
|
|
, common-updater-scripts
|
|
|
|
, coreutils
|
|
|
|
, curl
|
2023-02-02 18:25:31 +00:00
|
|
|
, fetchurl
|
2023-03-24 00:07:29 +00:00
|
|
|
, forgejo
|
2023-02-02 18:25:31 +00:00
|
|
|
, git
|
|
|
|
, gzip
|
2023-02-09 11:40:11 +00:00
|
|
|
, jq
|
|
|
|
, lib
|
|
|
|
, makeWrapper
|
|
|
|
, nix
|
2023-03-04 12:14:45 +00:00
|
|
|
, nixosTests
|
2023-02-09 11:40:11 +00:00
|
|
|
, openssh
|
2023-02-02 18:25:31 +00:00
|
|
|
, pam
|
|
|
|
, pamSupport ? true
|
|
|
|
, sqliteSupport ? true
|
2023-03-24 00:07:29 +00:00
|
|
|
, xorg
|
|
|
|
, runCommand
|
2023-02-09 11:40:11 +00:00
|
|
|
, stdenv
|
|
|
|
, writeShellApplication
|
2023-02-02 18:25:31 +00:00
|
|
|
}:
|
2022-12-28 21:21:41 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
buildGoModule rec {
|
2022-12-28 21:21:41 +00:00
|
|
|
pname = "forgejo";
|
2023-03-24 00:07:29 +00:00
|
|
|
version = "1.19.0-2";
|
2022-12-28 21:21:41 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
name = "${pname}-src-${version}.tar.gz";
|
|
|
|
# see https://codeberg.org/forgejo/forgejo/releases
|
2023-03-24 00:07:29 +00:00
|
|
|
url = "https://codeberg.org/attachments/2bf497db-fa91-4260-9c98-5c791b6b397c";
|
|
|
|
hash = "sha256-neDIT+V3qHR8xgP4iy4TJQ6PCWO3svpSA7FLCacQSMI=";
|
2022-12-28 21:21:41 +00:00
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
vendorHash = null;
|
|
|
|
|
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
outputs = [ "out" "data" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = lib.optional pamSupport pam;
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./../gitea/static-root-path.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace modules/setting/setting.go --subst-var data
|
|
|
|
'';
|
|
|
|
|
|
|
|
tags = lib.optional pamSupport "pam"
|
|
|
|
++ lib.optionals sqliteSupport [ "sqlite" "sqlite_unlock_notify" ];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X main.Version=${version}"
|
|
|
|
"-X 'main.Tags=${lib.concatStringsSep " " tags}'"
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir $data
|
|
|
|
cp -R ./{public,templates,options} $data
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R ./options/locale $out/locale
|
|
|
|
wrapProgram $out/bin/gitea \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
|
2022-12-28 21:21:41 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru = {
|
|
|
|
data-compressed = runCommand "forgejo-data-compressed" {
|
|
|
|
nativeBuildInputs = [ brotli xorg.lndir ];
|
|
|
|
} ''
|
|
|
|
mkdir $out
|
|
|
|
lndir ${forgejo.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 {} ';'
|
2023-02-09 11:40:11 +00:00
|
|
|
'';
|
2023-03-24 00:07:29 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
2023-02-09 11:40:11 +00:00
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A self-hosted lightweight software forge";
|
|
|
|
homepage = "https://forgejo.org";
|
|
|
|
changelog = "https://codeberg.org/forgejo/forgejo/releases/tag/v${version}";
|
|
|
|
license = licenses.mit;
|
2023-02-09 11:40:11 +00:00
|
|
|
maintainers = with maintainers; [ indeednotjames urandom ];
|
2023-02-02 18:25:31 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2023-02-09 11:40:11 +00:00
|
|
|
mainProgram = "gitea";
|
2022-12-28 21:21:41 +00:00
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
}
|