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

zelda64recomp: init at 1.1.1-unstable-2024-10-06 #313013

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions pkgs/by-name/n6/n64recomp/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
lib,
stdenv,
cmake,
fetchFromGitHub,
unstableGitUpdater,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "n64recomp";
version = "0-unstable-2024-09-15";

src = fetchFromGitHub {
owner = "N64Recomp";
repo = "N64Recomp";
rev = "d33d38161798167929b114c2b0fd445f9670e10a";
hash = "sha256-IFGWQ57kHWxqmeHwX0vg6NoTvTqwr4S5/lyvB9I5Fi4=";
fetchSubmodules = true;
};

nativeBuildInputs = [ cmake ];

installPhase = ''
runHook preInstall

install -Dm755 -t $out/bin {N64Recomp,RSPRecomp}
install -Dm644 -t $out/share/licenses/${finalAttrs.pname} ../LICENSE

runHook postInstall
'';

qubitnano marked this conversation as resolved.
Show resolved Hide resolved
passthru.updateScript = unstableGitUpdater { };

meta = {
description = "Tool to statically recompile N64 games into native executables";
homepage = "https://github.com/N64Recomp/N64Recomp";
license = with lib.licenses; [
# N64Recomp
mit

# reverse engineering
unfree
];
maintainers = with lib.maintainers; [ qubitnano ];
mainProgram = "N64Recomp";
platforms = lib.platforms.linux;
hydraPlatforms = [ ];
};
})
46 changes: 46 additions & 0 deletions pkgs/by-name/z6/z64decompress/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
lib,
stdenv,
fetchFromGitHub,
unstableGitUpdater,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "z64decompress";
version = "1.0.3-unstable-2023-12-21";

src = fetchFromGitHub {
owner = "z64tools";
repo = "z64decompress";
rev = "e2b3707271994a2a1b3afc6c3997a7cf6b479765";
hash = "sha256-PHiOeEB9njJPsl6ScdoDVwJXGqOdIIJCZRbIXSieBIY=";
};

makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];

installPhase = ''
runHook preInstall

install -Dm755 -t $out/bin z64decompress
install -Dm644 -t $out/share/licenses/${finalAttrs.pname} LICENSE

runHook postInstall
'';

qubitnano marked this conversation as resolved.
Show resolved Hide resolved
passthru.updateScript = unstableGitUpdater { };

meta = {
description = "Zelda 64 rom decompressor";
homepage = "https://github.com/z64tools/z64decompress";
license = with lib.licenses; [
gpl3Only

# Reverse engineering
unfree
];
maintainers = with lib.maintainers; [ qubitnano ];
mainProgram = "z64decompress";
platforms = lib.platforms.linux;
hydraPlatforms = [ ];
};
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 87ec2d0ebde07e04a9335204b33b8e56a152e9ba Mon Sep 17 00:00:00 2001
From: qubitnano <[email protected]>
Date: Sat, 6 Jul 2024 19:11:01 -0400
Subject: [PATCH] disable cmake downloading gamecontrollerdb.txt

This is fetched in the derivation
---
CMakeLists.txt | 7 -------
1 file changed, 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7acd983..49124ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -116,13 +116,6 @@ add_custom_command(OUTPUT
DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.elf
)

-# Download controller db file for controller support via SDL2
-set(GAMECONTROLLERDB_COMMIT "b1e4090b3d4266e55feb0793efa35792e05faf66")
-set(GAMECONTROLLERDB_URL "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/${GAMECONTROLLERDB_COMMIT}/gamecontrollerdb.txt")
-
-file(DOWNLOAD ${GAMECONTROLLERDB_URL} ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt
- TLS_VERIFY ON)
-
add_custom_target(DownloadGameControllerDB
DEPENDS ${CMAKE_SOURCE_DIR}/gamecontrollerdb.txt)

--
2.45.1

173 changes: 173 additions & 0 deletions pkgs/by-name/ze/zelda64recomp/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
lib,
SDL2,
cmake,
copyDesktopItems,
directx-shader-compiler,
fetchFromGitHub,
fetchurl,
gtk3,
llvmPackages_18,
makeDesktopItem,
makeWrapper,
n64recomp,
ninja,
pkg-config,
requireFile,
vulkan-loader,
wrapGAppsHook3,
z64decompress,
}:

let

baseRom = requireFile {
name = "mm.us.rev1.rom.z64";
Copy link
Contributor

@JohnRTitor JohnRTitor Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay how do I download this file to test this?

message = ''
zelda64recomp currently only supports the US version of Majora's Mask.

Please rename your copy to mm.us.rev1.rom.z64 and add it to the nix store using

nix-store --add-fixed sha256 mm.us.rev1.rom.z64

and rebuild.
'';
hash = "sha256-77E2WzrjYmBFFMD5oaLRH13IaIulvmYKN96/XjvkPys=";
};

gamecontrollerdb = fetchFromGitHub {
owner = "mdqinc";
repo = "SDL_GameControllerDB";
rev = "cfc2bffe0ad29fea2bec7a0f4cb19dead5703ea8";
hash = "sha256-BEN0/q+7iLVmPpOO3i80nuLYpr7KiHd2ONxKmDIJuWU=";
};

