diff --git a/pkgs/by-name/ol/olympus-with-steam-run/package.nix b/pkgs/by-name/ol/olympus-with-steam-run/package.nix new file mode 100644 index 00000000000000..8d5d4b50599426 --- /dev/null +++ b/pkgs/by-name/ol/olympus-with-steam-run/package.nix @@ -0,0 +1,6 @@ +{ + steam-run, + callPackage, +}: + +callPackage ../olympus/package.nix { celesteWrapper = steam-run; } diff --git a/pkgs/by-name/ol/olympus/deps.nix b/pkgs/by-name/ol/olympus/deps.nix index 82da86b0514d7b..6824f40b6fd260 100644 --- a/pkgs/by-name/ol/olympus/deps.nix +++ b/pkgs/by-name/ol/olympus/deps.nix @@ -5,47 +5,47 @@ [ (fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies"; - version = "1.0.2"; - sha256 = "0i42rn8xmvhn08799manpym06kpw89qy9080myyy2ngy565pqh0a"; + version = "1.0.3"; + hash = "sha256-FBoJP5DHZF0QHM0xLm9yd4HJZVQOuSpSKA+VQRpphEE="; }) (fetchNuGet { pname = "Microsoft.NETFramework.ReferenceAssemblies.net452"; - version = "1.0.2"; - sha256 = "02xpdaynfglblvi2brszspvz0rz3admzh35shnqgik6s1x75n82k"; + version = "1.0.3"; + hash = "sha256-RTPuFG8D7gnwINEoEtAqmVm4oTW8K4Z87v1o4DDeLMI="; }) (fetchNuGet { pname = "Mono.Cecil"; version = "0.11.4"; - sha256 = "1yxa7mh432s7g7p9r7scqxvxjk5ypwc567qdbf0gmk8fbf0d3f8y"; + hash = "sha256-HrnRgFsOzfqAWw0fUxi/vkzZd8dMn5zueUeLQWA9qvs="; }) (fetchNuGet { pname = "MonoMod"; version = "22.1.4.3"; - sha256 = "1bxrqflqfj6ck1mk9mq41iv2ayz1idirxi4vlan1b30ljq7xsacj"; + hash = "sha256-kindD5YUjBWsopvEnmOL4XsldgwE1zRrmMxIh6nDua8="; }) (fetchNuGet { pname = "MonoMod.RuntimeDetour"; version = "22.1.4.3"; - sha256 = "0brf5835psbi4i0bhvgacpg5cgq9ln89ffz73a8q24wc47flvccv"; + hash = "sha256-m7FN3SGME4GRGuc7l5ClCT9W3mXqbbhAJHHpWwYqLi8="; }) (fetchNuGet { pname = "MonoMod.RuntimeDetour.HookGen"; version = "22.1.4.3"; - sha256 = "0km4g8wlfcsrr9lj6sz06dcsm60x8npdwv1fzzcssjqwfjwsgqqf"; + hash = "sha256-DuOnuXQcS63Z/y5s3q5FHZiqWTPgayNpylkzRzl6pE4="; }) (fetchNuGet { pname = "MonoMod.Utils"; version = "22.1.4.3"; - sha256 = "1m9wcmg2x85f2bji1gzgynn71x0nc9z8g04zryz6w2w26fismb6h"; + hash = "sha256-0KyqozOCC26+z5+Ah35iFvRwrPXvvxDlEq6gLl5lPNU="; }) (fetchNuGet { pname = "Newtonsoft.Json"; version = "13.0.1"; - sha256 = "0fijg0w6iwap8gvzyjnndds0q4b8anwxxvik7y8vgq97dram4srb"; + hash = "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo="; }) (fetchNuGet { pname = "YamlDotNet"; version = "9.1.0"; - sha256 = "0fcnw8plp1fl8nx5ykfbwq3qlsjpjzk65hfafj9dzj0vp4w0zcsr"; + 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 index 060e8e66860a55..0fcd1e2fa8cafc 100644 --- a/pkgs/by-name/ol/olympus/package.nix +++ b/pkgs/by-name/ol/olympus/package.nix @@ -2,42 +2,58 @@ lib, fetchFromGitHub, fetchzip, + buildFHSEnv, buildDotnetModule, - mono4, - love, - lua51Packages, - msbuild, + luajitPackages, sqlite, - curl, libarchive, - buildFHSEnv, + curl, + mono, + love, xdg-utils, + # Some examples for celesteWrapper: + # - null or "": Do not use wrapper. + # - steam-run: Use steam-run. + # - "steam-run": Use steam-run command available from PATH. + # - buildFHSEnv { ... }: Use a custom FHS env. + # - writeShellScriptBin { ... }: Use a custom script. + # - ./my-wrapper.sh: Use a custom script. + # In any case, it can be overridden at runtime by OLYMPUS_CELESTE_WRAPPER. + celesteWrapper ? null, }: -# 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). -# https://github.com/EverestAPI/Olympus/issues/94 could be a temporary 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"; - }; + lua_cpath = + with luajitPackages; + lib.concatMapStringsSep ";" getLuaCPath [ + (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"; + }) + + (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 ]; + }) + + nfd + ]; - # NOTE: on installation olympus uses MiniInstallerLinux which is dynamically linked, this makes it run fine - fhs-env = buildFHSEnv { - name = "olympus-fhs"; + # When installing Everest, Olympus uses MiniInstaller, which is dynamically linked. + miniinstaller-fhs = buildFHSEnv { + name = "olympus-miniinstaller-fhs"; targetPkgs = pkgs: (with pkgs; [ @@ -45,120 +61,103 @@ let stdenv.cc.cc libgcc.lib openssl + dotnet-runtime # Without this, MiniInstaller will install dotnet itself. ]); runScript = "bash"; }; + miniinstaller-wrapper = "${miniinstaller-fhs}/bin/${miniinstaller-fhs.name}"; - 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 ]; - }; + celeste-wrapper = + if lib.isDerivation celesteWrapper then + lib.getExe celesteWrapper + else if celesteWrapper == null then + "" + else + celesteWrapper; - dotnet-out = "sharp/bin/Release/net452"; pname = "olympus"; phome = "$out/lib/${pname}"; - nfd = lua51Packages.nfd; + # The following variables are to be updated by the update script. + version = "24.11.23.01"; + buildId = "4418"; # IMPORTANT: This line is matched with regex in update.sh. + rev = "d05f50fae23d741c9b6f72ba8fd951dca1a6e0f0"; in -buildDotnetModule rec { - inherit pname; - - # FIXME: I made up this version number. - version = "24.07.06.02"; +buildDotnetModule { + inherit pname version; src = fetchFromGitHub { + inherit rev; owner = "EverestAPI"; repo = "Olympus"; - rev = "5f3e40687eb825c57021f52d83a3bc9a82c04bdb"; fetchSubmodules = true; # Required. See upstream's README. - hash = "sha256-rNh6sH51poahiV0Mb61lHfzqOkPF2pW2wr7MOrfVSVs="; + hash = "sha256-SjSdcYAO6Do+OkHPMut+V7VwqBBFIkeHl8gjDIwocc0="; }; - executables = [ ]; - nativeBuildInputs = [ - msbuild - libarchive # To create the .love file (zip format) - ]; - - buildInputs = [ - love - mono4 - nfd - lua-subprocess - lsqlite3 - ]; - - runtimeInputs = [ - xdg-utils + libarchive # To create the .love file (zip format). ]; nugetDeps = ./deps.nix; + projectFile = "sharp/Olympus.Sharp.csproj"; + executables = [ ]; - projectFile = "sharp/Olympus.Sharp.sln"; - - postConfigure = '' - echo '${version}-nixos' > src/version.txt - ''; - - # TODO: the override is needed for it to run. Should be found out why - # Copied from `olympus` in AUR. - buildPhase = '' - runHook preBuild - FrameworkPathOverride=${mono4.out}/lib/mono/4.5 msbuild ${projectFile} /p:Configuration=Release - runHook postBuild + # 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: + # This was proposed by @0x0ade on discord.gg/celeste. # https://discord.com/channels/403698615446536203/514006912115802113/827507533962149900 - # - # I assume --fused is so saves are properly made (https://love2d.org/wiki/love.filesystem) postBuild = '' - makeWrapper ${mono4.out}/bin/mono ${dotnet-out}/Olympus.Sharp.bin.x86 \ + 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 + 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 + # 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 "${celeste-wrapper}" \ + --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 = '' - 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 ''; + passthru.updateScript = ./update.sh; + meta = { 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"; + downloadPage = "https://everestapi.github.io/#olympus"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ ulysseszhan diff --git a/pkgs/by-name/ol/olympus/update.sh b/pkgs/by-name/ol/olympus/update.sh new file mode 100755 index 00000000000000..365b6464c69a02 --- /dev/null +++ b/pkgs/by-name/ol/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