nixpkgs/pkgs/development/libraries/opencsg/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

54 lines
1.6 KiB
Nix

{lib, stdenv, fetchurl, libGLU, libGL, libglut, glew, libXmu, libXext, libX11
, qmake, GLUT, fixDarwinDylibNames }:
stdenv.mkDerivation rec {
version = "1.6.0";
pname = "opencsg";
src = fetchurl {
url = "http://www.opencsg.org/OpenCSG-${version}.tar.gz";
hash = "sha256-v4+4Dj4M4R2H3XjdFaDehy27iXLYf1+Jz/xGHvrUe+g=";
};
nativeBuildInputs = [ qmake ]
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ glew ]
++ lib.optionals stdenv.hostPlatform.isLinux [ libGLU libGL libglut libXmu libXext libX11 ]
++ lib.optional stdenv.hostPlatform.isDarwin GLUT;
doCheck = false;
preConfigure = ''
rm example/Makefile src/Makefile
qmakeFlags=("''${qmakeFlags[@]}" "INSTALLDIR=$out")
'';
postInstall = ''
install -D copying.txt "$out/share/doc/opencsg/copying.txt"
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
mv $out/bin/*.app $out/Applications
rmdir $out/bin || true
'';
dontWrapQtApps = true;
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
app=$out/Applications/opencsgexample.app/Contents/MacOS/opencsgexample
install_name_tool -change \
$(otool -L $app | awk '/opencsg.+dylib/ { print $1 }') \
$(otool -D $out/lib/libopencsg.dylib | tail -n 1) \
$app
'';
meta = with lib; {
description = "Constructive Solid Geometry library";
mainProgram = "opencsgexample";
homepage = "http://www.opencsg.org/";
platforms = platforms.unix;
maintainers = [ maintainers.raskin ];
license = licenses.gpl2Plus;
};
}