about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ml/mlx42/package.nix
blob: 3387dec3378d5befc2a3b0f37b3679b9ecf8b03e (plain) (blame)
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
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, glfw
, darwin
, enableShared ? !stdenv.hostPlatform.isStatic
, enableDebug ? false
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "mlx42";
  version = "2.3.3";

  src = fetchFromGitHub {
    owner = "codam-coding-college";
    repo = "MLX42";
    rev = "v${finalAttrs.version}";
    hash = "sha256-igkTeOnqGYBISzmtDGlDx9cGJjoQ8fzXtVSR9hU4F5E=";
  };

  postPatch = ''
    patchShebangs ./tools
  ''
  + lib.optionalString enableShared ''
    substituteInPlace CMakeLists.txt \
        --replace "mlx42 STATIC" "mlx42 SHARED"
  '';

  nativeBuildInputs = [ cmake ];

  buildInputs = [ glfw ]
    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ OpenGL Cocoa IOKit ]);

  cmakeFlags = [ "-DDEBUG=${toString enableDebug}" ];

  postInstall = ''
    mkdir -p $out/lib/pkgconfig
    substituteAll ${./mlx42.pc} $out/lib/pkgconfig/mlx42.pc
  '';

  meta = {
    changelog = "https://github.com/codam-coding-college/MLX42/releases/tag/${finalAttrs.src.rev}";
    description = "A simple cross-platform graphics library that uses GLFW and OpenGL";
    homepage = "https://github.com/codam-coding-college/MLX42";
    license = lib.licenses.gpl2Only;
    maintainers = with lib.maintainers; [ tomasajt ];
    platforms = lib.platforms.unix;
  };
})