mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
space-cadet-pinball: Improve packaging (#354555)
This commit is contained in:
commit
8a312b121e
@ -15206,6 +15206,13 @@
|
||||
githubId = 1234956;
|
||||
"keys" = [ { "fingerprint" = "F21A 6194 C9DB 9899 CD09 E24E 434B 2C14 B8C3 3422"; } ];
|
||||
};
|
||||
nadiaholmquist = {
|
||||
name = "Nadia Holmquist Pedersen";
|
||||
email = "nadia@nhp.sh";
|
||||
matrix = "@nhp:matrix.org";
|
||||
github = "nadiaholmquist";
|
||||
githubId = 893884;
|
||||
};
|
||||
nadir-ishiguro = {
|
||||
github = "nadir-ishiguro";
|
||||
githubId = 23151917;
|
||||
|
86
pkgs/by-name/sp/space-cadet-pinball/package.nix
Normal file
86
pkgs/by-name/sp/space-cadet-pinball/package.nix
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchzip,
|
||||
cmake,
|
||||
SDL2,
|
||||
SDL2_mixer,
|
||||
unrar,
|
||||
}:
|
||||
|
||||
let
|
||||
assets = fetchzip {
|
||||
url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
|
||||
hash = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
|
||||
stripRoot = false;
|
||||
nativeBuildInputs = [ unrar ];
|
||||
};
|
||||
darwinApp = "$out/Applications/SpaceCadetPinball.app/Contents";
|
||||
assetsDest =
|
||||
if stdenv.hostPlatform.isDarwin then darwinApp + "/Resources" else "$out/share/SpaceCadetPinball";
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "SpaceCadetPinball";
|
||||
version = "2.1.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "k4zmu2a";
|
||||
repo = "SpaceCadetPinball";
|
||||
rev = "Release_${version}";
|
||||
hash = "sha256-W2P7Txv3RtmKhQ5c0+b4ghf+OMsN+ydUZt+6tB+LClM=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [
|
||||
SDL2
|
||||
SDL2_mixer
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# Change the hardcoded FHS assets path
|
||||
substituteInPlace SpaceCadetPinball/pch.h \
|
||||
--replace-fail /usr/share ${placeholder "out"}/share
|
||||
# Disable building a universal binary on Darwin, otherwise the cc wrapper passing -arch breaks the build
|
||||
substituteInPlace CMakeLists.txt \
|
||||
--replace-fail "arm64;x86_64" ""
|
||||
'';
|
||||
|
||||
# Darwin needs a custom installPhase since it is excluded from the cmake install
|
||||
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
|
||||
# This builds a bundle similar to what upstream's build script produces
|
||||
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/cb9b7b886244a27773f66b0b19fdc2998392565e/build-mac-app.sh
|
||||
installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
runHook preInstall
|
||||
install -D ../bin/SpaceCadetPinball -t ${darwinApp}/MacOS
|
||||
install -Dm644 ../Platform/macOS/SpaceCadetPinball.icns -t ${darwinApp}/Resources
|
||||
substitute ../Platform/macOS/Info.plist ${darwinApp}/Info.plist \
|
||||
--replace-fail CHANGEME_SW_VERSION ${version}
|
||||
echo -n "APPL????" > ${darwinApp}/PkgInfo
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# The game uses SDL_GetBasePath to find the assets directory.
|
||||
# On Darwin, this will return Resources/ inside the bundle,
|
||||
# on other platforms, the fallback path the game checks is used instead.
|
||||
postInstall = ''
|
||||
install -Dm644 ${assets}/*.{DAT,DOC,MID,BMP,INF} \
|
||||
${assets}/Sounds/*.WAV -t ${assetsDest}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
|
||||
homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
|
||||
# The assets are unfree while the code is labeled as MIT
|
||||
license = with lib.licenses; [
|
||||
unfree
|
||||
mit
|
||||
];
|
||||
maintainers = with lib.maintainers; [
|
||||
hqurve
|
||||
nadiaholmquist
|
||||
];
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "SpaceCadetPinball";
|
||||
};
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
{ lib, stdenv, fetchFromGitHub, fetchzip
|
||||
, cmake, SDL2, SDL2_mixer, Cocoa
|
||||
, unrar-wrapper, makeWrapper
|
||||
}:
|
||||
|
||||
let
|
||||
assets = (fetchzip {
|
||||
url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
|
||||
sha256 = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
|
||||
stripRoot = false;
|
||||
}).overrideAttrs (old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ unrar-wrapper ];
|
||||
});
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "SpaceCadetPinball";
|
||||
version = "2.1.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "k4zmu2a";
|
||||
repo = pname;
|
||||
rev = "Release_${version}";
|
||||
hash = "sha256-W2P7Txv3RtmKhQ5c0+b4ghf+OMsN+ydUZt+6tB+LClM=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake makeWrapper ];
|
||||
buildInputs = [
|
||||
SDL2
|
||||
SDL2_mixer
|
||||
] ++ lib.optional stdenv.hostPlatform.isDarwin Cocoa;
|
||||
|
||||
# Darwin needs a custom installphase since it is excluded from the cmake install
|
||||
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/0f88e43ba261bc21fa5c3ef9d44969a2a079d0de/CMakeLists.txt#L221
|
||||
installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
install ../bin/SpaceCadetPinball $out/bin
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/lib/SpaceCadetPinball
|
||||
install ${assets}/*.{DAT,DOC,MID,BMP,INF} ${assets}/Sounds/*.WAV $out/lib/SpaceCadetPinball
|
||||
|
||||
# Assets are loaded from the directory of the program is stored in
|
||||
# https://github.com/k4zmu2a/SpaceCadetPinball/blob/de13d4e326b2dfa8e6dfb59815c0a8b9657f942d/SpaceCadetPinball/winmain.cpp#L119
|
||||
mv $out/bin/SpaceCadetPinball $out/lib/SpaceCadetPinball
|
||||
makeWrapper $out/lib/SpaceCadetPinball/SpaceCadetPinball $out/bin/SpaceCadetPinball
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Reverse engineering of 3D Pinball for Windows – Space Cadet, a game bundled with Windows";
|
||||
homepage = "https://github.com/k4zmu2a/SpaceCadetPinball";
|
||||
# The assets are unfree while the code is labeled as MIT
|
||||
license = with licenses; [ unfree mit ];
|
||||
maintainers = [ maintainers.hqurve ];
|
||||
platforms = platforms.all;
|
||||
mainProgram = "SpaceCadetPinball";
|
||||
};
|
||||
}
|
@ -17336,10 +17336,6 @@ with pkgs;
|
||||
buildShareware = true;
|
||||
};
|
||||
|
||||
space-cadet-pinball = callPackage ../games/space-cadet-pinball {
|
||||
inherit (darwin.apple_sdk.frameworks) Cocoa;
|
||||
};
|
||||
|
||||
starsector = callPackage ../games/starsector {
|
||||
openjdk = openjdk8;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user