This commit is contained in:
@@ -191,6 +191,7 @@ in {
|
||||
in {
|
||||
inherit affine;
|
||||
affine-frontend-static = affine.frontendStatic;
|
||||
horizon = pkgs.callPackage ./horizon {};
|
||||
}) // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
with-attic-cache = pkgs.callPackage ./with-attic-cache {};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
{
|
||||
autoPatchelfHook,
|
||||
coreutils,
|
||||
fetchurl,
|
||||
lib,
|
||||
runtimeShell,
|
||||
stdenv,
|
||||
stdenvNoCC,
|
||||
}:
|
||||
let
|
||||
version = "nightly-2026-11-01";
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "horizon";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/horizon-rust/horizon/releases/download/${version}/horizon-server-linux-x86_64.tar.gz";
|
||||
hash = "sha256-xF7PQAoR6FBRWXq4YBFRin9oSE3X97gOffxXGdGcrVs=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ autoPatchelfHook ];
|
||||
buildInputs = [ stdenv.cc.cc.lib ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p \
|
||||
"$out/bin" \
|
||||
"$out/libexec/horizon" \
|
||||
"$out/share/horizon/prepare-root/mods/horizon/src/test/java/dev/horizonlab" \
|
||||
"$out/share/licenses/horizon"
|
||||
install -m 0755 horizon-server horizon-engine horizon-prepare "$out/libexec/horizon/"
|
||||
install -m 0644 LICENSE "$out/share/licenses/horizon/LICENSE"
|
||||
install -m 0644 research-lock.json "$out/share/horizon/prepare-root/research-lock.json"
|
||||
cp -R exporters "$out/share/horizon/prepare-root/exporters"
|
||||
cp -R \
|
||||
mods/horizon/src/test/java/dev/horizonlab/parity \
|
||||
"$out/share/horizon/prepare-root/mods/horizon/src/test/java/dev/horizonlab/parity"
|
||||
for binary in horizon-server horizon-engine; do
|
||||
ln -s "$out/libexec/horizon/$binary" "$out/bin/$binary"
|
||||
done
|
||||
cat > "$out/bin/horizon-prepare" <<'EOF'
|
||||
#!${runtimeShell}
|
||||
set -eu
|
||||
|
||||
executable=$(${coreutils}/bin/readlink -f "$0")
|
||||
package_root=$(${coreutils}/bin/dirname "$executable")
|
||||
package_root=$(${coreutils}/bin/dirname "$package_root")
|
||||
support_root="$package_root/share/horizon/prepare-root"
|
||||
preparer="$package_root/libexec/horizon/horizon-prepare"
|
||||
root=""
|
||||
saw_root=false
|
||||
want_root=false
|
||||
|
||||
for argument do
|
||||
case "$argument" in
|
||||
-h|--help|-V|--version)
|
||||
exec "$preparer" "$@"
|
||||
;;
|
||||
esac
|
||||
if "$want_root"; then
|
||||
root=$argument
|
||||
want_root=false
|
||||
continue
|
||||
fi
|
||||
case "$argument" in
|
||||
--root)
|
||||
saw_root=true
|
||||
want_root=true
|
||||
;;
|
||||
--root=*)
|
||||
saw_root=true
|
||||
root=''${argument#--root=}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if "$want_root" || { "$saw_root" && [ -z "$root" ]; }; then
|
||||
exec "$preparer" "$@"
|
||||
fi
|
||||
if ! "$saw_root"; then
|
||||
cache_home=''${XDG_CACHE_HOME:-''${HOME:?HOME is unset}/.cache}
|
||||
root="$cache_home/horizon/prepare-root-${version}"
|
||||
set -- --root "$root" "$@"
|
||||
fi
|
||||
|
||||
marker="$root/.hearth-${version}"
|
||||
if [ ! -f "$marker" ]; then
|
||||
${coreutils}/bin/mkdir -p "$root"
|
||||
${coreutils}/bin/cp -R "$support_root/." "$root/"
|
||||
${coreutils}/bin/chmod -R u+w \
|
||||
"$root/research-lock.json" "$root/exporters" "$root/mods"
|
||||
${coreutils}/bin/touch "$marker"
|
||||
fi
|
||||
exec "$preparer" "$@"
|
||||
EOF
|
||||
chmod 0755 "$out/bin/horizon-prepare"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
"$out/bin/horizon-server" --help >/dev/null
|
||||
"$out/bin/horizon-server" --version | grep -F '${version}' >/dev/null
|
||||
"$out/bin/horizon-engine" --help >/dev/null
|
||||
"$out/bin/horizon-prepare" --help >/dev/null
|
||||
"$out/bin/horizon-prepare" --version | grep -F '${version}' >/dev/null
|
||||
test -f "$out/share/horizon/prepare-root/research-lock.json"
|
||||
test -f "$out/share/horizon/prepare-root/exporters/manifest.json"
|
||||
test -f "$out/share/horizon/prepare-root/mods/horizon/src/test/java/dev/horizonlab/parity/PrepareWorker.java"
|
||||
|
||||
set +e
|
||||
check_output=$(XDG_CACHE_HOME="$TMPDIR/cache" \
|
||||
"$out/bin/horizon-prepare" --check --output "$TMPDIR/missing" 2>&1)
|
||||
check_status=$?
|
||||
set -e
|
||||
test "$check_status" -eq 1
|
||||
printf '%s\n' "$check_output" | grep -F 'is not prepared: horizon-prepare --prepare' >/dev/null
|
||||
test -f "$TMPDIR/cache/horizon/prepare-root-${version}/research-lock.json"
|
||||
|
||||
set +e
|
||||
check_output=$("$out/bin/horizon-prepare" \
|
||||
--root "$TMPDIR/custom-root" --check --output "$TMPDIR/missing" 2>&1)
|
||||
check_status=$?
|
||||
set -e
|
||||
test "$check_status" -eq 1
|
||||
printf '%s\n' "$check_output" | grep -F 'is not prepared: horizon-prepare --prepare' >/dev/null
|
||||
test -f "$TMPDIR/custom-root/exporters/manifest.json"
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
passthru.sourceRevision = "4aa6854a886183440256f4f4a4a9d1ed853227a1";
|
||||
|
||||
meta = {
|
||||
description = "Native Horizon server for Minecraft Java Edition 26.3";
|
||||
homepage = "https://github.com/horizon-rust/horizon";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "horizon-server";
|
||||
platforms = [ "x86_64-linux" ];
|
||||
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user