edopro: init at 40.1.4 (#342365)
Co-authored-by: Cosima Neidahl <opna2608@protonmail.com>
This commit is contained in:
parent
868c371827
commit
2b2950fbc0
14
pkgs/by-name/ed/edopro/deps.nix
generated
Normal file
14
pkgs/by-name/ed/edopro/deps.nix
generated
Normal file
@ -0,0 +1,14 @@
|
||||
# This is automatically generated by the update script.
|
||||
# DO NOT MANUALLY EDIT.
|
||||
{
|
||||
assets-hash = "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k=";
|
||||
edopro-version = "40.1.4";
|
||||
edopro-rev = "c713e23491a1e55c9d8e91257e5f2b5873696b9b";
|
||||
edopro-hash = "sha256-2E1cjG0FONu/fbr67/3qRCKQ1W/wPznClEWsMa1FAzo=";
|
||||
irrlicht-version = "1.9.0-unstable-2023-02-18";
|
||||
irrlicht-rev = "7edde28d4f8c0c3589934c398a3a441286bb7c22";
|
||||
irrlicht-hash = "sha256-Q2tNiYE/enZPqA5YhUe+Tkvmqtmmz2E0OqTRUDnt+UA=";
|
||||
ocgcore-version = "0-unstable-2022-09-15";
|
||||
ocgcore-rev = "4a872ad7686e0d00ee4c1c051e90fc07c40613d4";
|
||||
ocgcore-hash = "sha256-s3DOHrZilRUy6fbXObNiLRinxpdHY99vDOmS/ZfOI78=";
|
||||
}
|
29
pkgs/by-name/ed/edopro/ocgcore-lua-symbols.patch
Normal file
29
pkgs/by-name/ed/edopro/ocgcore-lua-symbols.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 41e750142b44465f3af197b7e2f0d6f54fc48c2d Mon Sep 17 00:00:00 2001
|
||||
From: OPNA2608 <opna2608@protonmail.com>
|
||||
Date: Mon, 21 Oct 2024 17:42:24 +0200
|
||||
Subject: [PATCH] Mark Lua symbols as C symbols
|
||||
|
||||
Otherwise linking against our Lua built by a C-compiler fails due to the symbols being resolved as C++ symbols.
|
||||
---
|
||||
interpreter.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/interpreter.h b/interpreter.h
|
||||
index 6c405a1..c471ecb 100644
|
||||
--- a/interpreter.h
|
||||
+++ b/interpreter.h
|
||||
@@ -9,9 +9,11 @@
|
||||
#define INTERPRETER_H_
|
||||
|
||||
// Due to longjmp behaviour, we must build Lua as C++ to avoid UB
|
||||
+extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
+}
|
||||
|
||||
#include "common.h"
|
||||
#include <unordered_map>
|
||||
--
|
||||
2.44.1
|
||||
|
318
pkgs/by-name/ed/edopro/package.nix
Normal file
318
pkgs/by-name/ed/edopro/package.nix
Normal file
@ -0,0 +1,318 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchzip,
|
||||
makeWrapper,
|
||||
premake5,
|
||||
writeShellScriptBin,
|
||||
runCommandLocal,
|
||||
symlinkJoin,
|
||||
imagemagick,
|
||||
bzip2,
|
||||
curl,
|
||||
flac,
|
||||
# Use fmt 10+ after release 40.1.4+
|
||||
fmt_9,
|
||||
freetype,
|
||||
libevent,
|
||||
libgit2,
|
||||
libGL,
|
||||
libGLU,
|
||||
libjpeg,
|
||||
libpng,
|
||||
libvorbis,
|
||||
libX11,
|
||||
libxkbcommon,
|
||||
libXxf86vm,
|
||||
lua5_3,
|
||||
mono,
|
||||
nlohmann_json,
|
||||
openal,
|
||||
SDL2,
|
||||
sqlite,
|
||||
wayland,
|
||||
egl-wayland,
|
||||
covers_url ? "https://pics.projectignis.org:2096/pics/cover/{}.jpg",
|
||||
fields_url ? "https://pics.projectignis.org:2096/pics/field/{}.png",
|
||||
# While ygoprodeck has higher quality images, "spamming" of their api results in a ban.
|
||||
# Thats why this link can change since it's compiled into the program, However it will
|
||||
# download assets when needed so it is unlikely to get banned. Unless you search the
|
||||
# card list with no filters of any kind. When testing use ProjectIgnis' website instead.
|
||||
pics_url ? "https://images.ygoprodeck.com/images/cards/{}.jpg",
|
||||
}:
|
||||
let
|
||||
archLabel =
|
||||
{
|
||||
"x86_64-linux" = "x64";
|
||||
"aarch64-linux" = "arm64";
|
||||
}
|
||||
.${stdenv.hostPlatform.system}
|
||||
or (throw "${stdenv.hostPlatform.system} is an unsupported arch label for edopro");
|
||||
|
||||
deps = import ./deps.nix;
|
||||
in
|
||||
let
|
||||
assets = fetchzip {
|
||||
url = "https://github.com/ProjectIgnis/edopro-assets/releases/download/${deps.edopro-version}/ProjectIgnis-EDOPro-${deps.edopro-version}-linux.tar.gz";
|
||||
hash = deps.assets-hash;
|
||||
};
|
||||
|
||||
irrlicht-edopro = stdenv.mkDerivation {
|
||||
pname = "irrlicht-edopro";
|
||||
version = deps.irrlicht-version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "edo9300";
|
||||
repo = "irrlicht1-8-4";
|
||||
rev = deps.irrlicht-rev;
|
||||
hash = deps.irrlicht-hash;
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
libGLU
|
||||
libX11
|
||||
libxkbcommon
|
||||
libXxf86vm
|
||||
wayland
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
buildFlags = [
|
||||
"NDEBUG=1"
|
||||
];
|
||||
makeFlags = [
|
||||
"-C"
|
||||
"source/Irrlicht"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{bin,include}
|
||||
cp lib/Linux/libIrrlicht.a $out/bin
|
||||
cp -r include/* $out/include
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
ocgcore = stdenv.mkDerivation {
|
||||
pname = "ygopro-core";
|
||||
version = deps.ocgcore-version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "edo9300";
|
||||
repo = "ygopro-core";
|
||||
rev = deps.ocgcore-rev;
|
||||
hash = deps.ocgcore-hash;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
patches = [
|
||||
./ocgcore-lua-symbols.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ premake5 ];
|
||||
|
||||
buildInputs = [ lua5_3 ];
|
||||
|
||||
preBuild = ''
|
||||
premake5 gmake2 \
|
||||
--lua-path="${lua5_3}"
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
buildFlags = [
|
||||
"verbose=true"
|
||||
"config=release"
|
||||
"ocgcoreshared"
|
||||
];
|
||||
makeFlags = [
|
||||
"-C"
|
||||
"build"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 -t $out/lib bin/release/libocgcore${stdenv.hostPlatform.extensions.sharedLibrary}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
edopro = stdenv.mkDerivation {
|
||||
pname = "edopro";
|
||||
version = deps.edopro-version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "edo9300";
|
||||
repo = "edopro";
|
||||
rev = deps.edopro-rev;
|
||||
hash = deps.edopro-hash;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
premake5
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
curl
|
||||
flac
|
||||
fmt_9
|
||||
freetype
|
||||
irrlicht-edopro
|
||||
libevent
|
||||
libgit2
|
||||
libjpeg
|
||||
libpng
|
||||
libvorbis
|
||||
lua5_3
|
||||
nlohmann_json
|
||||
ocgcore
|
||||
openal
|
||||
SDL2
|
||||
sqlite
|
||||
];
|
||||
|
||||
# nixpkgs' gcc stack currently appears to not support LTO
|
||||
postPatch = ''
|
||||
substituteInPlace premake5.lua \
|
||||
--replace-fail 'flags "LinkTimeOptimization"' 'removeflags "LinkTimeOptimization"'
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
premake5 gmake2 \
|
||||
--architecture=${archLabel} \
|
||||
--covers=\"${covers_url}\" \
|
||||
--fields=\"${fields_url}\" \
|
||||
--pics=\"${pics_url}\" \
|
||||
--prebuilt-core="${lib.getLib ocgcore}/lib" \
|
||||
--sound=sfml
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
env = {
|
||||
# remove after release 40.1.4+
|
||||
# https://discord.com/channels/170601678658076672/792223685112889344/1286043823293599785
|
||||
CXXFLAGS = "-include cstdint";
|
||||
LDFLAGS = "-I ${irrlicht-edopro}/include -L ${irrlicht-edopro}/bin";
|
||||
};
|
||||
buildFlags = [
|
||||
"verbose=true"
|
||||
"config=release_${archLabel}"
|
||||
"ygopro"
|
||||
];
|
||||
makeFlags = [
|
||||
"-C"
|
||||
"build"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp bin/${archLabel}/release/ygopro $out/bin
|
||||
wrapProgram $out/bin/ygopro \
|
||||
--prefix PATH : ${lib.makeBinPath [ mono ]} \
|
||||
--prefix LD_LIBRARY_PATH : ${
|
||||
lib.makeLibraryPath [
|
||||
libGL
|
||||
libX11
|
||||
libxkbcommon
|
||||
libXxf86vm
|
||||
sqlite
|
||||
wayland
|
||||
egl-wayland
|
||||
]
|
||||
}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
edopro-script =
|
||||
let
|
||||
assetsToCopy = lib.concatStringsSep "," [
|
||||
# Needed if we download files from ProjectIgnis' website or any https only website.
|
||||
"cacert.pem"
|
||||
"config"
|
||||
"deck"
|
||||
"COPYING.txt"
|
||||
"expansions"
|
||||
"lflists"
|
||||
"notices"
|
||||
"puzzles"
|
||||
"fonts"
|
||||
"script"
|
||||
"skin"
|
||||
"sound"
|
||||
"textures"
|
||||
"WindBot"
|
||||
];
|
||||
in
|
||||
writeShellScriptBin "edopro" ''
|
||||
set -eu
|
||||
EDOPRO_DIR="''${XDG_DATA_HOME:-$HOME/.local/share}/edopro"
|
||||
|
||||
if [ ! -d $EDOPRO_DIR ]; then
|
||||
mkdir -p $EDOPRO_DIR
|
||||
cp -r --no-preserve=all ${assets}/{${assetsToCopy}} $EDOPRO_DIR
|
||||
chmod -R go-rwx $EDOPRO_DIR
|
||||
|
||||
rm $EDOPRO_DIR/config/io.github.edo9300.EDOPro.desktop.in
|
||||
fi
|
||||
|
||||
exec ${edopro}/bin/ygopro -C $EDOPRO_DIR $@
|
||||
'';
|
||||
|
||||
edopro-desktop = runCommandLocal "io.github.edo9300.EDOPro.desktop" { } ''
|
||||
cp ${assets}/config/io.github.edo9300.EDOPro.desktop.in desktop-template
|
||||
|
||||
sed '/Path=/d' -i desktop-template
|
||||
sed 's/Exec=.*/Exec=EDOPro/' -i desktop-template
|
||||
sed 's/Icon=.*/Icon=EDOPro/' -i desktop-template
|
||||
|
||||
install -D desktop-template $out/share/applications/io.github.edo9300.EDOPro.desktop
|
||||
'';
|
||||
in
|
||||
symlinkJoin {
|
||||
name = "edopro-application-${deps.edopro-version}";
|
||||
version = deps.edopro-version;
|
||||
paths = [
|
||||
edopro-script
|
||||
edopro-desktop
|
||||
];
|
||||
|
||||
postBuild = ''
|
||||
mkdir -p $out/share/icons/hicolor/256x256/apps/
|
||||
${imagemagick}/bin/magick \
|
||||
${assets}/textures/AppIcon.png \
|
||||
-resize 256x256 \
|
||||
$out/share/icons/hicolor/256x256/apps/EDOPro.png
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.py;
|
||||
|
||||
meta = {
|
||||
description = "Bleeding-edge automatic duel simulator, a fork of the YGOPro client";
|
||||
homepage = "https://projectignis.github.io";
|
||||
changelog = "https://github.com/edo9300/edopro/releases";
|
||||
license = lib.licenses.agpl3Plus;
|
||||
maintainers = with lib.maintainers; [
|
||||
OPNA2608
|
||||
redhawk
|
||||
];
|
||||
mainProgram = "edopro";
|
||||
# This is likely a very easy app to port if you're interested.
|
||||
# We just have no way to test on other platforms.
|
||||
platforms = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
};
|
||||
}
|
119
pkgs/by-name/ed/edopro/update.py
Executable file
119
pkgs/by-name/ed/edopro/update.py
Executable file
@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python -p nix-prefetch-github python3Packages.githubkit
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
from githubkit import GitHub, UnauthAuthStrategy
|
||||
from githubkit.versions.latest.models import (
|
||||
Commit,
|
||||
ContentSubmodule,
|
||||
Tag,
|
||||
)
|
||||
|
||||
DEPS_PATH: str = "./pkgs/by-name/ed/edopro/deps.nix"
|
||||
|
||||
with GitHub(UnauthAuthStrategy()) as github:
|
||||
edopro: Tag = github.rest.repos.list_tags("edo9300", "edopro").parsed_data[0]
|
||||
|
||||
ocgcore_submodule: ContentSubmodule = github.rest.repos.get_content(
|
||||
"edo9300", "edopro", "ocgcore"
|
||||
).parsed_data
|
||||
|
||||
ocgcore: Commit = github.rest.repos.get_commit(
|
||||
"edo9300", "ygopro-core", ocgcore_submodule.sha
|
||||
).parsed_data
|
||||
|
||||
# This dep is not versioned in anyway and is why we check below to see if this is a new version.
|
||||
irrlicht: Commit = github.rest.repos.list_commits(
|
||||
"edo9300", "irrlicht1-8-4"
|
||||
).parsed_data[0]
|
||||
|
||||
irrlicht: Commit = github.rest.repos.get_commit(
|
||||
"edo9300", "irrlicht1-8-4", "7edde28d4f8c0c3589934c398a3a441286bb7c22"
|
||||
).parsed_data
|
||||
|
||||
|
||||
edopro_working_version: str = ""
|
||||
try:
|
||||
with open(DEPS_PATH, "r") as file:
|
||||
for line in file.readlines():
|
||||
if "edopro-version" in line:
|
||||
edopro_working_version = line.split('"')[1]
|
||||
except FileNotFoundError:
|
||||
print("Error: Dep file not found.")
|
||||
exit(2)
|
||||
|
||||
if edopro_working_version == "":
|
||||
print("Working version is unbound")
|
||||
exit(5)
|
||||
|
||||
if edopro_working_version == edopro.name:
|
||||
print("Version is updated")
|
||||
exit(0)
|
||||
|
||||
|
||||
def get_hash(owner: str, repo: str, rev: str, submodule: bool = False) -> str:
|
||||
args: list[str] = ["nix-prefetch-github", owner, repo, "--rev", rev]
|
||||
|
||||
if submodule:
|
||||
args.append("--fetch-submodules")
|
||||
|
||||
out: subprocess.CompletedProcess = subprocess.run(args, capture_output=True)
|
||||
out_json = json.loads(out.stdout.decode())
|
||||
|
||||
return out_json["hash"]
|
||||
|
||||
|
||||
edopro_hash = get_hash("edo9300", "edopro", edopro.commit.sha, submodule=True)
|
||||
ocgcore_hash = get_hash("edo9300", "ygopro-core", ocgcore.sha)
|
||||
irrlicht_hash = get_hash("edo9300", "irrlicht1-8-4", irrlicht.sha)
|
||||
|
||||
asset_legacy_hash: str = (
|
||||
subprocess.run(
|
||||
[
|
||||
"nix-prefetch-url",
|
||||
f"https://github.com/ProjectIgnis/edopro-assets/releases/download/{edopro.name}/ProjectIgnis-EDOPro-{edopro.name}-linux.tar.gz",
|
||||
"--unpack",
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
)
|
||||
asset_hash: str = (
|
||||
subprocess.run(
|
||||
[
|
||||
"nix",
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"hash",
|
||||
"to-sri",
|
||||
"--type",
|
||||
"sha256",
|
||||
asset_legacy_hash,
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
)
|
||||
|
||||
|
||||
with open(DEPS_PATH, "w") as file:
|
||||
contents = f"""# This is automatically generated by the update script.
|
||||
# DO NOT MANUALLY EDIT.
|
||||
{{
|
||||
assets-hash = "{asset_hash}";
|
||||
edopro-version = "{edopro.name}";
|
||||
edopro-rev = "{edopro.commit.sha}";
|
||||
edopro-hash = "{edopro_hash}";
|
||||
irrlicht-version = "{"1.9.0-unstable-" + irrlicht.commit.committer.date.split("T")[0]}";
|
||||
irrlicht-rev = "{irrlicht.sha}";
|
||||
irrlicht-hash = "{irrlicht_hash}";
|
||||
ocgcore-version = "{"0-unstable-" + ocgcore.commit.committer.date.split("T")[0]}";
|
||||
ocgcore-rev = "{ocgcore.sha}";
|
||||
ocgcore-hash = "{ocgcore_hash}";
|
||||
}}
|
||||
"""
|
||||
|
||||
file.write(contents)
|
Loading…
Reference in New Issue
Block a user