about summary refs log tree commit diff
path: root/pkgs/by-name/py/pyxel/package.nix
blob: 1103dbba46199e49089fa94331512cc00fc07b6b (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  stdenv,
  python3,
  fetchFromGitHub,
  rustPlatform,
  SDL2,
  libiconv,
  darwin,
}:

python3.pkgs.buildPythonApplication rec {
  pname = "pyxel";
  version = "2.1.6";
  pyproject = true;

  disabled = python3.pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "kitao";
    repo = "pyxel";
    rev = "v${version}";
    hash = "sha256-6S+fl6J1JN785HxG8i0oYlwoTsqa3Gm1DpCd4swUPZ8=";
  };

  patches = [ ./never-bundle-sdl2.patch ];

  postPatch = ''
    cp ${./Cargo.lock} rust/Cargo.lock
  '';

  cargoRoot = "rust";

  cargoDeps = rustPlatform.importCargoLock {
    # generated by running `cargo generate-lockfile` in the `rust` directory
    lockFile = ./Cargo.lock;
  };

  buildAndTestSubdir = "python";

  nativeBuildInputs = with rustPlatform; [
    cargoSetupHook
    maturinBuildHook
    bindgenHook
  ];

  buildInputs =
    [ SDL2 ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      libiconv
      darwin.apple_sdk.frameworks.IOKit
    ];

  env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL2}/include/SDL2";

  # Tests want to use the display
  doCheck = false;

  pythonImportsCheck = [
    "pyxel"
    "pyxel.pyxel_wrapper"
  ];

  meta = {
    changelog = "https://github.com/kitao/pyxel/tree/${src.rev}/CHANGELOG.md";
    description = "Retro game engine for Python";
    homepage = "https://github.com/kitao/pyxel";
    license = lib.licenses.mit;
    mainProgram = "pyxel";
    maintainers = with lib.maintainers; [ tomasajt ];
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}