in

llvmPackages_18.stdenv.mkDerivation (finalAttrs: {
pname = "zelda64recomp";
version = "1.1.1-unstable-2024-10-06";

src = fetchFromGitHub {
owner = "Zelda64Recomp";
repo = "Zelda64Recomp";
rev = "0d0f64e32f15c2ecc95c9e4945caa37ec19ce1ce";
hash = "sha256-JtNXTP6XrIzjccfRzffZ5uRhuLbfAlkfGmGO18yEZPc=";
fetchSubmodules = true;
};

nativeBuildInputs = [
cmake
copyDesktopItems
llvmPackages_18.lld
makeWrapper
ninja
pkg-config
wrapGAppsHook3
];

buildInputs = [
SDL2
gtk3
vulkan-loader
];

desktopItems = [
(makeDesktopItem {
name = "Zelda64Recompiled";
icon = "zelda64recomp";
exec = "Zelda64Recompiled";
comment = "Static recompilation of Majora's Mask";
genericName = "Static recompilation of Majora's Mask";
desktopName = "Zelda 64: Recompiled";
categories = [ "Game" ];
})
];

preConfigure = ''
ln -s ${baseRom} ./mm.us.rev1.rom.z64
${lib.getExe z64decompress} mm.us.rev1.rom.z64 mm.us.rev1.rom_uncompressed.z64
cp ${n64recomp}/bin/* .
cp ${gamecontrollerdb}/gamecontrollerdb.txt gamecontrollerdb.txt

./N64Recomp us.rev1.toml
./RSPRecomp aspMain.us.rev1.toml
./RSPRecomp njpgdspMain.us.rev1.toml

substituteInPlace lib/rt64/CMakeLists.txt \
--replace-fail "\''${PROJECT_SOURCE_DIR}/src/contrib/dxc/lib/x64" "${directx-shader-compiler}/lib/" \
--replace-fail "\''${PROJECT_SOURCE_DIR}/src/contrib/dxc/bin/x64/dxc" "${directx-shader-compiler}/bin/dxc" \
--replace-fail "\''${PROJECT_SOURCE_DIR}/src/contrib/dxc/inc" "${directx-shader-compiler.src}/include/dxc"

substituteInPlace CMakeLists.txt \
--replace-fail "\''${PROJECT_SOURCE_DIR}/lib/rt64/src/contrib/dxc/lib/x64" "${directx-shader-compiler}/lib/" \
--replace-fail "\''${PROJECT_SOURCE_DIR}/lib/rt64/src/contrib/dxc/bin/x64/dxc" "${directx-shader-compiler}/bin/dxc"
'';

# This is required or else nothing will build
hardeningDisable = [
"format"
"pic"
"stackprotector"
"zerocallusedregs"
];

patches = [
# Disable cmake attempting to fetch gamecontrollerdb
./0001-disable-cmake-downloading-gamecontrollerdb.txt.patch
];

installPhase = ''
runHook preInstall

install -Dm755 -t $out/bin Zelda64Recompiled
install -Dm644 -t $out/share ../gamecontrollerdb.txt
install -Dm644 ../icons/512.png $out/share/icons/hicolor/scalable/apps/zelda64recomp.png
ln -s $out/share/gamecontrollerdb.txt $out/bin/gamecontrollerdb.txt
cp -r ../assets $out/bin/

install -Dm644 -t $out/share/licenses/${finalAttrs.pname} ../COPYING
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/N64ModernRuntime ../lib/N64ModernRuntime/COPYING
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/RmlUi ../lib/RmlUi/LICENSE.txt
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/SDL_GameControllerDB ${gamecontrollerdb}/LICENSE
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/lunasvg ../lib/lunasvg/LICENSE
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/rt64 ../lib/rt64/LICENSE
install -Dm644 -t $out/share/licenses/${finalAttrs.pname}/sse2neon ../lib/sse2neon/LICENSE

runHook postInstall
'';

preFixup = ''
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]}
)
'';

postFixup = ''
# This is needed as Zelda64Recompiled will segfault when not run from the same directory as the binary
# It will also exit if run with SDL_VIDEODRIVER=wayland
source "${makeWrapper}/nix-support/setup-hook"
wrapProgram $out/bin/Zelda64Recompiled \
--run "cd $out/bin/" \
--set SDL_VIDEODRIVER x11
'';

meta = {
description = "Static recompilation of Majora's Mask (and soon Ocarina of Time) for PC (Windows/Linux)";
homepage = "https://github.com/Zelda64Recomp/Zelda64Recomp";
license = with lib.licenses; [
# Zelda64Recomp, N64ModernRuntime
gpl3Only

# RT64, RmlUi, lunasvg, sse2neon
mit

# reverse engineering
unfree
];
maintainers = with lib.maintainers; [ qubitnano ];
mainProgram = "Zelda64Recompiled";
platforms = [ "x86_64-linux" ];
hydraPlatforms = [ ];
};
})
Loading