From ba83043864d3fcefaeef5d5b65c8ccd5a71978d0 Mon Sep 17 00:00:00 2001 From: Petingoso Date: Sun, 5 May 2024 17:32:50 +0100 Subject: [PATCH] olympus: init at 24.11.23.03 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](https://github.com/NixOS/nixpkgs/pull/295258), with the authors permission. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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](https://github.com/NixOS/nixpkgs/pull/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 (#336576) olympus: tweak miniinstallerWrapper olympus: migrated to deps.json (#362278) olympus: remove meta.mainProgram explicitly (#358550) --- pkgs/by-name/ol/olympus/deps.json | 47 ++++++++ pkgs/by-name/ol/olympus/package.nix | 171 ++++++++++++++++++++++++++++ pkgs/by-name/ol/olympus/update.sh | 32 ++++++ 3 files changed, 250 insertions(+) create mode 100644 pkgs/by-name/ol/olympus/deps.json create mode 100644 pkgs/by-name/ol/olympus/package.nix create mode 100755 pkgs/by-name/ol/olympus/update.sh diff --git a/pkgs/by-name/ol/olympus/deps.json b/pkgs/by-name/ol/olympus/deps.json new file mode 100644 index 00000000000000..8933c682f9b525 --- /dev/null +++ b/pkgs/by-name/ol/olympus/deps.json @@ -0,0 +1,47 @@ +[ + { + "pname": "Microsoft.NETFramework.ReferenceAssemblies", + "version": "1.0.3", + "hash": "sha256-FBoJP5DHZF0QHM0xLm9yd4HJZVQOuSpSKA+VQRpphEE=" + }, + { + "pname": "Microsoft.NETFramework.ReferenceAssemblies.net452", + "version": "1.0.3", + "hash": "sha256-RTPuFG8D7gnwINEoEtAqmVm4oTW8K4Z87v1o4DDeLMI=" + }, + { + "pname": "Mono.Cecil", + "version": "0.11.4", + "hash": "sha256-HrnRgFsOzfqAWw0fUxi/vkzZd8dMn5zueUeLQWA9qvs=" + }, + { + "pname": "MonoMod", + "version": "22.1.4.3", + "hash": "sha256-kindD5YUjBWsopvEnmOL4XsldgwE1zRrmMxIh6nDua8=" + }, + { + "pname": "MonoMod.RuntimeDetour", + "version": "22.1.4.3", + "hash": "sha256-m7FN3SGME4GRGuc7l5ClCT9W3mXqbbhAJHHpWwYqLi8=" + }, + { + "pname": "MonoMod.RuntimeDetour.HookGen", + "version": "22.1.4.3", + "hash": "sha256-DuOnuXQcS63Z/y5s3q5FHZiqWTPgayNpylkzRzl6pE4=" + }, + { + "pname": "MonoMod.Utils", + "version": "22.1.4.3", + "hash": "sha256-0KyqozOCC26+z5+Ah35iFvRwrPXvvxDlEq6gLl5lPNU=" + }, + { + "pname": "Newtonsoft.Json", + "version": "13.0.1", + "hash": "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo=" + }, + { + "pname": "YamlDotNet", + "version": "9.1.0", + "hash": "sha256-WbMPOLkbyN+SdMrBYuaXV2qKB+bLTV+6RdSFSy/iljk=" + } +] diff --git a/pkgs/by-name/ol/olympus/package.nix b/pkgs/by-name/ol/olympus/package.nix new file mode 100644 index 00000000000000..bbdd0810c16da9 --- /dev/null +++ b/pkgs/by-name/ol/olympus/package.nix @@ -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 + }; +} diff --git a/pkgs/by-name/ol/olympus/update.sh b/pkgs/by-name/ol/olympus/update.sh new file mode 100755 index 00000000000000..4ae9a6ab93cec7 --- /dev/null +++ b/pkgs/by-name/ol/olympus/update.sh @@ -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)"