Files
flake-hub/packages/gitea-projects-api.nix
T
Oleks 949f0d2153 gitea-projects-api: refresh to 1.26.0-unstable-2026-05-11
Pin to gitea fork rev 20f31b8967a4 (tag v1.26.0-unstable-2026-05-11).
Refreshed by nix-update via passthru.updateScript.
2026-05-12 00:02:46 +03:00

159 lines
3.6 KiB
Nix

{
lib,
buildGoModule,
fetchgit,
makeWrapper,
git,
bash,
coreutils,
gzip,
nodejs,
openssh,
fetchPnpmDeps,
pnpmConfigHook,
pnpm,
stdenv,
sqliteSupport ? true,
}:
# Custom Gitea built from oleks/gitea feat/projects-api — upstream PR #37518
# (Projects REST API) on top of upstream main.
#
# Mirrors the structure of nixpkgs' gitea derivation (frontend pnpm sub-drv
# + buildGoModule with go:embed of public/) but with our fork as src.
let
pname = "gitea-projects-api";
version = "1.26.0-unstable-2026-05-11";
src = fetchgit {
url = "https://git.oleks.space/oleks/gitea.git";
rev = "20f31b8967a4556fbdd32bc72c386d5a4c89bcc5";
hash = "sha256-Ws8I+q6Y8/X13C3uAAFLUUF+DHZRgFrsuo5XG2Cvyns=";
};
# Gitea's package.json requires pnpm >= 11; nixpkgs ships pnpm 10. The
# lockfile is v9 (forward-compatible), so strip the engine constraint and
# the packageManager preference before any pnpm tool sees the source.
# We only patch the source the frontend sees; the Go build doesn't care.
frontendSrc = stdenv.mkDerivation {
pname = "${pname}-frontend-src";
inherit version src;
dontConfigure = true;
dontBuild = true;
installPhase = ''
cp -R . $out
chmod -R +w $out
${nodejs}/bin/node -e '
const fs = require("fs");
const path = process.argv[1];
const pkg = JSON.parse(fs.readFileSync(path, "utf8"));
if (pkg.engines) delete pkg.engines.pnpm;
delete pkg.packageManager;
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + "\n");
' "$out/package.json"
'';
};
frontend = stdenv.mkDerivation (finalAttrs: {
pname = "${pname}-frontend";
inherit version;
src = frontendSrc;
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
fetcherVersion = 3;
hash = "sha256-Egehno2w8XyfaY+JVyVzTBlIwBpusgnMaObWNPTvh3M=";
};
nativeBuildInputs = [
nodejs
pnpmConfigHook
pnpm
];
buildPhase = ''
make frontend
'';
installPhase = ''
mkdir -p $out
cp -R public $out/
'';
});
in
buildGoModule {
inherit pname version src;
proxyVendor = true;
vendorHash = "sha256-TxLmmeMinazGmIx94iQvpsncWKXb+42ddZcxbwayVgk=";
outputs = [
"out"
"data"
];
subPackages = [ "." ];
nativeBuildInputs = [ makeWrapper ];
tags = lib.optionals sqliteSupport [
"sqlite"
"sqlite_unlock_notify"
];
ldflags = [
"-s"
"-w"
"-X main.Version=${version}"
"-X 'main.Tags=${
lib.concatStringsSep " " (
lib.optionals sqliteSupport [
"sqlite"
"sqlite_unlock_notify"
]
)
}'"
];
postInstall = ''
mkdir $data
ln -s ${frontend}/public $data/public
cp -R ./{templates,options} $data
mkdir -p $out
cp -R ./options/locale $out/locale
wrapProgram $out/bin/gitea \
--prefix PATH : ${
lib.makeBinPath [
bash
coreutils
git
gzip
openssh
]
}
'';
passthru = {
# Expose hashes nix-update needs to find when iterating.
inherit (frontend) pnpmDeps;
# Custom update flow: refresh hashes + retag the gitea fork + push.
# Invoke with `nix-update --use-update-script gitea-projects-api` or
# `just gitea-update` (which passes `--use-update-script`).
updateScript = ../scripts/update-gitea-projects-api.sh;
};
meta = {
description = "Gitea fork with Projects REST API (upstream PR #37518)";
homepage = "https://git.oleks.space/oleks/gitea";
license = lib.licenses.mit;
mainProgram = "gitea";
platforms = [
"x86_64-linux"
"aarch64-linux"
];
};
}