Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edopro: Fix lua scripts failing #352

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions pkgs/_sources/generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,19 @@
},
"version": "473af98e3f5eb015a2b481481abbcc8c8027b484"
},
"edopro-distribution": {
"edopro-assets": {
"cargoLocks": null,
"date": "2024-06-13",
"date": null,
"extract": null,
"name": "edopro-distribution",
"name": "edopro-assets",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": true,
"leaveDotGit": true,
"name": null,
"owner": "ProjectIgnis",
"repo": "Distribution",
"rev": "286db345033c79cab6e36a8f06de3468008ff8cd",
"sha256": "sha256-ojbN+QH1nS2NCXDp4kwvEKWTxU+PO94gs9hbTGM0i70=",
"type": "github"
"sha256": "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k=",
"type": "tarball",
"url": "https://github.com/ProjectIgnis/edopro-assets/releases/download/40.1.4/ProjectIgnis-EDOPro-40.1.4-linux.tar.gz"
},
"version": "286db345033c79cab6e36a8f06de3468008ff8cd"
"version": "40.1.4"
},
"edopro-irrlicht": {
"cargoLocks": null,
Expand Down
18 changes: 6 additions & 12 deletions pkgs/_sources/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@
};
date = "2024-07-18";
};
edopro-distribution = {
pname = "edopro-distribution";
version = "286db345033c79cab6e36a8f06de3468008ff8cd";
src = fetchFromGitHub {
owner = "ProjectIgnis";
repo = "Distribution";
rev = "286db345033c79cab6e36a8f06de3468008ff8cd";
fetchSubmodules = true;
deepClone = false;
leaveDotGit = true;
sha256 = "sha256-3I5gRE+TPcLjosb7azaY8ycq58SRqQC2qGC4fGSYza4=";
edopro-assets = {
pname = "edopro-assets";
version = "40.1.4";
src = fetchTarball {
url = "https://github.com/ProjectIgnis/edopro-assets/releases/download/40.1.4/ProjectIgnis-EDOPro-40.1.4-linux.tar.gz";
sha256 = "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k=";
};
date = "2024-06-13";
};
edopro-irrlicht = {
pname = "edopro-irrlicht";
Expand Down
131 changes: 63 additions & 68 deletions pkgs/applications/edopro.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
lib,
stdenv,
sources,

# build deps
premake5,
writeShellScriptBin,
makeDesktopItem,
runCommandLocal,
symlinkJoin,
imagemagick,

Expand All @@ -21,63 +22,31 @@
libjpeg,
libpng,
libvorbis,
lua5_4_compat,
nlohmann_json,
noto-fonts-cjk-sans,
openal,
sqlite,

# Irrlicht deps
wayland,
egl-wayland,
libxkbcommon,
}:
let
lua = lua5_4_compat;
font = "${noto-fonts-cjk-sans}/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc";

irrlicht-edopro = irrlicht.overrideAttrs (old: {
inherit (sources.edopro-irrlicht) pname version src;
buildInputs = old.buildInputs ++ [
wayland
libxkbcommon
];
});

ocgcore = stdenv.mkDerivation {
inherit (sources.edopro) version src;
pname = sources.edopro.pname + "-ocgcore";

nativeBuildInputs = [ premake5 ];
buildInputs = [ lua ];

enableParallelBuilding = true;
buildFlags = [ "verbose=true config=release ocgcoreshared" ];

# nixpkgs' lua is compiled as C, but lua can also be compiled as
# C++. Due to name mangling, a C-compiled lua will not be able to
# link to a C++ project without some hoops, but edopro normally
# builds it as a C++ library, so their code isn't used to this
# edge case.
#
# Hence we need to change the included headers a bit.
postPatch = ''
sed -i 's/#include <lua.h>/#include <lua.hpp>/g' ocgcore/*.*
sed -i '/#include <lualib.h>/d' ocgcore/*.*
sed -i '/#include <lauxlib.h>/d' ocgcore/*.*
'';

preBuild = ''
cd ocgcore
premake5 gmake2 --lua-path='${lua}'
cd build
makeFlagsArray+=(sharedlib NDEBUG=1)
'';
});

installPhase = ''
mkdir -p $out/lib
cp -r ../bin/release/* $out/lib/
'';
};

font = "${noto-fonts-cjk-sans}/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc";
edopro = stdenv.mkDerivation {
inherit (sources.edopro) pname version src;

Expand All @@ -95,7 +64,6 @@ let
libjpeg
libpng
libvorbis
lua
nlohmann_json
openal
sqlite
Expand All @@ -111,55 +79,82 @@ let
NIX_CFLAGS_COMPILE = "-I ${irrlicht-edopro}/include/irrlicht/";

enableParallelBuilding = true;
buildFlags = [ "verbose=true config=release_x64 ygopro" ];
buildFlags = [ "verbose=true config=release_x64 ygoprodll" ];

preBuild = ''
premake5 gmake2 \
--sound=sfml \
--no-joystick=true \
--os=linux \
--prebuilt-core='${ocgcore}/lib' \
--no-core \
--architecture=x64 \
--bundled-font='${font}' \
--lua-path='${lua}'
--bundled-font='${font}'

cd build
'';

installPhase = ''
mkdir -p $out/{lib,bin}
cp ../bin/x64/release/ygopro $out/bin/
cp ../bin/x64/release/ygoprodll $out/bin/
cp ../bin/x64/release/*.a $out/lib
'';
};

edopro-script = writeShellScriptBin "EDOPro" ''
set -eu
EDOPRO_DIR="''${XDG_DATA_HOME:-~/.local/share}/edopro"
edopro-script =
let
assetsToCopy = lib.concatStringsSep "," [
"config"
"deck"
"COPYING.txt"
"expansions"
# We grab the ocgcore from the official release bundle, on
# upstream suggestion; this is completely static and has no
# dependencies, so it should be fine.
"libocgcore.so"
"lflists"
"notices"
"puzzles"
"fonts"
"script"
"skin"
"sound"
"textures"
];
in
writeShellScriptBin "EDOPro" ''
set -eu
EDOPRO_DIR="''${XDG_DATA_HOME:-~/.local/share}/edopro"

if [ ! -d "''${EDOPRO_DIR}" ]; then
mkdir -p "''${EDOPRO_DIR}"
cp -r ${sources.edopro-assets.src}/{${assetsToCopy}} "''${EDOPRO_DIR}/"

find "''${EDOPRO_DIR}" -type d -exec chmod u=rwx,go-rwx {} +
find "''${EDOPRO_DIR}" -type f -exec chmod u=rw,go-rwx {} +

rm "''${EDOPRO_DIR}/config/io.github.edo9300.EDOPro.desktop.in"
fi

export LD_LIBRARY_PATH='${
lib.makeLibraryPath [
wayland
egl-wayland
libxkbcommon
]
}';

exec ${edopro}/bin/ygoprodll -C "''${EDOPRO_DIR}" $@
'';

if [ ! -d "''${EDOPRO_DIR}" ]; then
mkdir -p "''${EDOPRO_DIR}"
cp -r ${sources.edopro-distribution.src}/*/ "''${EDOPRO_DIR}/"
find "''${EDOPRO_DIR}" -type d -exec chmod 700 {} +
find "''${EDOPRO_DIR}" -type f -exec chmod 600 {} +
fi
edopro-desktop = runCommandLocal "io.github.edo9300.EDOPro.desktop" { } ''
cp ${sources.edopro-assets.src}/config/io.github.edo9300.EDOPro.desktop.in desktop-template

exec ${edopro}/bin/ygopro -C "''${EDOPRO_DIR}" $@
'';
sed '/Path=/d' -i desktop-template
sed 's/Exec=.*/Exec=EDOPro/' -i desktop-template
sed 's/Icon=.*/Icon=EDOPro/' -i desktop-template

edopro-desktop = makeDesktopItem {
name = "edopro-desktop";
desktopName = "EDOPro";
genericName = "Yu-Gi-Oh! simulator";
icon = "EDOPro";
exec = "EDOPro";
# TODO(tlater): Add mime types - can use an XML file like [this
# one](https://github.com/NixOS/nixpkgs/blob/a8b599256e0692225c2b476530d0a5b0f65e34ef/pkgs/applications/graphics/antimony/mimetype.xml)
# to create the mime types, then add the `mimeTypes` attr here to
# list the ones that associate to EDOPro.
categories = [ "Game" ];
keywords = [ "yugioh" ];
};
install -D desktop-template $out/share/applications/io.github.edo9300.EDOPro.desktop
'';
in
symlinkJoin {
name = "edopro-application";
Expand All @@ -172,7 +167,7 @@ symlinkJoin {
postBuild = ''
mkdir -p $out/share/icons/hicolor/256x256/apps/
${imagemagick}/bin/magick \
${sources.edopro-distribution.src}/textures/AppIcon.png \
${sources.edopro-assets.src}/textures/AppIcon.png \
-resize 256x256 \
$out/share/icons/hicolor/256x256/apps/EDOPro.png
'';
Expand Down
9 changes: 4 additions & 5 deletions pkgs/nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ src.git = "https://github.com/edo9300/edopro.git"
fetch.github = "edo9300/edopro"
git.fetchSubmodules = true

[edopro-distribution]
src.git = "https://github.com/ProjectIgnis/Distribution.git"
fetch.github = "ProjectIgnis/Distribution"
git.fetchSubmodules = true
git.leaveDotGit = true
[edopro-assets]
src.webpage = "https://projectignis.github.io/download.html"
src.regex = 'https://github\.com/ProjectIgnis/edopro-assets/releases/download/(?P<version>\d+\.\d+\.\d+)/ProjectIgnis-EDOPro-\1-linux\.tar\.gz'
fetch.tarball = "https://github.com/ProjectIgnis/edopro-assets/releases/download/$ver/ProjectIgnis-EDOPro-$ver-linux.tar.gz"

[edopro-irrlicht]
src.git = "https://github.com/edo9300/irrlicht1-8-4.git"
Expand Down