added more balatro packages

This commit is contained in:
Kristian Krsnik 2025-04-24 19:05:58 +02:00
parent 58ae7c9dd1
commit b4997dcd7a
Signed by: Kristian
GPG Key ID: FD1330AC9F909E85
8 changed files with 129 additions and 9 deletions

3
.gitignore vendored
View File

@ -3,3 +3,6 @@
# balatromobile # # balatromobile #
/balatro*.apk /balatro*.apk
# Balatro #
*.exe

BIN
Balatro.exe Executable file

Binary file not shown.

View File

@ -1,3 +1 @@
# Balatromobile Flake # Balatro Flake
This repository packages [balatromobile](https://github.com/antipatico/balatromobile) for use with NixOS.

View File

@ -0,0 +1,18 @@
{
stdenvNoCC,
balatro,
balatromobile,
extraArguments ? "",
}:
stdenvNoCC.mkDerivation {
pname = "balatro-android";
version = balatro.version;
dontUnpack = true;
buildPhase = ''
mkdir -p $out/share
${balatromobile}/bin/balatromobile android ${extraArguments} ${balatro}/share/Balatro
install balatro*.apk $out/share
'';
}

15
balatro/globals.patch Normal file
View File

@ -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

82
balatro/package.nix Normal file
View File

@ -0,0 +1,82 @@
{
stdenv,
lib,
love,
lovely-injector,
p7zip,
copyDesktopItems,
makeWrapper,
makeDesktopItem,
requireFile,
withMods ? true,
withLinuxPatch ? true,
balatroExe ?
requireFile {
name = "Balatro.exe";
url = "https://store.steampowered.com/app/2379780/Balatro/";
# Use `nix hash file --sri --type sha256 <path/to/file>` to get the correct hash
hash = "sha256-DXX+FkrM8zEnNNSzesmHiN0V8Ljk+buLf5DE5Z3pP0c=";
},
}:
stdenv.mkDerivation {
pname = "balatro";
version = "1.0.1o";
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";
};
}

View File

@ -1,5 +1,5 @@
{ {
description = "A Python Project Template."; description = "Packages concerning the game Balatro.";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@ -9,20 +9,24 @@
self, self,
nixpkgs, nixpkgs,
... ...
} @ inputs: let }: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in { in {
# `nix build` # `nix build`
packages = forAllSystems (system: rec { packages = forAllSystems (system: rec {
default = balatromobile; balatro = pkgs.${system}.callPackage ./balatro/package.nix {};
balatromobile = pkgs.${system}.callPackage ./default.nix {}; balatromobile = pkgs.${system}.callPackage ./balatromobile/package.nix {};
balatro-android = pkgs.${system}.callPackage ./balatro-android/package.nix {inherit balatro balatromobile;};
}); });
# `nix run` # `nix run`
apps = forAllSystems (system: rec { apps = forAllSystems (system: {
default = balatromobile; balatro = {
program = "${self.packages.${system}.balatro}/bin/balatro";
type = "app";
};
balatromobile = { balatromobile = {
program = "${self.packages.${system}.balatromobile}/bin/balatromobile"; program = "${self.packages.${system}.balatromobile}/bin/balatromobile";
type = "app"; type = "app";