Skip to content

Instantly share code, notes, and snippets.

@lboklin
Last active January 15, 2022 19:23
Show Gist options
  • Save lboklin/1cd8cd242eed80c941243caa408d0aa6 to your computer and use it in GitHub Desktop.
Save lboklin/1cd8cd242eed80c941243caa408d0aa6 to your computer and use it in GitHub Desktop.
Alderon Games Launcher/Path of Titans on NixOS
{ stdenv, shellcheck, appimage-run, writeShellApplication, vulkan-loader, vulkan-tools, fetchurl, curl }:
let
version = "1.1.68";
name = "alderon-games-launcher-${version}";
launcher = fetchurl {
inherit name;
url = "https://launcher-cdn.alderongames.com/AlderonGamesLauncher-${version}.AppImage";
sha256 = "sha256-eFHFsFy7ieHws/aDlFBGAQrMB67zWL46I4oYfhbF0U4=";
};
in writeShellApplication {
inherit name;
runtimeInputs = [
vulkan-loader
vulkan-tools
(curl.override { gnutlsSupport = false; opensslSupport = true; })
];
checkPhase = ''
runHook preCheck
${stdenv.shell} -n $out/bin/${name}
# ignore 'name is referenced but not assigned'
${shellcheck}/bin/shellcheck -e SC2154 $out/bin/${name}
runHook postCheck
'';
text = ''
# All of this is just to fix a problem that prevents choosing install directory
# Adapted from https://github.com/NixOS/nixpkgs/issues/72282#issuecomment-550208152
set -e
gsettings_schemas_path=""
gtk_path=""
for requisite in $(nix-store --query --requisites --quiet --quiet "$(which ${appimage-run}/bin/appimage-run)"); do
if [[ -z $gsettings_schemas_path ]]; then
R=$(echo "$requisite" | grep gsettings-desktop-schemas || echo "" | head -n1)
if [[ -n $R ]]; then
gsettings_schemas_path=$R
fi
unset R
fi
if [[ -z $gtk_path ]]; then
R=$(echo "$requisite" | grep gtk+3 || echo "" | head -n1)
if [[ -n $R ]]; then
gtk_path=$R
fi
unset R
fi
done
if [[ -z $gsettings_schemas_path ]]; then echo "No \$gsettings_schemas_path"; exit 1; fi
if [[ -z $gtk_path ]]; then echo "No \$gtk_path"; exit 1; fi
eval "$(nix-store --print-env "$(nix-store -qd "$gsettings_schemas_path")" | grep "export name" | head -n1)"
gsettings_schemas_name=$name
unset name
eval "$(nix-store --print-env "$(nix-store -qd "$gtk_path")" | grep "export name" | head -n1)"
gtk_name=$name
unset name
export XDG_DATA_DIRS=$gsettings_schemas_path/share/gsettings-schemas/$gsettings_schemas_name:$gtk_path/share/gsettings-schemas/$gtk_name:$XDG_DATA_DIRS
unset gsettings_schemas_path
unset gtk_path
unset gsettings_schemas_name
unset gtk_name
${appimage-run}/bin/appimage-run ${launcher}
'';
}
{ appimageTools, fetchurl }:
let
version = "1.1.68";
name = "alderon-games-launcher-${version}";
in appimageTools.wrapType1 {
inherit name;
src = fetchurl {
inherit name;
url = "https://launcher-cdn.alderongames.com/AlderonGamesLauncher-${version}.AppImage";
sha256 = "sha256-eFHFsFy7ieHws/aDlFBGAQrMB67zWL46I4oYfhbF0U4=";
};
extraPkgs = pkgs: with pkgs; [
(curl.override { gnutlsSupport = false; opensslSupport = true; })
vulkan-loader
vulkan-tools
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment