Skip to content

Commit

Permalink
balatro: init at 1.0.1n, lovely-injector: init at 0.6.0 (NixOS#338610)
Browse files Browse the repository at this point in the history
  • Loading branch information
FliegendeWurst authored Dec 31, 2024
2 parents 09f55c6 + 24c766e commit a7745fe
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,12 @@
matrix = "@anthonyrsl:matrix.org";
keys = [ { fingerprint = "472D 368A F107 F443 F3A5 C712 9DC4 987B 1A55 E75E"; } ];
};
antipatico = {
email = "[email protected]";
github = "antipatico";
githubId = 14838767;
name = "Jacopo Scannella";
};
antoinerg = {
email = "[email protected]";
github = "antoinerg";
Expand Down
15 changes: 15 additions & 0 deletions pkgs/by-name/ba/balatro/globals.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- result/share/balatro/globals.lua 1970-01-01 01:00:01.000000000 +0100
+++ result/share/balatro/globals.lua 1970-01-01 01:00:01.000000000 +0100
@@ -56,6 +56,12 @@ function Game:set_globals()
self.F_CRASH_REPORTS = false
end

+ if love.system.getOS() == 'Linux' then
+ self.F_SAVE_TIMER = 5
+ self.F_DISCORD = true
+ self.F_ENGLISH_ONLY = false
+ end
+
if love.system.getOS() == 'Nintendo Switch' then
self.F_HIDE_BETA_LANGS = true
self.F_BASIC_CREDITS = true
79 changes: 79 additions & 0 deletions pkgs/by-name/ba/balatro/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
stdenv,
lib,
love,
lovely-injector,
p7zip,
copyDesktopItems,
makeWrapper,
makeDesktopItem,
requireFile,
withMods ? true,
withLinuxPatch ? true,
}:
let
version = "1.0.1n";
balatroExe = requireFile {
name = "Balatro-${version}.exe";
url = "https://store.steampowered.com/app/2379780/Balatro/";
# Use `nix hash file --sri --type sha256` to get the correct hash
hash = "sha256-mJ5pL+Qj3+ldOLFcQc64dM0edTeQSePIYpp5EuwxKXo=";
};
in
stdenv.mkDerivation {
pname = "balatro";
inherit version;
nativeBuildInputs = [
p7zip
copyDesktopItems
makeWrapper
];
buildInputs = [ love ] ++ lib.optional withMods lovely-injector;
dontUnpack = true;
desktopItems = [
(makeDesktopItem {
name = "balatro";
desktopName = "Balatro";
exec = "balatro";
keywords = [ "Game" ];
categories = [ "Game" ];
icon = "balatro";
})
];
buildPhase = ''
runHook preBuild
tmpdir=$(mktemp -d)
7z x ${balatroExe} -o$tmpdir -y
${if withLinuxPatch then "patch $tmpdir/globals.lua -i ${./globals.patch}" else ""}
patchedExe=$(mktemp -u).zip
7z a $patchedExe $tmpdir/*
runHook postBuild
'';

# The `cat` bit is a hack suggested by whitelje (https://github.com/ethangreen-dev/lovely-injector/pull/66#issuecomment-2319615509)
# to make it so that lovely will pick up Balatro as the game name. The `LD_PRELOAD` bit is used to load lovely and it is the
# 'official' way of doing it.
installPhase = ''
runHook preInstall
install -Dm444 $tmpdir/resources/textures/2x/balatro.png -t $out/share/icons/
cat ${lib.getExe love} $patchedExe > $out/share/Balatro
chmod +x $out/share/Balatro
makeWrapper $out/share/Balatro $out/bin/balatro ${lib.optionalString withMods "--prefix LD_PRELOAD : '${lovely-injector}/lib/liblovely.so'"}
runHook postInstall
'';

meta = {
description = "Poker roguelike";
longDescription = ''
Balatro is a hypnotically satisfying deckbuilder where you play illegal poker hands,
discover game-changing jokers, and trigger adrenaline-pumping, outrageous combos.
'';
license = lib.licenses.unfree;
homepage = "https://store.steampowered.com/app/2379780/Balatro/";
maintainers = [ lib.maintainers.antipatico ];
platforms = love.meta.platforms;
mainProgram = "balatro";
};
}
39 changes: 39 additions & 0 deletions pkgs/by-name/lo/lovely-injector/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
fetchFromGitHub,
rustPlatform,
lib,
}:
let
version = "0.6.0";
lovelyInjector = fetchFromGitHub {
owner = "vgskye";
repo = "lovely-injector";
rev = "3224915f4d47b557c34b5012797cf92d4cc629af";
hash = "sha256-fzkuuu6pmvqeJa7qlX8jhtCLC4oYRLUm1hqHTRiYEX8=";
};
in
rustPlatform.buildRustPackage rec {
pname = "lovely-injector";
inherit version;
src = lovelyInjector;
useFetchCargoVendor = true;
cargoHash = "sha256-Mkmj+ENdUge1V1cVAQOV2K01sYKEyhxTse0f5o6H6Xc=";
# no tests
doCheck = false;
# lovely-injector depends on nightly rust features
env.RUSTC_BOOTSTRAP = 1;

meta = {
description = "Runtime lua injector for games built with LÖVE";
longDescription = ''
Lovely is a lua injector which embeds code into a LÖVE 2d game at runtime.
Unlike executable patchers, mods can be installed, updated, and removed over and over again without requiring a partial or total game reinstallation.
This is accomplished through in-process lua API detouring and an easy to use (and distribute) patch system.
'';
license = lib.licenses.mit;
homepage = "https://github.com/ethangreen-dev/lovely-injector";
downloadPage = "https://github.com/ethangreen-dev/lovely-injector/releases";
maintainers = [ lib.maintainers.antipatico ];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}

0 comments on commit a7745fe

Please sign in to comment.