summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/op/opencsg/package.nix
blob: 92c93f11d440cc94644dab66dbd97b2e0cee091f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  lib,
  stdenv,
  fetchurl,
  cmake,
  libGLU,
  libGL,
  libglut,
  glew,
  libxmu,
  libxext,
  libx11,
  fixDarwinDylibNames,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "opencsg";
  version = "1.8.2";

  src = fetchurl {
    url = "https://www.opencsg.org/OpenCSG-${finalAttrs.version}.tar.gz";
    hash = "sha256-WsXfc7GtM0DdZwX/kOAJ8alGu5U2whwiY6b5dCZWZMA=";
  };

  patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./opencsgexample.patch ];

  nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;

  buildInputs = [
    glew
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    libGLU
    libGL
    libglut
    libxmu
    libxext
    libx11
  ];

  doCheck = false;

  postInstall = ''
    install -D ../copying.txt "$out/share/doc/opencsg/copying.txt"
  '';

  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 = {
    description = "Constructive Solid Geometry library";
    mainProgram = "opencsgexample";
    homepage = "http://www.opencsg.org/";
    platforms = lib.platforms.unix;
    maintainers = [ lib.maintainers.raskin ];
    license = lib.licenses.gpl2Plus;
  };
})