nixpkgs/pkgs/by-name/di/discord-gamesdk/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

56 lines
1.4 KiB
Nix

{
lib,
stdenv,
fetchzip,
autoPatchelfHook,
}:
stdenv.mkDerivation rec {
pname = "discord-gamesdk";
version = "3.2.1";
src = fetchzip {
url = "https://dl-game-sdk.discordapp.net/${version}/discord_game_sdk.zip";
hash = "sha256-83DgL9y3lHLLJ8vgL3EOVk2Tjcue64N+iuDj/UpSdLc=";
stripRoot = false;
};
outputs = [
"out"
"dev"
];
buildInputs = [ (stdenv.cc.cc.libgcc or null) ];
nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
installPhase =
let
processor = stdenv.hostPlatform.uname.processor;
sharedLibrary = stdenv.hostPlatform.extensions.sharedLibrary;
in
''
runHook preInstall
install -Dm555 lib/${processor}/discord_game_sdk${sharedLibrary} $out/lib/discord_game_sdk${sharedLibrary}
install -Dm444 c/discord_game_sdk.h $dev/lib/include/discord_game_sdk.h
runHook postInstall
'';
meta = with lib; {
homepage = "https://discord.com/developers/docs/game-sdk/sdk-starter-guide";
description = "Library to allow other programs to interact with the Discord desktop application";
license = licenses.unfree;
maintainers = with maintainers; [ tomodachi94 ];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
platforms = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
"x86_64-windows"
];
};
}