nixpkgs/pkgs/by-name/bl/blastem/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

81 lines
2.0 KiB
Nix

{
lib,
stdenv,
fetchhg,
pkg-config,
makeBinaryWrapper,
SDL2,
glew,
gtk3,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "blastem";
version = "0.6.2-unstable-2024-08-14";
src = fetchhg {
url = "https://www.retrodev.com/repos/blastem";
rev = "aa888682faa0";
hash = "sha256-0xw9O0o1pkJiXHyZer4nMJeLlRXS3Z4YYoLgfkrz3Yo=";
};
# will probably be fixed in https://github.com/NixOS/nixpkgs/pull/302481
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace Makefile \
--replace-fail "-flto" ""
'';
nativeBuildInputs = [
pkg-config
makeBinaryWrapper
];
buildInputs = [
gtk3
SDL2
glew
];
# Note: menu.bin cannot be generated yet, because it would
# need the `vasmm68k_mot` executable (part of vbcc for amigaos68k
# Luckily, menu.bin doesn't need to be present for the emulator to function
makeFlags = [ "HOST_ZLIB=1" ];
env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL2}/include/SDL2";
installPhase = ''
runHook preInstall
# not sure if any executable other than blastem is really needed here
install -Dm755 blastem dis zdis termhelper -t $out/share/blastem
install -Dm644 gamecontrollerdb.txt default.cfg rom.db -t $out/share/blastem
cp -r shaders $out/share/blastem/shaders
# wrapping instead of sym-linking makes sure argv0 stays at the original location
makeWrapper $out/share/blastem/blastem $out/bin/blastem
runHook postInstall
'';
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "blastem -v";
version = "0.6.3-pre"; # remove line when moving to a stable version
};
meta = {
description = "The fast and accurate Genesis emulator";
homepage = "https://www.retrodev.com/blastem/";
license = lib.licenses.gpl3Plus;
mainProgram = "blastem";
maintainers = with lib.maintainers; [ tomasajt ];
platforms = [
"i686-linux"
"x86_64-linux"
"x86_64-darwin"
];
};
})