nixpkgs/pkgs/by-name/gc/gcs/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

106 lines
2.4 KiB
Nix

{
lib,
buildGoModule,
buildNpmPackage,
fetchFromGitHub,
pkg-config,
libGL,
libX11,
libXcursor,
libXrandr,
libXinerama,
libXi,
libXxf86vm,
mupdf,
fontconfig,
freetype,
stdenv,
darwin,
}:
buildGoModule rec {
pname = "gcs";
version = "5.21.0";
src = fetchFromGitHub {
owner = "richardwilkes";
repo = "gcs";
rev = "v${version}";
hash = "sha256-mes1aXh4R1re4sW3xYDWtSIcW7lwkWoAxbcbdyT/W+o=";
};
modPostBuild = ''
chmod +w vendor/github.com/richardwilkes/pdf
sed -i 's|-lmupdf[^ ]* |-lmupdf |g' vendor/github.com/richardwilkes/pdf/pdf.go
'';
vendorHash = "sha256-H5GCrrqmDwpCneXawu7kZsRfrQ8hcsbqhpAAG6FCawg=";
frontend = buildNpmPackage {
name = "${pname}-${version}-frontend";
inherit src;
sourceRoot = "${src.name}/server/frontend";
npmDepsHash = "sha256-wP6sjdcjljzmTs0GUMbF2BPo83LKpfdn15sUuMEIn6E=";
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r dist $out/dist
runHook postInstall
'';
};
postPatch = ''
cp -r ${frontend}/dist server/frontend/dist
'';
nativeBuildInputs = [ pkg-config ];
buildInputs =
[
libGL
libX11
libXcursor
libXrandr
libXinerama
libXi
libXxf86vm
mupdf
fontconfig
freetype
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk_11_0.frameworks.Carbon
darwin.apple_sdk_11_0.frameworks.Cocoa
darwin.apple_sdk_11_0.frameworks.Kernel
];
# flags are based on https://github.com/richardwilkes/gcs/blob/master/build.sh
flags = [ "-a" ];
ldflags = [
"-s"
"-w"
"-X github.com/richardwilkes/toolbox/cmdline.AppVersion=${version}"
];
installPhase = ''
runHook preInstall
install -Dm755 $GOPATH/bin/gcs -t $out/bin
runHook postInstall
'';
meta = {
changelog = "https://github.com/richardwilkes/gcs/releases/tag/${src.rev}";
description = "Stand-alone, interactive, character sheet editor for the GURPS 4th Edition roleplaying game system";
homepage = "https://gurpscharactersheet.com/";
license = lib.licenses.mpl20;
mainProgram = "gcs";
maintainers = with lib.maintainers; [ tomasajt ];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
# incompatible vendor/github.com/richardwilkes/unison/internal/skia/libskia_linux.a
broken = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64;
};
}