From d2fbfa04561671a19ae3b3beeb30702b4e7425a9 Mon Sep 17 00:00:00 2001 From: vorboyvo Date: Tue, 3 Dec 2024 00:39:25 -0500 Subject: [PATCH] Updated olympus package. Still need to update in packages. --- pkgs/olympus/deps.nix | 57 ++++++++++--- pkgs/olympus/olympus.nix | 160 ------------------------------------ pkgs/olympus/package.nix | 170 +++++++++++++++++++++++++++++++++++++++ pkgs/olympus/update.sh | 33 ++++++++ 4 files changed, 250 insertions(+), 170 deletions(-) delete mode 100644 pkgs/olympus/olympus.nix create mode 100644 pkgs/olympus/package.nix create mode 100644 pkgs/olympus/update.sh diff --git a/pkgs/olympus/deps.nix b/pkgs/olympus/deps.nix index c80ed3c..6824f40 100644 --- a/pkgs/olympus/deps.nix +++ b/pkgs/olympus/deps.nix @@ -1,14 +1,51 @@ # This file was automatically generated by passthru.fetch-deps. # Please dont edit it manually, your changes might get overwritten! -{ fetchNuGet }: [ - (fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies"; version = "1.0.2"; sha256 = "0i42rn8xmvhn08799manpym06kpw89qy9080myyy2ngy565pqh0a"; }) - (fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies.net452"; version = "1.0.2"; sha256 = "02xpdaynfglblvi2brszspvz0rz3admzh35shnqgik6s1x75n82k"; }) - (fetchNuGet { pname = "Mono.Cecil"; version = "0.11.4"; sha256 = "1yxa7mh432s7g7p9r7scqxvxjk5ypwc567qdbf0gmk8fbf0d3f8y"; }) - (fetchNuGet { pname = "MonoMod"; version = "22.1.4.3"; sha256 = "1bxrqflqfj6ck1mk9mq41iv2ayz1idirxi4vlan1b30ljq7xsacj"; }) - (fetchNuGet { pname = "MonoMod.RuntimeDetour"; version = "22.1.4.3"; sha256 = "0brf5835psbi4i0bhvgacpg5cgq9ln89ffz73a8q24wc47flvccv"; }) - (fetchNuGet { pname = "MonoMod.RuntimeDetour.HookGen"; version = "22.1.4.3"; sha256 = "0km4g8wlfcsrr9lj6sz06dcsm60x8npdwv1fzzcssjqwfjwsgqqf"; }) - (fetchNuGet { pname = "MonoMod.Utils"; version = "22.1.4.3"; sha256 = "1m9wcmg2x85f2bji1gzgynn71x0nc9z8g04zryz6w2w26fismb6h"; }) - (fetchNuGet { pname = "Newtonsoft.Json"; version = "13.0.1"; sha256 = "0fijg0w6iwap8gvzyjnndds0q4b8anwxxvik7y8vgq97dram4srb"; }) - (fetchNuGet { pname = "YamlDotNet"; version = "9.1.0"; sha256 = "0fcnw8plp1fl8nx5ykfbwq3qlsjpjzk65hfafj9dzj0vp4w0zcsr"; }) +{ fetchNuGet }: +[ + (fetchNuGet { + pname = "Microsoft.NETFramework.ReferenceAssemblies"; + version = "1.0.3"; + hash = "sha256-FBoJP5DHZF0QHM0xLm9yd4HJZVQOuSpSKA+VQRpphEE="; + }) + (fetchNuGet { + pname = "Microsoft.NETFramework.ReferenceAssemblies.net452"; + version = "1.0.3"; + hash = "sha256-RTPuFG8D7gnwINEoEtAqmVm4oTW8K4Z87v1o4DDeLMI="; + }) + (fetchNuGet { + pname = "Mono.Cecil"; + version = "0.11.4"; + hash = "sha256-HrnRgFsOzfqAWw0fUxi/vkzZd8dMn5zueUeLQWA9qvs="; + }) + (fetchNuGet { + pname = "MonoMod"; + version = "22.1.4.3"; + hash = "sha256-kindD5YUjBWsopvEnmOL4XsldgwE1zRrmMxIh6nDua8="; + }) + (fetchNuGet { + pname = "MonoMod.RuntimeDetour"; + version = "22.1.4.3"; + hash = "sha256-m7FN3SGME4GRGuc7l5ClCT9W3mXqbbhAJHHpWwYqLi8="; + }) + (fetchNuGet { + pname = "MonoMod.RuntimeDetour.HookGen"; + version = "22.1.4.3"; + hash = "sha256-DuOnuXQcS63Z/y5s3q5FHZiqWTPgayNpylkzRzl6pE4="; + }) + (fetchNuGet { + pname = "MonoMod.Utils"; + version = "22.1.4.3"; + hash = "sha256-0KyqozOCC26+z5+Ah35iFvRwrPXvvxDlEq6gLl5lPNU="; + }) + (fetchNuGet { + pname = "Newtonsoft.Json"; + version = "13.0.1"; + hash = "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo="; + }) + (fetchNuGet { + pname = "YamlDotNet"; + version = "9.1.0"; + hash = "sha256-WbMPOLkbyN+SdMrBYuaXV2qKB+bLTV+6RdSFSy/iljk="; + }) ] diff --git a/pkgs/olympus/olympus.nix b/pkgs/olympus/olympus.nix deleted file mode 100644 index 3ddc993..0000000 --- a/pkgs/olympus/olympus.nix +++ /dev/null @@ -1,160 +0,0 @@ -{ - fetchFromGitHub, - fetchzip, - buildDotnetModule, - lib, - mono4, - love, - lua51Packages, - msbuild, - sqlite, - curl, - libarchive, - buildFHSEnv, - xdg-utils, -}: -# WONTFIX: On NixOS, cannot launch Steam installations of Everest / Celeste from Olympus. -# The way it launches Celeste is by directly executing steamapps/common/Celeste/Celeste, -# and it does not work on NixOS (even with steam-run). -# This should be considered a bug of Steam on NixOS (and is probably very hard to fix). - -# FIXME: olympus checks if xdg-mime x-scheme-handler/everest for a popup. If it's not set it complains about it. -# I'm pretty sure thats by user so end user needs to do it - -let - lua-subprocess = lua51Packages.buildLuarocksPackage { - pname = "subprocess"; - version = "bfa8e9"; - src = fetchFromGitHub { - owner = "0x0ade"; # a developer of Everest - repo = "lua-subprocess"; - rev = "bfa8e97da774141f301cfd1106dca53a30a4de54"; - hash = "sha256-4LiYWB3PAQ/s33Yj/gwC+Ef1vGe5FedWexeCBVSDIV0="; - }; - rockspecFilename = "subprocess-scm-1.rockspec"; - }; - - # NOTE: on installation olympus uses MiniInstallerLinux which is dynamically linked, this makes it run fine - fhs-env = buildFHSEnv { - name = "olympus-fhs"; - targetPkgs = pkgs: (with pkgs; [ - icu - stdenv.cc.cc - libgcc.lib - openssl - ]); - runScript = "bash"; - }; - - - lsqlite3 = lua51Packages.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]; - }; - - dotnet-out = "sharp/bin/Release/net452"; - pname = "olympus"; - phome = "$out/lib/${pname}"; - nfd = lua51Packages.nfd; -in - buildDotnetModule rec { - inherit pname; - - # FIXME: I made up this version number. - version = "24.07.06.02"; - - src = fetchFromGitHub { - owner = "EverestAPI"; - repo = "Olympus"; - rev = "5f3e40687eb825c57021f52d83a3bc9a82c04bdb"; - fetchSubmodules = true; # Required. See upstream's README. - hash = "sha256-rNh6sH51poahiV0Mb61lHfzqOkPF2pW2wr7MOrfVSVs="; - }; - - executables = []; - - nativeBuildInputs = [ - msbuild - libarchive # To create the .love file (zip format) - ]; - - buildInputs = [ - love - mono4 - nfd - lua-subprocess - lsqlite3 - ]; - - runtimeInputs = [ - xdg-utils - ]; - - nugetDeps = ./deps.nix; - - projectFile = "sharp/Olympus.Sharp.sln"; - - postConfigure = '' - echo '${version}-nixos' > src/version.txt - ''; - - # Copied from `olympus` in AUR. - buildPhase = '' - runHook preBuild - FrameworkPathOverride=${mono4.out}/lib/mono/4.5 msbuild ${projectFile} /p:Configuration=Release - runHook postBuild - ''; - - # 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 = '' - makeWrapper ${mono4.out}/bin/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. - installPhase = let - subprocess-cpath = "${lua-subprocess.out}/lib/lua/5.1/?.so"; - nfd-cpath = "${nfd.out}/lib/lua/5.1/?.so"; - lsqlite3-cpath = "${lsqlite3.out}/lib/lua/5.1/?.so"; - in '' - runHook preInstall - mkdir -p $out/bin - makeWrapper ${love.out}/bin/love ${phome}/find-love \ - --add-flags "--fused" - makeWrapper ${phome}/find-love $out/bin/olympus \ - --prefix LUA_CPATH : "${nfd-cpath};${subprocess-cpath};${lsqlite3-cpath}" \ - --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [curl]} \ - --add-flags "${phome}/olympus.love" - mkdir -p ${phome} - bsdtar --format zip --strip-components 1 -cf ${phome}/olympus.love src - install -Dm755 ${dotnet-out}/* -t ${phome}/sharp - runHook postInstall - ''; - - # we need to force olympus to use the fhs-env - postInstall = '' - sed -i 's|^exec|& ${fhs-env}/bin/olympus-fhs|' $out/bin/olympus - 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 - ''; - - meta = with lib; { - description = "Cross-platform GUI Everest installer and Celeste mod manager"; - homepage = "https://github.com/EverestAPI/Olympus"; - changelog = "https://github.com/EverestAPI/Olympus/blob/main/changelog.txt"; - license = licenses.mit; - maintainers = with maintainers; [ulysseszhan petingoso]; - mainProgram = "olympus"; - platforms = platforms.unix; - }; - } diff --git a/pkgs/olympus/package.nix b/pkgs/olympus/package.nix new file mode 100644 index 0000000..efe6f29 --- /dev/null +++ b/pkgs/olympus/package.nix @@ -0,0 +1,170 @@ +{ + 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 { + name = "olympus-miniinstaller-fhs"; + 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" "${miniinstaller-fhs}/bin/${miniinstaller-fhs.name} -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.nix; + 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/olympus/update.sh b/pkgs/olympus/update.sh new file mode 100644 index 0000000..365b646 --- /dev/null +++ b/pkgs/olympus/update.sh @@ -0,0 +1,33 @@ +#!/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)" +nixfmt $(dirname $nix_file)/deps.nix # NixOS/nixpkgs#358025