nixpkgs/pkgs/by-name/ca/cadzinho/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

52 lines
1.4 KiB
Nix

{ lib, stdenv, fetchFromGitHub, SDL2, SDL2_net, glew, lua5_4, desktopToDarwinBundle }:
stdenv.mkDerivation rec {
pname = "cadzinho";
version = "0.6.0";
src = fetchFromGitHub {
owner = "zecruel";
repo = "CadZinho";
rev = version;
hash = "sha256-AHojy6lYLEyeBaYiIzo6MdQCM3jX5ENNTKgU+PGSD00=";
};
postPatch = ''
substituteInPlace src/gui_config.c --replace-fail "/usr/share/cadzinho" "$out/share/cadzinho"
substituteInPlace Makefile --replace-fail "-lGLEW" "-lGLEW -lSDL2_net"
'';
nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle;
buildInputs = [ SDL2 SDL2_net glew lua5_4 ];
makeFlags = [ "CC:=$(CC)" ];
env.NIX_CFLAGS_COMPILE = toString ([
"-I${SDL2.dev}/include/SDL2"
"-I${SDL2_net.dev}/include/SDL2"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
# https://github.com/llvm/llvm-project/issues/62254
"-fno-builtin-strrchr"
]);
hardeningDisable = [ "format" ];
installPhase = ''
runHook preInstall
install -Dm755 cadzinho -t $out/bin
install -Dm644 lang/*.lua -t $out/share/cadzinho/lang
cp -r linux/CadZinho/share/* $out/share
runHook postInstall
'';
meta = with lib; {
description = "Minimalist computer aided design (CAD) software";
homepage = "https://github.com/zecruel/CadZinho";
license = licenses.mit;
maintainers = with maintainers; [ sikmir ];
platforms = platforms.unix;
mainProgram = "cadzinho";
};
}