1{
2 lib,
3 python3,
4 fetchFromGitHub,
5 rustPlatform,
6 SDL2,
7}:
8
9python3.pkgs.buildPythonApplication rec {
10 pname = "pyxel";
11 version = "2.3.18";
12 pyproject = true;
13
14 src = fetchFromGitHub {
15 owner = "kitao";
16 repo = "pyxel";
17 rev = "v${version}";
18 hash = "sha256-pw1ZDmQ7zGwfM98jjym34RbLmUbjuuUnCoPGczxdai8=";
19 };
20
21 patches = [ ./never-bundle-sdl2.patch ];
22
23 postPatch = ''
24 cp ${./Cargo.lock} rust/Cargo.lock
25 '';
26
27 cargoRoot = "rust";
28
29 cargoDeps = rustPlatform.importCargoLock {
30 # generated by running `cargo generate-lockfile` in the `rust` directory
31 lockFile = ./Cargo.lock;
32 };
33
34 buildAndTestSubdir = "python";
35
36 nativeBuildInputs = with rustPlatform; [
37 cargoSetupHook
38 maturinBuildHook
39 bindgenHook
40 ];
41
42 buildInputs = [ SDL2 ];
43
44 env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL2}/include/SDL2";
45
46 # Tests want to use the display
47 doCheck = false;
48
49 pythonImportsCheck = [
50 "pyxel"
51 "pyxel.pyxel_wrapper"
52 ];
53
54 meta = {
55 changelog = "https://github.com/kitao/pyxel/tree/${src.rev}/CHANGELOG.md";
56 description = "Retro game engine for Python";
57 homepage = "https://github.com/kitao/pyxel";
58 license = lib.licenses.mit;
59 mainProgram = "pyxel";
60 maintainers = with lib.maintainers; [ tomasajt ];
61 platforms = lib.platforms.linux ++ lib.platforms.darwin;
62 };
63}