-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
requireFile, | ||
unzip, | ||
yq, | ||
dotnet-runtime_7, | ||
|
||
everest ? null, | ||
overrideSrc ? null, | ||
writableDir ? null, | ||
launchFlags ? "", | ||
launchEnv ? "", | ||
# If we leave it to be the default (log.txt), | ||
# Everest will try to delete log.txt when it starts, | ||
# which doesn't work because the file system is read-only. | ||
# https://github.com/EverestAPI/Everest/blob/050b4a1b4a7918b22d3d5140224f9c0472e1655a/Celeste.Mod.mm/Patches/Celeste.cs#L140-L155 | ||
everestLogFilename ? "everest-log.txt", | ||
}: | ||
|
||
# TODO: It appears that it is possible to package Celeste for aarch devices: | ||
# https://github.com/pixelomer/Celeste-ARM64 | ||
# However, I don't have an aarch device to do that. | ||
let | ||
pname = "celeste-unwrapped"; | ||
version = "1.4.0.0"; | ||
downloadPage = "https://maddymakesgamesinc.itch.io/celeste"; | ||
phome = "$out/lib/Celeste"; | ||
|
||
launchFlags' = | ||
if launchFlags != "" && everest == null then | ||
lib.warn "launchFlags is useless without Everest." "" | ||
else | ||
launchFlags; | ||
launchEnv' = | ||
if launchEnv != "" && everest == null then | ||
lib.warn "launchEnv is useless without Everest." "" | ||
else | ||
'' | ||
EVEREST_LOG_FILENAME=${everestLogFilename} | ||
EVEREST_TMPDIR=${writableDir} | ||
${launchEnv} | ||
''; | ||
in | ||
stdenvNoCC.mkDerivation { | ||
pname = "celeste-unwrapped"; | ||
version = version; | ||
src = | ||
if overrideSrc == null then | ||
requireFile { | ||
name = "celeste-linux.zip"; | ||
hash = "sha256-q4gniSgg00U3j5TZpvIZnSmqAyCHd/pOVAuQ3rDYEAs="; | ||
url = downloadPage; | ||
} | ||
else | ||
overrideSrc; | ||
dontUnpack = true; | ||
nativeBuildInputs = [ | ||
unzip | ||
yq | ||
]; | ||
postInstall = | ||
'' | ||
mkdir -p ${phome} | ||
unzip -q $src -d ${phome} | ||
'' | ||
+ lib.optionalString (everest != null) '' | ||
cp -r ${everest}/* $out | ||
chmod -R +w ${phome} # Files copied from other derivations are not writable by default | ||
# There will still be a runtime error saying chmod failed for the splash, | ||
# but it doesn't matter because we make it executable here. | ||
# https://github.com/EverestAPI/Everest/blob/050b4a1b4a7918b22d3d5140224f9c0472e1655a/Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs#L73-L81 | ||
chmod +x ${phome}/EverestSplash/EverestSplash-linux | ||
# Everest determines whether it is FNA or XNA by the existence of the file. | ||
# Creating this now prevents it from creating it in the future | ||
# when the file system is read-only. | ||
# https://github.com/EverestAPI/Everest/blob/050b4a1b4a7918b22d3d5140224f9c0472e1655a/Celeste.Mod.mm/Patches/Celeste.cs#L41-L47 | ||
touch ${phome}/BuildIsFNA.txt | ||
# Please Piton by having the runtime. | ||
# Otherwise it will try to download it. | ||
# https://github.com/Popax21/Piton/blob/21c7868d06007f0c5e7d9030a0109fe892df1bf3/apphost/src/runtime.rs#L82-L89 | ||
mkdir ${phome}/piton-runtime | ||
ln -s ${dotnet-runtime_7}/share/dotnet/* -t ${phome}/piton-runtime | ||
platform=linux-x86_64 | ||
echo -n "$platform $(yq -r .\"$platform\".version ${phome}/piton-runtime.yaml)" > ${phome}/piton-runtime/piton-runtime-id.txt | ||
chmod +x ${phome}/MiniInstaller-linux | ||
${phome}/MiniInstaller-linux | ||
echo "${launchFlags'}" > ${phome}/everest-launch.txt | ||
echo "${launchEnv'}" > ${phome}/everest-env.txt | ||
''; | ||
|
||
dontPatchELF = true; | ||
dontStrip = true; | ||
dontPatchShebangs = true; | ||
postFixup = | ||
lib.optionalString (everest != null) '' | ||
rm -r ${phome}/Mods # Currently it is empty. | ||
ln -s "${writableDir}"/{Mods,LogHistory,CrashLogs,${everestLogFilename}} -t ${phome} | ||
'' | ||
+ lib.optionalString (writableDir != null) '' | ||
ln -s "${writableDir}/log.txt" -t ${phome} | ||
''; | ||
|
||
meta = { | ||
inherit downloadPage; | ||
homepage = "https://www.celestegame.com"; | ||
description = "2D platformer game about climing a mountain"; | ||
license = with lib.licenses; [ unfree ]; | ||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | ||
maintainers = with lib.maintainers; [ ulysseszhan ]; | ||
platforms = [ | ||
"x86_64-linux" | ||
"i686-linux" | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
fetchzip, | ||
icu, | ||
autoPatchelfHook, | ||
}: | ||
|
||
let | ||
pname = "everest"; | ||
version = "5262"; # TODO: From a PR, so Azure pipeline artifact will expire in 10 days. | ||
phome = "$out/lib/Celeste"; | ||
in | ||
stdenvNoCC.mkDerivation { | ||
inherit pname version; | ||
src = fetchzip { | ||
#url = "https://github.com/EverestAPI/Everest/releases/download/stable-1.${version}.0/main.zip"; | ||
#hash = "sha256-aEuWLR5WxYpID7ykFzgS3ZF8Mb2I+W0QIKxjfg5umj4="; | ||
url = "https://dev.azure.com/EverestAPI/Everest/_apis/build/builds/${lib.toInt version - 700}/artifacts?artifactName=main&api-version=7.1&%24format=zip"; | ||
extension = "zip"; | ||
hash = "sha256-z95+mi9UMNzZaXIGQbaCqLIsWpTnvyHZ+ZyYon9gnTw="; | ||
}; | ||
buildInputs = [ | ||
icu | ||
]; | ||
nativeBuildInputs = [ | ||
autoPatchelfHook | ||
]; | ||
postInstall = '' | ||
mkdir -p ${phome} | ||
cp -r * ${phome} | ||
''; | ||
dontAutoPatchelf = true; | ||
dontPatchELF = true; | ||
dontStrip = true; | ||
dontPatchShebangs = true; | ||
postFixup = '' | ||
autoPatchelf ${phome}/MiniInstaller-linux | ||
''; | ||
meta = { | ||
description = "Celeste mod loader"; | ||
license = with lib.licenses; [ mit ]; | ||
maintainers = with lib.maintainers; [ ulysseszhan ]; | ||
homepage = "https://everestapi.github.io"; | ||
platforms = [ "x86_64-linux" ]; | ||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
lib, | ||
fetchurl, | ||
fetchFromGitHub, | ||
buildDotnetModule, | ||
dotnetCorePackages, | ||
autoPatchelfHook, | ||
mono, | ||
git, | ||
icu, | ||
}: | ||
|
||
let | ||
pname = "everest"; | ||
version = "5184"; | ||
phome = "$out/lib/Celeste"; | ||
in | ||
buildDotnetModule { | ||
inherit pname version; | ||
|
||
src = fetchFromGitHub { | ||
owner = "EverestAPI"; | ||
repo = "Everest"; | ||
tag = "stable-1.${version}.0"; | ||
fetchSubmodules = true; | ||
leaveDotGit = true; # MonoMod.SourceGen.Internal needs .git | ||
hash = "sha256-yujI6h+y7WeUs3dz7h7PLqK4BkaDAvFJurlnRj07IrA="; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
git | ||
autoPatchelfHook | ||
]; | ||
|
||
buildInputs = [ | ||
icu # For autoPatchelf | ||
mono # See upstream README | ||
]; | ||
|
||
patches = [ | ||
# Avoiding creating/deleting files directly in the installation dir at runtime | ||
(fetchurl { | ||
url = "https://github.com/EverestAPI/Everest/compare/050b4a1b4a7918b22d3d5140224f9c0472e1655a...0c55de517b8b08ba2afc43efebe9fa3de26c34a3.patch"; | ||
hash = "sha256-Th6c/dklHPK8/kxhRv1l7m1UW7uWgnMYyJoqW0Dfqwc="; | ||
}) | ||
]; | ||
|
||
postPatch = '' | ||
# MonoMod.ILHelpers.Patcher complains at build phase: You must install .NET to run this application. | ||
sed -i 's|<Exec Command=""|<Exec Command="DOTNET_ROOT=${dotnetCorePackages.runtime_6_0}/share/dotnet \"|' external/MonoMod/tools/Common.IL.targets | ||
# Moving files after publishing somehow doesn't work. Will do this manually in postInstall. | ||
sed -i 's|<Move.*/>||' Celeste.Mod.mm/Celeste.Mod.mm.csproj | ||
autoPatchelf lib-ext/piton/piton-linux_x64 | ||
''; | ||
|
||
# Upgrade to .NET 8 is still WIP upstream: EverestAPI/Everest#828 | ||
dotnet-sdk = dotnetCorePackages.sdk_7_0; | ||
|
||
preConfigure = '' | ||
# Microsoft.SourceLink.GitHub complains: Unable to determine repository url, the source code won't be available via source link. | ||
cd external/MonoMod | ||
git -c safe.directory='*' remote add origin https://github.com/MonoMod/MonoMod.git | ||
cd ../.. | ||
''; | ||
|
||
nugetDeps = ./deps.json; | ||
|
||
# Needed for ILAsm projects: https://github.com/NixOS/nixpkgs/issues/370754#issuecomment-2571475814 | ||
linkNugetPackages = true; | ||
|
||
# Microsoft.NET.Sdk complains: The process cannot access the file xxx because it is being used by another process. | ||
enableParallelBuilding = false; | ||
|
||
preBuild = '' | ||
# See .azure-pipelines/prebuild.ps1 | ||
sed -i 's|0\.0\.0-dev|1.${version}.0-nixos-'$(git rev-parse --short=5 HEAD)'|' Celeste.Mod.mm/Mod/Everest/Everest.cs | ||
cat Celeste.Mod.mm/Mod/Everest/Everest.cs | ||
cat <<-EOF > Celeste.Mod.mm/Mod/Helpers/EverestVersion.cs | ||
namespace Celeste.Mod.Helpers { | ||
internal static class EverestBuild${version} { | ||
public static string EverestBuild = "EverestBuild${version}"; | ||
} | ||
} | ||
EOF | ||
''; | ||
|
||
installPath = builtins.replaceStrings [ "$out" ] [ (placeholder "out") ] phome; | ||
|
||
postInstall = '' | ||
mkdir tmp-EverestSplash | ||
mv ${phome}/EverestSplash* tmp-EverestSplash | ||
mv tmp-EverestSplash ${phome}/EverestSplash | ||
cp ${phome}/piton-runtime.yaml ${phome}/EverestSplash | ||
''; | ||
|
||
executables = [ ]; | ||
|
||
dontPatchELF = true; | ||
dontStrip = true; | ||
dontPatchShebangs = true; | ||
dontAutoPatchelf = true; | ||
|
||
meta = { | ||
description = "Celeste mod loader"; | ||
license = with lib.licenses; [ mit ]; | ||
maintainers = with lib.maintainers; [ ulysseszhan ]; | ||
homepage = "https://everestapi.github.io"; | ||
platforms = [ "x86_64-linux" ]; | ||
sourceProvenance = with lib.sourceTypes; [ | ||
binaryNativeCode | ||
fromSource | ||
]; | ||
}; | ||
} |
Oops, something went wrong.