1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00
nixpkgs/pkgs/games/jumpy/default.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

87 lines
2 KiB
Nix

{ lib
, rustPlatform
, fetchFromGitHub
, makeWrapper
, pkg-config
, zstd
, stdenv
, alsa-lib
, libxkbcommon
, udev
, vulkan-loader
, wayland
, xorg
, darwin
}:
rustPlatform.buildRustPackage rec {
pname = "jumpy";
version = "0.8.0";
src = fetchFromGitHub {
owner = "fishfolk";
repo = pname;
rev = "v${version}";
sha256 = "sha256-ggePJH2kKJ17aOWRKUnLyolIdSzlc6Axf5Iw74iFfek=";
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"bevy_egui-0.21.0" = "sha256-hu55tZQppw1NajwqIsYsw6de0IAwQwgra3D9OFzSSLc=";
"bones_asset-0.3.0" = "sha256-1UeOXW6O/gMQBBUnHxRreJgmiUTPC5SJB+uLn9V8aa4=";
"kira-0.8.5" = "sha256-z4R5aIaoRQQprL6JsVrFI69rwTOsW5OH01+jORS+hBQ=";
};
};
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
zstd
] ++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
libxkbcommon
udev
vulkan-loader
wayland
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk_11_0.frameworks.Cocoa
rustPlatform.bindgenHook
];
cargoBuildFlags = [ "--bin" "jumpy" ];
env = {
ZSTD_SYS_USE_PKG_CONFIG = true;
};
# jumpy only loads assets from the current directory
# https://github.com/fishfolk/bones/blob/f84d07c2f2847d9acd5c07098fe1575abc496400/framework_crates/bones_asset/src/io.rs#L50
postInstall = ''
mkdir $out/share
cp -r assets $out/share
wrapProgram $out/bin/jumpy --chdir $out/share
'';
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
patchelf $out/bin/.jumpy-wrapped \
--add-rpath ${lib.makeLibraryPath [ vulkan-loader ]}
'';
meta = with lib; {
description = "Tactical 2D shooter played by up to 4 players online or on a shared screen";
mainProgram = "jumpy";
homepage = "https://fishfight.org/";
changelog = "https://github.com/fishfolk/jumpy/releases/tag/v${version}";
license = with licenses; [ mit /* or */ asl20 ];
maintainers = with maintainers; [ figsoda ];
};
}