sm64coopdx: acquire from upstream nixpkgs PR

This commit is contained in:
2024-10-03 12:39:39 +00:00
parent 083dcd03f7
commit 588fc12bdf
7 changed files with 21 additions and 111 deletions

View File

@@ -258,8 +258,8 @@ in
# "pinball" # 3d pinball; kb/mouse. old sourceforge project
# "powermanga" # STYLISH space invaders derivative (keyboard-only)
"shattered-pixel-dungeon" # doesn't cross compile
"sm64ex-coop"
"sm64ex-coop-deluxe"
# "sm64ex-coop"
"sm64coopdx"
"space-cadet-pinball" # LMB/RMB controls (bindable though. volume buttons?)
"steam"
"superTux" # keyboard-only controls

View File

@@ -161,8 +161,8 @@
./sfeed.nix
./shadow.nix
./signal-desktop.nix
./sm64coopdx.nix
./sm64ex-coop.nix
./sm64ex-coop-deluxe.nix
./soundconverter.nix
./splatmoji.nix
./spot.nix

View File

@@ -1,9 +1,9 @@
{ config, lib, ... }:
let
cfg = config.sane.programs.sm64ex-coop-deluxe;
cfg = config.sane.programs.sm64coopdx;
in
{
sane.programs.sm64ex-coop-deluxe = {
sane.programs.sm64coopdx = {
sandbox.net = "all";
sandbox.whitelistAudio = true;
sandbox.whitelistDri = true;

View File

@@ -1,6 +0,0 @@
# "baseRom" is used by `sm64ex`, `sm64ex-coop`: broken packages which fail to provide this dependency
{ fetchurl }:
fetchurl {
url = "https://github.com/jb1361/Super-Mario-64-AI/raw/development/Super%20Mario%2064%20(USA).z64";
hash = "sha256-F84Hc0PGEz+Mny1tbZpKtiyM0qpXxArqH0kLTIuyHZE=";
}

View File

@@ -72,6 +72,12 @@ in
hash = "sha256-qAoDQuv34gV1Etc/6Kj5U0c3HHsPAUR1Fshb456i5pA=";
})
(fetchpatch' {
title = "Add package sm64coopdx";
prUrl = "https://github.com/NixOS/nixpkgs/pull/344305";
hash = "sha256-46KFQ7p0QMZVOJRr207LNPHyA0RGVOgWgNn01BklNfg=";
})
# (fetchpatch' {
# # this causes a rebuild of systemd and everything above it:
# # PR against staging is live: <https://github.com/NixOS/nixpkgs/pull/332399>

View File

@@ -0,0 +1,10 @@
# "baseRom" (previously) / "sm64baserom" (in the future) is used by `sm64coopdx`, `sm64ex-coop`: braindead packages which use `requireFile` instead of fetching their sources.
{ fetchurl, ... }:
let
baserom = fetchurl {
url = "https://github.com/jb1361/Super-Mario-64-AI/raw/development/Super%20Mario%2064%20(USA).z64";
hash = "sha256-F84Hc0PGEz+Mny1tbZpKtiyM0qpXxArqH0kLTIuyHZE=";
};
in {
romPath = "${baserom}";
}

View File

@@ -1,100 +0,0 @@
# package taken from: <https://git.uninsane.org/shelvacu/nix-stuff/src/branch/master/coopdx.nix>
{ callPackage
, fetchFromGitHub
, autoPatchelfHook
, zlib
, curl
, libcxx
, stdenvNoCC
, nixpkgs ? <nixpkgs>
, writeTextFile
, lib
, bash
, enableTextureFix ? true
, enableDiscord ? false
}: 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 = stdenvNoCC.targetPlatform;
bits = if target.is64bit then "64" else if target.is32bit then "32" else throw "unspported bits";
pname = "sm64coopdx";
version = "1.0.3";
region = "us"; #dx removed support for other regions
in (callPackage "${nixpkgs}/pkgs/games/sm64ex/generic.nix" {
inherit pname version region;
src = fetchFromGitHub {
owner = "coop-deluxe";
repo = pname;
rev = "v${version}";
hash = "sha256-cIH3escLFMcHgtFxeSKIo5nZXvaknti+EVt72uB4XXc=";
};
extraNativeBuildInputs = [
autoPatchelfHook
];
extraBuildInputs = [
zlib
curl
libcxx
libc_hack
];
# Normally there's no need to set TARGET_ARCH, but if we don't it adds -march=native which is impure
compileFlags = [
"BREW_PREFIX=/not-exist"
"TARGET_ARCH=generic"
"TARGET_BITS=${bits}"
"DISCORD_SDK=${if enableDiscord then "1" else "0"}"
"TEXTURE_FIX=${if enableTextureFix then "1" else "0"}"
];
extraMeta = {
mainProgram = pname;
homepage = "https://sm64coopdx.com/";
description = "Super Mario 64 online co-op mod, forked from sm64ex";
};
}).overrideAttrs {
installPhase =
let
sharedLib = target.extensions.sharedLibrary;
in
''
runHook preInstall
local built=$PWD/build/${region}_pc
mkdir -p $out/share/${pname}
cp $built/${pname} $out/share/${pname}/${pname}-unwrapped
cp -r $built/{dynos,lang,mods,palettes} $out/share/${pname}
${lib.optionalString enableDiscord ''
cp $built/libdiscord_game_sdk${sharedLib} $out/share/${pname}
''}
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}
# you're supposed to manually drag and drop the baserom at start, or you can put it here and it discovers it :)
cp ./baserom.*.z64 $out/share/sm64coopdx
runHook postInstall
'';
}