1{ lib
2, python3
3, fetchFromGitHub
4, godot3-server
5}:
6
7let
8 python = python3.override {
9 packageOverrides = self: super: {
10 lark = super.lark.overridePythonAttrs (old: rec {
11 # gdtoolkit needs exactly this lark version
12 version = "0.8.0";
13 src = fetchFromGitHub {
14 owner = "lark-parser";
15 repo = "lark";
16 rev = version;
17 hash = "sha256-KN9buVlH8hJ8t0ZP5yefeYM5vH5Gg7a7TEDGKJYpozs=";
18 fetchSubmodules = true;
19 };
20 patches = [ ];
21 });
22 };
23 };
24in
25python.pkgs.buildPythonApplication rec {
26 pname = "gdtoolkit";
27 version = "3.3.1";
28
29 # If we try to get using fetchPypi it requires GeoIP (but the package dont has that dep!?)
30 src = fetchFromGitHub {
31 owner = "Scony";
32 repo = "godot-gdscript-toolkit";
33 rev = version;
34 sha256 = "13nnpwy550jf5qnm9ixpxl1bwfnhhbiys8vqfd25g3aim4bm3gnn";
35 };
36
37 disabled = python.pythonOlder "3.7";
38
39 propagatedBuildInputs = with python.pkgs; [
40 docopt
41 lark
42 pyyaml
43 setuptools
44 ];
45
46 doCheck = true;
47
48 nativeCheckInputs = with python.pkgs; [
49 pytestCheckHook
50 hypothesis
51 godot3-server
52 ];
53
54 preCheck =
55 let
56 godotServerMajorVersion = lib.versions.major godot3-server.version;
57 gdtoolkitMajorVersion = lib.versions.major version;
58 msg = ''
59 gdtoolkit major version ${gdtoolkitMajorVersion} does not match godot-server major version ${godotServerMajorVersion}!
60 gdtoolkit needs a matching godot-server for its tests.
61 If you see this error, you can either:
62 - disable doCheck for gdtoolkit, or
63 - provide a compatible godot-server version to gdtoolkit"
64 '';
65 in lib.throwIf (godotServerMajorVersion != gdtoolkitMajorVersion) msg ''
66 # The tests want to run the installed executables
67 export PATH=$out/bin:$PATH
68
69 # gdtoolkit tries to write cache variables to $HOME/.cache
70 export HOME=$TMP
71
72 # Work around https://github.com/godotengine/godot/issues/20503
73 # Without this, Godot will complain about a missing project file
74 touch project.godot
75
76 # Remove broken test case
77 # (hard to skip via disabledTests since the test name contains an absolute path)
78 rm tests/potential-godot-bugs/multiline-subscription-expression.gd
79 '';
80
81 pythonImportsCheck = [ "gdtoolkit" "gdtoolkit.formatter" "gdtoolkit.linter" "gdtoolkit.parser" ];
82
83 meta = with lib; {
84 description = "Independent set of tools for working with Godot's GDScript - parser, linter and formatter";
85 homepage = "https://github.com/Scony/godot-gdscript-toolkit";
86 license = licenses.mit;
87 maintainers = with maintainers; [ shiryel tmarkus ];
88 };
89}