Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13725,6 +13725,12 @@
githubId = 34152449;
name = "Karl Hallsby";
};
karol-broda = {
email = "nix@karolbroda.com";
github = "karol-broda";
githubId = 122811026;
name = "Karol Broda";
};
karpfediem = {
name = "Karpfen";
github = "karpfediem";
Expand Down Expand Up @@ -15449,6 +15455,14 @@
githubId = 591860;
name = "Lionello Lunesu";
};
liquidnya = {
name = "Alice ✨🌙 Luna";
github = "liquidnya";
githubId = 7364785;
email = "alice@liquidnya.dev";
matrix = "@liquidnya:matrix.org";
keys = [ { fingerprint = "7C2D E075 FA93 D61C C9A7 876F 7966 C19E 32F9 EF06"; } ];
};
lisanna-dettwyler = {
email = "lisanna.dettwyler@gmail.com";
github = "lisanna-dettwyler";
Expand Down
170 changes: 170 additions & 0 deletions pkgs/by-name/hy/hytale-launcher/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
lib,
stdenv,
fetchzip,
buildFHSEnv,
makeWrapper,
makeDesktopItem,
writeScript,
gtk3,
nss,
libsecret,
libsoup_3,
gdk-pixbuf,
glib,
webkitgtk_4_1,
xdg-utils,
libGL,
alsa-lib,
udev,
libx11,
libxcursor,
libxrandr,
libxi,
icu,
openssl,
version ? null,
hytaleHashes ? null,
}:

let
sources = lib.importJSON ./pin.json;

finalVersion = if version != null then version else sources.version;
finalHytaleHashes = if hytaleHashes != null then hytaleHashes else sources.hashes;

# TODO: add icon once a stable versioned source is available
desktopItem = makeDesktopItem {
name = "hytale-launcher";
desktopName = "Hytale Launcher";
exec = "hytale-launcher";
comment = "Official launcher for Hytale";
categories = [ "Game" ];
terminal = false;
startupWMClass = "com.hypixel.HytaleLauncher";
};

os = if stdenv.hostPlatform.system == "x86_64-linux" then "linux" else "darwin";
arch = if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" else "arm64";

src = fetchzip {
url = "https://launcher.hytale.com/builds/release/${os}/${arch}/hytale-launcher-${finalVersion}.zip";
hash =
finalHytaleHashes.${stdenv.hostPlatform.system}
or (throw "unsupported system: ${stdenv.hostPlatform.system}");
stripRoot = false;
};

launcherRunScript = writeScript "hytale-launcher-run" ''
#!/bin/bash
LAUNCHER_DIR="$HOME/.local/share/Hytale/bin"
LAUNCHER_BIN="$LAUNCHER_DIR/hytale-launcher"
NIX_BIN="${src}/hytale-launcher"
NIX_STORE_PATH_FILE="$LAUNCHER_DIR/.nix-store-path"

if [[ ! -f "$LAUNCHER_BIN" ]] || [[ "$(cat "$NIX_STORE_PATH_FILE" 2>/dev/null)" != "$NIX_BIN" ]]; then
mkdir -p "$LAUNCHER_DIR"
cp "$NIX_BIN" "$LAUNCHER_BIN"
echo "$NIX_BIN" > "$NIX_STORE_PATH_FILE"
fi

exec "$LAUNCHER_BIN" "$@"
'';
Comment on lines +58 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice workaround for the auto updating problem :)
I think adding a comment about the launcher version being managed by Hytale instead of Nix would be great, or maybe even putting it in the long description.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for not using writeShellScript here?


