gitea-projects-api: package fork carrying upstream PR #37518
Builds oleks/gitea feat/projects-api (Gitea 1.27.0-dev + Projects REST API) as `nix build .#gitea-projects-api`. Exposes `out` (binary) and `data` (templates, options, frontend bundle, locale files) matching the layout nixpkgs' `services.gitea` module expects. Notes: - Pins Go 1.26.3 (built from upstream src) because the fork's go.mod requires it, while pinned nixpkgs only has 1.26.0. - Patches package.json to drop engines.pnpm before fetchPnpmDeps runs: gitea wants pnpm >= 11, but nixpkgs only packages pnpm 10. The pnpm-lock.yaml is v9 (forward-compatible) so pnpm 10 produces the same install closure. - Platforms: x86_64-linux, aarch64-linux (skipped on s390x cross since the frontend pnpm step has no s390x toolchain).
This commit is contained in:
@@ -63,6 +63,25 @@
|
||||
};
|
||||
};
|
||||
}
|
||||
# Native-only packages — skip on s390x cross (gitea's pnpm step and
|
||||
# cgo+sqlite link don't cross-compile cleanly).
|
||||
// nixpkgs.lib.optionalAttrs (sys == "x86_64-linux" || sys == "aarch64-linux") {
|
||||
gitea-projects-api =
|
||||
let
|
||||
# Our fork's go.mod requires Go 1.26.3; nixpkgs at this pin has
|
||||
# only 1.26.0 (and unstable has 1.26.2). Bump the package's src.
|
||||
go = pkgs.go_1_26.overrideAttrs (_: rec {
|
||||
version = "1.26.3";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://go.dev/dl/go${version}.src.tar.gz";
|
||||
hash = "sha256-HGRoddCqh5kTMYTtV895/yS97+jIggRwYCqdPW2Rkrg=";
|
||||
};
|
||||
});
|
||||
in
|
||||
pkgs.callPackage ./packages/gitea-projects-api.nix {
|
||||
buildGoModule = pkgs.buildGoModule.override { inherit go; };
|
||||
};
|
||||
}
|
||||
# Xontribs: pass into `programs.xonsh.extraPackages` or
|
||||
# `pkgs.xonsh.override { extraPackages = ps: [...]; }`.
|
||||
// xontribs
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
{
|
||||
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.27.0-dev-projects-api";
|
||||
|
||||
rawSrc = 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.
|
||||
src = stdenv.mkDerivation {
|
||||
pname = "${pname}-src";
|
||||
inherit version;
|
||||
src = rawSrc;
|
||||
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;
|
||||
|
||||
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
|
||||
]
|
||||
}
|
||||
'';
|
||||
|
||||
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"
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user