velocity: init at 3.4.0-unstable-2025-02-28 (#384071)

This commit is contained in:
Sandro
2025-03-01 02:05:58 +01:00
committed by GitHub
6 changed files with 1692 additions and 0 deletions
+1
View File
@@ -1217,6 +1217,7 @@ in {
vault-postgresql = handleTest ./vault-postgresql.nix {};
vaultwarden = discoverTests (import ./vaultwarden.nix);
vector = handleTest ./vector {};
velocity = runTest ./velocity.nix;
vengi-tools = handleTest ./vengi-tools.nix {};
victoriametrics = handleTest ./victoriametrics {};
vikunja = handleTest ./vikunja.nix {};
+68
View File
@@ -0,0 +1,68 @@
{ lib, pkgs, ... }:
{
name = "velocity";
meta = {
platforms = [
"x86_64-linux"
"aarch64-linux"
];
maintainers = [ lib.maintainers.Tert0 ];
};
nodes.server =
{ ... }:
{
imports =
let
mkVelocityService = name: pkg: {
systemd.sockets.${name} = {
socketConfig = {
ListenFIFO = "/run/${name}.stdin";
Service = "${name}";
};
};
systemd.services.${name} = {
serviceConfig = {
ExecStart = "${pkg}/bin/velocity";
DynamicUser = true;
StateDirectory = "${name}";
WorkingDirectory = "/var/lib/${name}";
Sockets = "${name}.socket";
StandardInput = "socket";
StandardOutput = "journal";
StandardError = "journal";
};
};
};
in
[
(mkVelocityService "velocity-without-native" (
pkgs.velocity.override { withVelocityNative = false; }
))
(mkVelocityService "velocity-with-native" (pkgs.velocity.override { withVelocityNative = true; }))
];
environment.systemPackages = [ pkgs.mcstatus ];
};
testScript = ''
def test_velocity(name: str, native: bool):
server.start_job(name)
server.wait_for_unit(name);
server.wait_for_open_port(25565)
server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q 'Booting up Velocity nixpkgs-${pkgs.velocity.version}...'")
connections_startup_query = "Connections will use epoll channels, libdeflate (.+) compression, OpenSSL 3.x.x (.+) ciphers" if native else "Connections will use epoll channels, Java compression, Java ciphers"
server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q -E '{connections_startup_query}'")
server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q 'Done ([0-9]*.[0-9]*s)!'");
_, status_result = server.execute("mcstatus localhost:25565 status")
assert "A Velocity Server" in status_result
server.execute(f"echo stop > /run/{name}.stdin")
server.wait_for_closed_port(25565);
test_velocity("velocity-without-native", False)
test_velocity("velocity-with-native", True)
'';
}
+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";
};
})