Files
nixpkgs/pkgs/by-name/ce/celestegame/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

223 lines
5.6 KiB
Nix

{
lib,
callPackage,
buildFHSEnv,
fetchzip,
makeDesktopItem,
writeShellScript,
autoPatchelfHook,
runtimeShell,
overrideSrc ? null,
# A package. Omit to build without Everest.
everest ? null,
# If build with Everest, must set writableDir to the path of a writable dir
# so that the mods can be installed there.
# It must be an absolute path.
# Example: "/home/kat/.local/share/Everest"
writableDir ? null,
# Optionally set paths of symlinks to the installation dir of Celeste.
# You can use this in Olympus so that you don't have to change installation dir path
# every time the nix store path changes.
# The links are updated every time the command `Celeste` is run.
gameDir ? [ ],
# This will be appended to everest-launch.txt.
launchFlags ? "",
# This will be appended to everest-env.txt.
launchEnv ? "",
}:
# For those who would like to use steam-run or alike to launch Celeste
# (useful when using the `olympus` package with its `celesteWrapper` argument overridden),
# install `celestegame.passthru.celeste-unwrapped` instead of `celestegame`, and if you want Everest,
# override `everest` to `celestegame.passthru.everest-bin` instead of `celestegame.passthru.everest`
# (steam-run cannot launch the latter for some currently unclear reason).
# For those who would like to launch Celeste without the need of any additional wrapper like steam-run,
# install `celestegame` with the `writableDir` argument overridden.
let
pname = "celeste";
phome = "$out/${celesteHomeRelative}";
executableName = "Celeste";
writableDir' =
if writableDir == null && everest != null then
lib.warn "writableDir is not set, so mods will not work." "/tmp"
else
writableDir;
gameDir' = lib.toList gameDir;
everestLogFilename = "everest-log.txt";
celeste = callPackage ./celeste {
inherit
executableName
everest
overrideSrc
launchFlags
launchEnv
everestLogFilename
;
desktopItems = [ desktopItem ];
writableDir = writableDir';
};
celesteHomeRelative = "lib/Celeste";
celesteHome = "${celeste}/${celesteHomeRelative}";
desktopItem = makeDesktopItem {
name = "Celeste";
desktopName = "Celeste";
genericName = "Celeste";
comment = celeste.meta.description;
exec = executableName;
icon = "Celeste";
categories = [ "Game" ];
};
in
buildFHSEnv {
inherit pname executableName;
version = celeste.version + (lib.optionalString (everest != null) "+everest.${everest.version}");
multiPkgs =
pkgs:
with pkgs;
[
glib
glibc_multi
kdePackages.wayland
libxkbcommon
libgcc
mesa
libdrm
expat
alsa-lib
at-spi2-atk
libGL
pcre2
libffi
zlib
util-linux.lib
libselinux
nspr
systemd
gtk3
pango
harfbuzz
fontconfig
fribidi
cairo
libepoxy
tinysparql
libthai
libpng
freetype
pixman
libcap
graphite2
bzip2
brotli
libjpeg
json-glib
libxml2
sqlite
libdatrie
ffmpeg
nss
dbus.lib
acl
attr
gmp
readline
libpulseaudio
pipewire
vulkan-loader
]
++ (with xorg; [
libX11
libXcomposite
libXdamage
libXfixes
libXext
libxcb
libXcursor
libXinerama
libXi
libXrandr
libXScrnSaver
libXxf86vm
libXau
libXdmcp
]);
targetPkgs = pkgs: [ celeste ];
extraInstallCommands = ''
icon=$out/share/icons/hicolor/512x512/apps/Celeste.png
mkdir -p $(dirname $icon)
ln -s ${celesteHome}/Celeste.png $icon
cp -r ${desktopItem}/* $out
'';
extraPreBwrapCmds = ''
export NIX_CELESTE_LAUNCHER=$(realpath --no-symlinks $0)
'';
runScript = writeShellScript executableName (
lib.optionalString (writableDir' != null) ''
mkdir -p "${writableDir'}"
touch "${writableDir'}/log.txt"
# This script is symlinked to gameDir/Celeste, which gets launched by Olympus
# (if the user set up Olympus to use gameDir as the location of Celeste).
# Writing the script like this makes Olympus able to launch Celeste wihout any wrapper without any problems.
echo "#! ${runtimeShell}
exec $NIX_CELESTE_LAUNCHER"' "$@"' > "${writableDir'}/Celeste"
chmod +x "${writableDir'}/Celeste"
''
+ lib.optionalString (everest != null) ''
mkdir -p "${writableDir'}"/{LogHistory,Mods,CrashLogs}
touch "${writableDir'}/${everestLogFilename}"
# Needed to prevent restarting; see comments in postInstall of ./celeste/default.nix.
export LD_LIBRARY_PATH="${celesteHome}/lib64-linux:$LD_LIBRARY_PATH"
''
+ lib.optionalString (gameDir' != [ ]) (
lib.concatMapStrings (link: ''
mkdir -p "$(dirname "${link}")"
if [ -L "${link}" ]; then
if [ ${celesteHome} != "$(readlink "${link}")" ]; then
rm "${link}"
ln -s ${celesteHome} "${link}"
fi
else
rm -r "${link}"
ln -s ${celesteHome} "${link}"
fi
'') gameDir'
)
+ ''
cd /${celesteHomeRelative}
exec ./Celeste-unwrapped "$@"
''
);
passthru.celeste-unwrapped = celeste;
passthru.everest = callPackage ./everest { };
passthru.everest-bin = callPackage ./everest-bin { };
passthru.updateScript = ./update.sh;
meta = {
inherit (celeste.meta)
homepage
downloadPage
description
license
sourceProvenance
platforms
;
maintainers = with lib.maintainers; [ ulysseszhan ];
};
}