better coopdx
This commit is contained in:
112
coopdx2.nix
Normal file
112
coopdx2.nix
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
{
|
||||
# callPackage,
|
||||
fetchFromGitHub,
|
||||
autoPatchelfHook,
|
||||
zlib,
|
||||
curl,
|
||||
SDL2,
|
||||
hexdump,
|
||||
stdenv,
|
||||
writeTextFile,
|
||||
lib,
|
||||
bash,
|
||||
python3,
|
||||
requireFile,
|
||||
baseRom ? requireFile {
|
||||
name = "baserom.us.z64";
|
||||
message = "bla";
|
||||
sha256 = "17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91";
|
||||
},
|
||||
|
||||
enableTextureFix ? true,
|
||||
enableDiscord ? false,
|
||||
enableCoopNet ? true,
|
||||
}:
|
||||
let
|
||||
libc_hack = writeTextFile {
|
||||
name = "libc-hack";
|
||||
# https://stackoverflow.com/questions/21768542/libc-h-no-such-file-or-directory-when-compiling-nanomsg-pipeline-sample
|
||||
text = ''
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
'';
|
||||
destination = "/include/libc.h";
|
||||
};
|
||||
target = stdenv.targetPlatform;
|
||||
bits =
|
||||
if target.is64bit then
|
||||
"64"
|
||||
else if target.is32bit then
|
||||
"32"
|
||||
else
|
||||
throw "unspported bits";
|
||||
pname = "sm64coopdx";
|
||||
version = "1.0.3";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "coop-deluxe";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
hash = "sha256-cIH3escLFMcHgtFxeSKIo5nZXvaknti+EVt72uB4XXc=";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
python3
|
||||
zlib
|
||||
curl
|
||||
libc_hack
|
||||
SDL2
|
||||
hexdump
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
# Normally there's no need to set TARGET_ARCH, but if we don't it adds -march=native which is impure
|
||||
makeFlags = [
|
||||
"BREW_PREFIX=/not-exist"
|
||||
"DISCORD_SDK=${if enableDiscord then "1" else "0"}"
|
||||
"TEXTURE_FIX=${if enableTextureFix then "1" else "0"}"
|
||||
"COOPNET=${if enableCoopNet then "1" else "0"}"
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
ln -s ${baseRom} baserom.us.z64
|
||||
substituteInPlace Makefile \
|
||||
--replace-fail ' -march=$(TARGET_ARCH) ' ' '
|
||||
# workaround a bug in the build
|
||||
# see https://github.com/coop-deluxe/sm64coopdx/issues/186#issuecomment-2216163935
|
||||
# this can likely be removed when the next version releases
|
||||
make build/us_pc/sound/sequences.bin
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
local built=$PWD/build/us_pc
|
||||
|
||||
share=$out/share/${pname}
|
||||
mkdir -p $share
|
||||
cp $built/${pname} $share/${pname}-unwrapped
|
||||
cp -r $built/{dynos,lang,mods,palettes} $share
|
||||
ln -s ${baseRom} $share/baserom.us.z64
|
||||
|
||||
${lib.optionalString enableDiscord ''
|
||||
cp $built/libdiscord_game_sdk* $share
|
||||
''}
|
||||
|
||||
mkdir -p $out/bin
|
||||
(
|
||||
echo '#!${bash}/bin/bash'
|
||||
echo "cd $out/share/${pname}"
|
||||
echo 'exec ./${pname}-unwrapped "$@"'
|
||||
) > $out/bin/${pname}
|
||||
chmod a+x $out/bin/${pname}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
@@ -309,7 +309,7 @@
|
||||
{
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
packages = {
|
||||
sm64coopdx = pkgs.callPackage ./coopdx.nix { inherit nixpkgs; };
|
||||
sm64coopdx = pkgs.callPackage ./coopdx2.nix { };
|
||||
# snmpb = pkgs.libsForQt5.callPackage ./packages/snmpb/package.nix { };
|
||||
# snmp-mibs-downloader = pkgs.callPackage ./packages/snmp-mibs-downloader.nix { };
|
||||
authorizedKeys = pkgs.writeText "authorizedKeys" (
|
||||
|
Reference in New Issue
Block a user