velocity: init at 3.4.0-unstable-2025-02-28

This commit is contained in:
Tert0
2025-02-28 16:55:49 +01:00
parent b5d0eb125c
commit 30f82d2e88
4 changed files with 1623 additions and 0 deletions
+1438
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,9 @@
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -28,4 +28,6 @@ subprojects {
}
}
}
+
+ tasks.withType<Javadoc>().configureEach { enabled = false }
}
@@ -0,0 +1,32 @@
--- a/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts
+++ b/build-logic/src/main/kotlin/velocity-init-manifest.gradle.kts
@@ -2,28 +2,9 @@ import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream
-val currentShortRevision = ByteArrayOutputStream().use {
- exec {
- executable = "git"
- args = listOf("rev-parse", "HEAD")
- standardOutput = it
- }
- it.toString().trim().substring(0, 8)
-}
-
tasks.withType<Jar> {
manifest {
- val buildNumber = System.getenv("BUILD_NUMBER")
- val velocityHumanVersion: String =
- if (project.version.toString().endsWith("-SNAPSHOT")) {
- if (buildNumber == null) {
- "${project.version} (git-$currentShortRevision)"
- } else {
- "${project.version} (git-$currentShortRevision-b$buildNumber)"
- }
- } else {
- archiveVersion.get()
- }
+ val velocityHumanVersion = System.getenv("BUILD_VERSION")
attributes["Implementation-Version"] = velocityHumanVersion
}
}
+144
View File
@@ -0,0 +1,144 @@
{
lib,
stdenv,
fetchFromGitHub,
gradle,
jdk17,
makeBinaryWrapper,
openssl,
libdeflate,
jre_headless,
writeScript,
nixosTests,
# native (openssl + libdeflate) compression and crypto implementations
withVelocityNative ? builtins.elem stdenv.hostPlatform.system [
"x86_64-linux"
"aarch64-linux"
],
}:
let
gradle_jdk17 = gradle.override {
javaToolchains = [ jdk17 ];
};
velocityNativePlatform =
{
x86_64-linux = "linux_x86_64";
aarch64-linux = "linux_aarch64";
}
.${stdenv.hostPlatform.system} or (
if withVelocityNative then
throw "velocity native is not supported on ${stdenv.hostPlatform.system}"
else
null
);
in
stdenv.mkDerivation (finalAttrs: {
pname = "velocity";
version = "3.4.0-unstable-2025-02-28";
src = fetchFromGitHub {
owner = "PaperMC";
repo = "Velocity";
rev = "b8fe3577c9582972a92134642e35eb7fac671376";
hash = "sha256-V+h2+M567niYmDWxT6hInbsVivL3pLp2pZO8D91kXkg=";
};
nativeBuildInputs =
[
gradle_jdk17
makeBinaryWrapper
]
++ lib.optionals withVelocityNative [
# libraries for velocity-native
openssl
libdeflate
# needed for building velocity-native jni
jdk17
];
mitmCache = gradle_jdk17.fetchDeps {
inherit (finalAttrs) pname;
data = ./deps.json;
};
patches = [
./fix-version.patch # remove build-time dependency on git and use version string from a env var instead
./disable-javadocs.patch # disable building java docs because they cause build failures
];
# tests require velocity native
doCheck = withVelocityNative;
postPatch = ''
rm -rf native/src/main/resources/{linux_x86_64,linux_aarch64,macos_aarch64}/*
'';
# based on native/build-support/compile-linux-{compress,crypt}.sh
preBuild =
let
CFLAGS = "-O2 -fPIC -shared -Wl,-z,noexecstack -Wall -Werror -fomit-frame-pointer";
in
lib.optionalString withVelocityNative ''
$CC ${CFLAGS} native/src/main/c/jni_util.c native/src/main/c/jni_cipher_openssl.c \
-o native/src/main/resources/${velocityNativePlatform}/velocity-cipher-ossl30x.so \
-lcrypto
$CC ${CFLAGS} native/src/main/c/jni_util.c native/src/main/c/jni_zlib_deflate.c native/src/main/c/jni_zlib_inflate.c \
-o native/src/main/resources/${velocityNativePlatform}/velocity-compress.so \
-ldeflate
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/velocity
cp proxy/build/libs/velocity-proxy-${builtins.head (builtins.split "-" finalAttrs.version)}-SNAPSHOT-all.jar $out/share/velocity/velocity.jar
makeWrapper ${lib.getExe jre_headless} "$out/bin/velocity" \
--append-flags "-jar $out/share/velocity/velocity.jar"
runHook postInstall
'';
env.BUILD_VERSION = "nixpkgs-${finalAttrs.version}";
passthru = {
updateScript = writeScript "update-velocity" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts
tmpdir="$(mktemp -d)"
git clone --depth=1 "${finalAttrs.src.gitRepoUrl}" "$tmpdir"
pushd "$tmpdir"
main_version=$(awk 'match($0,/version=([0-9.]+)/,r) { print r[1] }' gradle.properties)
commit_date=$(git show -s --pretty='format:%cs')
commit_hash=$(git show -s --pretty='format:%H')
popd
rm -rf "$tmpdir"
update-source-version "$UPDATE_NIX_ATTR_PATH" "$main_version-unstable-$commit_date" --rev="$commit_hash"
'';
tests.velocity = nixosTests.velocity;
};
meta = {
description = "Modern, next-generation Minecraft server proxy";
homepage = "https://papermc.io/software/velocity";
license = with lib.licenses; [
gpl3Only
mit
];
sourceProvenance = with lib.sourceTypes; [
fromSource
binaryBytecode # java deps
];
maintainers = with lib.maintainers; [ Tert0 ];
platforms = lib.platforms.linux;
mainProgram = "velocity";
};
})