fhsEnv = buildFHSEnv {
pname = "hytale-launcher";
version = finalVersion;

targetPkgs = pkgs: [
# launcher dependencies (webkit/tauri)
gtk3
nss
libsecret
libsoup_3
gdk-pixbuf
glib
webkitgtk_4_1
xdg-utils
# graphics
libGL
# audio
alsa-lib
# input/display
udev
libx11
libxcursor
libxrandr
libxi
# .NET runtime dependencies :(
icu
openssl
# misc
stdenv.cc.cc.lib
];

runScript = "${launcherRunScript}";

extraBwrapArgs = [
"--setenv __NV_DISABLE_EXPLICIT_SYNC 1"
"--setenv WEBKIT_DISABLE_DMABUF_RENDERER 1"
# taken from the flatpak at https://launcher.hytale.com/builds/release/linux/amd64/hytale-launcher-latest.flatpak
"--setenv WEBKIT_DISABLE_COMPOSITING_MODE 1"
"--setenv DESKTOP_STARTUP_ID com.hypixel.HytaleLauncher"
];

extraInstallCommands = ''
mkdir -p $out/share/applications
cp ${desktopItem}/share/applications/*.desktop $out/share/applications/
'';

passthru = {
inherit src;
updateScript = ./update.sh;
};

meta = {
description = "Official launcher for Hytale";
longDescription = ''
Official launcher for Hytale, an upcoming block-based game from Hypixel Studios.

Note: The launcher's built-in auto-update mechanism will not work on NixOS
due to the immutable nature of the Nix store. You may see an error message
about "failed to remove existing executable: read-only file system", this
is expected and the launcher will continue to work. Updates must be applied
by updating the nixpkgs package.
'';
homepage = "https://hytale.com";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [
gepbird
karol-broda
liquidnya
];
mainProgram = "hytale-launcher";
platforms = [
"x86_64-linux"
"aarch64-darwin"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
};

darwinPackage = stdenv.mkDerivation {
pname = "hytale-launcher";
version = finalVersion;
inherit src;

nativeBuildInputs = [ makeWrapper ];

installPhase = ''
runHook preInstall
mkdir -p "$out/Applications" "$out/bin"
cp -r hytale-launcher.app "$out/Applications/"
makeWrapper "$out/Applications/hytale-launcher.app/Contents/MacOS/hytale-launcher" "$out/bin/hytale-launcher"
runHook postInstall
'';

inherit (fhsEnv) passthru meta;
};
in
if stdenv.hostPlatform.isDarwin then darwinPackage else fhsEnv
7 changes: 7 additions & 0 deletions pkgs/by-name/hy/hytale-launcher/pin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "2026.03.24-a65f18c",
"hashes": {
"x86_64-linux": "sha256-pABTyxhUZe0pvrAnyYw5GCVBfr1xgJYc3uplZb3k8hk=",
"aarch64-darwin": "sha256-XacE+msmzwI3k7VLHnSk+2sujw1GKNFjdUx6eLzGJFU="
}
}
51 changes: 51 additions & 0 deletions pkgs/by-name/hy/hytale-launcher/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure -I nixpkgs=./. -i bash -p bash curl cacert jq nix nix-prefetch

launcherJson=$(curl -s https://launcher.hytale.com/version/release/launcher.json)

function launcherJq() {
echo "$launcherJson" | jq --raw-output "$@"
}

latestVersion=$(launcherJq '.version')
if [[ $latestVersion == "$UPDATE_NIX_OLD_VERSION" ]]; then
echo "package is up-to-date"
exit 0
fi

function selectUrlAndHash() {
local os="$1"
local arch="$2"
# shellcheck disable=SC2016
launcherJq --arg os "$os" --arg arch "$arch" '[.download_url[$os][$arch].url, .download_url[$os][$arch].sha256] | join(" ")'
}

function prefetch() {
nix store prefetch-file --json --hash-type sha256 "$@" | jq --raw-output '[.hash, .storePath] | join(" ")'
}

function fetchzipFile() {
local file="$1"
shift
# keep a reference to the store path to keep it in the sandbox
derivationArgs="{ src = builtins.storePath $(echo -n "$file" | jq -Rsa '.'); }"
nix-prefetch -I nixpkgs=./. --quiet fetchzip --url "file://$file" --derivationArgs --expr "$derivationArgs" "$@"
}

function update() {
local system="$1"
shift
read -r url expectedHash < <(selectUrlAndHash "$@")
read -r _zipHash zipPath < <(prefetch --expected-hash "$expectedHash" "$url")
hash=$(fetchzipFile "$zipPath" --no-stripRoot)

currentPin="$(dirname "${BASH_SOURCE[0]}")/pin.json"
newPin=$(mktemp)
jq --arg ver "$latestVersion" --arg sys "$system" --arg hash "$hash" \
'.version = $ver | .hashes[$sys] = $hash' \
"$currentPin" > "$newPin"
mv "$newPin" "$currentPin"
}

update "x86_64-linux" "linux" "amd64"
update "aarch64-darwin" "darwin" "arm64"
Loading