Skip to content

Commit

Permalink
olympus: init at 24.11.23.03
Browse files Browse the repository at this point in the history
This is an attempt to package [Olympus](https://everestapi.github.io/), a GUI for installing Everest and managing Celeste mods.
This is based on this [draft](NixOS#295258), with the authors permission.

It maintains the previous issue of not being able to launch Steam
versions of Celeste from the command line but that's not feasible
without upstream changes.

I only have to note that it has a popup complaining about
finishing the installation but that's due to xdg-mime
x-scheme-handler/everest not being set.

Finally I want to note that it depends on lua51Packages.nfd, which
is broken while [this](NixOS#309026)
isn't merged so currently has the fix there.

Finally, [Lönn](https://github.com/CelestialCartographers/Loenn) works
as expected, being the installation managed by the program.

Ahorn is deprecated(in favor of Loenn) and it crashes over trying to run dynamic
executables

olympus: fixed zenity argument

olympus: bugfix add openssl to fhs

olympus: fixed to use the default nfd instead of patched version

olympus: changed location of ndf arg

olympus: bugfix: add xdg-utils as runtime dependency to fix pop-up

olympus: deleted zenity.patch

Due to nfd lua package being fixed, this patch is no longer needed

olympus: fix use of wrong nfd package

olympus: bumped up version to 24.07.06.02

olympus: format files with nixfmt-rfc

olympus: chores: comments, fixed lib conventions

olympus: make wrappers properly, use standard build process, misc fixes

olympus: update version, src; add updateScript

olympus: avoid rec; use lib.getExe; remove redundant .out; minor changes

olympus: use standard build process for dotnet; remove -nixos suffix in version; use new mono; add dotnet-runtime to fhs env

olympus: 24.10.27.02 -> 24.11.23.01; fix version.txt; remove unnecessary dependencies; add miniinstaller and celeste wrapper; other misc change
olympus-with-steam-run: init

olympus: more flexible celeste wrapper

olympus: accept emptry string and path as celeste wrapper; minor fix with lua cpath

olympus: minor fix with lua cpath; add xdg-utils to path

olympus: use standard lua-subprocess instead of fork

olympus: make MiniInstaller be properly wrapped

olympus: add option to skip handler

olympus: tweaked platforms, tweaked miniinstaller-fhs

olympus-with-steam-run: comment for reminder on fixing issues with
relative paths

olympus: removed extraneous package

olympus: add extra wrapper options for mininstaller and loenn

olympus: add more explicit comments, bump version

olympus: fixed mismatched hash in olympus

olympus: changed proprieties of miniinstaller-fhs (NixOS#336576)

olympus: tweak miniinstallerWrapper

olympus: migrated to deps.json (NixOS#362278)

olympus: remove meta.mainProgram explicitly (NixOS#358550)
  • Loading branch information
Petingoso committed Dec 28, 2024
1 parent 682408e commit ba83043
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkgs/by-name/ol/olympus/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 171 additions & 0 deletions pkgs/by-name/ol/olympus/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
lib,
fetchFromGitHub,
fetchzip,
buildFHSEnv,
buildDotnetModule,
luajitPackages,
sqlite,
libarchive,
curl,
mono,
love,
xdg-utils,
writeShellScript,
# These need overriding if you launch Celeste/Loenn/MiniInstaller from Olympus.
# Some examples:
# - null: Use default wrapper.
# - "": Do not use wrapper.
# - steam-run: Use steam-run.
# - "steam-run": Use steam-run command available from PATH.
# - writeShellScriptBin { ... }: Use a custom script.
# - ./my-wrapper.sh: Use a custom script.
# In any case, it can be overridden at runtime by OLYMPUS_{CELESTE,LOENN,MINIINSTALLER}_WRAPPER.
celesteWrapper ? null,
loennWrapper ? null,
miniinstallerWrapper ? null,
skipHandlerCheck ? false, # whether to skip olympus xdg-mime check, true will override it
}:

let
lua_cpath =
with luajitPackages;
lib.concatMapStringsSep ";" getLuaCPath [
(buildLuarocksPackage {
pname = "lsqlite3";
version = "0.9.6-1";
src = fetchzip {
url = "http://lua.sqlite.org/index.cgi/zip/lsqlite3_v096.zip";
hash = "sha256-Mq409A3X9/OS7IPI/KlULR6ZihqnYKk/mS/W/2yrGBg=";
};
buildInputs = [ sqlite.dev ];
})

lua-subprocess
nfd
];

# When installing Everest, Olympus uses MiniInstaller, which is dynamically linked.
miniinstaller-fhs = buildFHSEnv {
pname = "olympus-miniinstaller-fhs";
inherit version;
targetPkgs =
pkgs:
(with pkgs; [
icu
openssl
dotnet-runtime # Without this, MiniInstaller will install dotnet itself.
]);
};

wrapper-to-env =
wrapper:
if lib.isDerivation wrapper then
lib.getExe wrapper
else if wrapper != null then
wrapper
else
"";

miniinstaller-wrapper =
if miniinstallerWrapper == null then
(writeShellScript "miniinstaller-wrapper" "exec ${lib.getExe miniinstaller-fhs} -c \"$@\"")
else
(wrapper-to-env miniinstallerWrapper);

pname = "olympus";
phome = "$out/lib/${pname}";
# The following variables are to be updated by the update script.
version = "24.11.23.03";
buildId = "4420"; # IMPORTANT: This line is matched with regex in update.sh.
rev = "a3792e0c85f3ad7a3029a6a66ca8288aa6f58ae4";

in
buildDotnetModule {
inherit pname version;

src = fetchFromGitHub {
inherit rev;
owner = "EverestAPI";
repo = "Olympus";
fetchSubmodules = true; # Required. See upstream's README.
hash = "sha256-UPAn9Rbm2IlxMJ/O69WXHugIc+22w+B5i6iLkCcsfQ8=";
};

nativeBuildInputs = [
libarchive # To create the .love file (zip format).
];

nugetDeps = ./deps.json;
projectFile = "sharp/Olympus.Sharp.csproj";
executables = [ ];

# See the 'Dist: Update src/version.txt' step in azure-pipelines.yml from upstream.
preConfigure = ''
echo ${version}-nixos-${buildId}-${builtins.substring 0 5 rev} > src/version.txt
'';

# Hack Olympus.Sharp.bin.{x86,x86_64} to use system mono.
# This was proposed by @0x0ade on discord.gg/celeste.
# https://discord.com/channels/403698615446536203/514006912115802113/827507533962149900
postBuild = ''
dotnet_out=sharp/bin/Release/net452
dotnet_out=$dotnet_out/$(ls $dotnet_out)
makeWrapper ${lib.getExe mono} $dotnet_out/Olympus.Sharp.bin.x86 \
--add-flags ${phome}/sharp/Olympus.Sharp.exe
cp $dotnet_out/Olympus.Sharp.bin.x86 $dotnet_out/Olympus.Sharp.bin.x86_64
'';

# The script find-love is hacked to use love from nixpkgs.
# It is used to launch Loenn from Olympus.
# I assume --fused is so saves are properly made (https://love2d.org/wiki/love.filesystem).
preInstall = ''
mkdir -p ${phome}
makeWrapper ${lib.getExe love} ${phome}/find-love \
--add-flags "--fused"
'';

installPhase = ''
runHook preInstall
mkdir -p $out/bin
makeWrapper ${phome}/find-love $out/bin/olympus \
--prefix LUA_CPATH ";" "${lua_cpath}" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ curl ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
--set-default OLYMPUS_MINIINSTALLER_WRAPPER "${miniinstaller-wrapper}" \
--set-default OLYMPUS_CELESTE_WRAPPER "${wrapper-to-env celesteWrapper}" \
--set-default OLYMPUS_LOENN_WRAPPER "${wrapper-to-env loennWrapper}" \
--set-default OLYMPUS_SKIP_SCHEME_HANDLER_CHECK ${if skipHandlerCheck then "1" else "0"} \
--add-flags ${phome}/olympus.love
bsdtar --format zip --strip-components 1 -cf ${phome}/olympus.love src
dotnet_out=sharp/bin/Release/net452
dotnet_out=$dotnet_out/$(ls $dotnet_out)
install -Dm755 $dotnet_out/* -t ${phome}/sharp
runHook postInstall
'';

postInstall = ''
install -Dm644 lib-linux/olympus.desktop $out/share/applications/olympus.desktop
install -Dm644 src/data/icon.png $out/share/icons/hicolor/128x128/apps/olympus.png
install -Dm644 LICENSE $out/share/licenses/${pname}/LICENSE
'';

passthru.updateScript = ./update.sh;

meta = {
description = "Cross-platform GUI Everest installer and Celeste mod manager";
homepage = "https://github.com/EverestAPI/Olympus";
downloadPage = "https://everestapi.github.io/#olympus";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
ulysseszhan
petingoso
];
mainProgram = "olympus";
platforms = lib.platforms.unix;
badPlatforms = lib.platforms.aarch; # We explicitly copy and wrap x86. possibly able to be done platform agnostic
};
}
32 changes: 32 additions & 0 deletions pkgs/by-name/ol/olympus/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts nixfmt-rfc-style

set -eu -o pipefail

attr=olympus
nix_file=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')

api() {
curl -s "https://dev.azure.com/EverestAPI/Olympus/_apis/$1?api-version=7.1"
}

pipeline_id=$(api pipelines | jq -r '
.value
| map(select(.name == "EverestAPI.Olympus"))
| .[0].id
')

run_id=$(api pipelines/$pipeline_id/runs | jq -r '
.value
| map(select(.result == "succeeded"))
| max_by(.finishedDate)
| .id
')
sed -i 's|buildId\s*=\s*".*";|buildId = "'$run_id'";|' $nix_file

run=$(api pipelines/$pipeline_id/runs/$run_id)
commit=$(echo "$run" | jq -r '.resources.repositories.self.version')
version=$(echo "$run" | jq -r '.name')
update-source-version $attr $version --rev=$commit

"$(nix-build --attr $attr.fetch-deps --no-out-link)"

0 comments on commit ba83043

Please sign in to comment.