1
+ {
2
+ description = "Independent set of tools for working with GDScript - parser, linter and formatter" ;
3
+
4
+ inputs = {
5
+ nixpkgs . url = "github:NixOS/nixpkgs" ;
6
+ flake-utils . url = "github:numtide/flake-utils" ;
7
+ } ;
8
+
9
+ outputs = { self , nixpkgs , flake-utils } :
10
+ flake-utils . lib . eachDefaultSystem ( system :
11
+ let
12
+ pkgs = import nixpkgs { inherit system ; } ;
13
+ pythonWithPkgs = pkgs . python3 . withPackages ( ps : with ps ; [
14
+ lark
15
+ docopt-ng
16
+ pyyaml
17
+ radon
18
+ setuptools
19
+ ] ) ;
20
+
21
+ appVersion = "4.3.4" ;
22
+
23
+ helpScript = pkgs . writeShellScript "gdtoolkit-help" ''
24
+ echo "GDScript Toolkit - Available commands:"
25
+ echo ""
26
+ echo "Usage: nix run github:Scony/godot-gdscript-toolkit#<command> -- [args]"
27
+ echo ""
28
+ echo "Available commands:"
29
+ echo " gdparse - GDScript parser for debugging and educational purposes"
30
+ echo " gdlint - GDScript linter that performs static analysis"
31
+ echo " gdformat - GDScript formatter that formats code according to predefined rules"
32
+ echo " gd2py - GDScript to Python transpiler"
33
+ echo " gdradon - GDScript code complexity analysis (calculates cyclomatic complexity)"
34
+ echo ""
35
+ echo "Examples:"
36
+ echo " nix run github:Scony/godot-gdscript-toolkit#gdformat -- --help"
37
+ echo " nix run github:Scony/godot-gdscript-toolkit#gdlint -- myfile.gd"
38
+ echo " nix run github:Scony/godot-gdscript-toolkit#gdparse -- myfile.gd -p"
39
+ echo ""
40
+ echo "For local development:"
41
+ echo " nix develop # Enter development shell with all tools available"
42
+ '' ;
43
+ in {
44
+ packages = {
45
+ gdtoolkit = pkgs . python3 . pkgs . buildPythonPackage {
46
+ pname = "gdtoolkit" ;
47
+ version = appVersion ;
48
+ src = self ;
49
+
50
+ propagatedBuildInputs = with pkgs . python3 . pkgs ; [
51
+ lark
52
+ docopt-ng
53
+ pyyaml
54
+ radon
55
+ setuptools
56
+ ] ;
57
+
58
+ # Create console scripts
59
+ postInstall = ''
60
+ mkdir -p $out/bin
61
+ echo '#!/usr/bin/env python' > $out/bin/gdparse
62
+ echo 'import sys; from gdtoolkit.parser.__main__ import main; sys.exit(main())' >> $out/bin/gdparse
63
+ echo '#!/usr/bin/env python' > $out/bin/gdlint
64
+ echo 'import sys; from gdtoolkit.linter.__main__ import main; sys.exit(main())' >> $out/bin/gdlint
65
+ echo '#!/usr/bin/env python' > $out/bin/gdformat
66
+ echo 'import sys; from gdtoolkit.formatter.__main__ import main; sys.exit(main())' >> $out/bin/gdformat
67
+ echo '#!/usr/bin/env python' > $out/bin/gd2py
68
+ echo 'import sys; from gdtoolkit.gd2py.__main__ import main; sys.exit(main())' >> $out/bin/gd2py
69
+ echo '#!/usr/bin/env python' > $out/bin/gdradon
70
+ echo 'import sys; from gdtoolkit.gdradon.__main__ import main; sys.exit(main())' >> $out/bin/gdradon
71
+ chmod +x $out/bin/*
72
+ '' ;
73
+ } ;
74
+
75
+ default = self . packages . ${ system } . gdtoolkit ;
76
+ } ;
77
+
78
+ apps = {
79
+ help = {
80
+ type = "app" ;
81
+ program = "${ helpScript } " ;
82
+ meta = with pkgs . lib ; {
83
+ description = "Show available GDScript Toolkit commands" ;
84
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
85
+ license = licenses . mit ;
86
+ platforms = platforms . all ;
87
+ } ;
88
+ } ;
89
+
90
+ gdparse = {
91
+ type = "app" ;
92
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdparse" ;
93
+ meta = with pkgs . lib ; {
94
+ description = "GDScript parser" ;
95
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
96
+ license = licenses . mit ;
97
+ platforms = platforms . all ;
98
+ } ;
99
+ } ;
100
+
101
+ gdlint = {
102
+ type = "app" ;
103
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdlint" ;
104
+ meta = with pkgs . lib ; {
105
+ description = "GDScript linter" ;
106
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
107
+ license = licenses . mit ;
108
+ platforms = platforms . all ;
109
+ } ;
110
+ } ;
111
+
112
+ gdformat = {
113
+ type = "app" ;
114
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdformat" ;
115
+ meta = with pkgs . lib ; {
116
+ description = "GDScript formatter" ;
117
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
118
+ license = licenses . mit ;
119
+ platforms = platforms . all ;
120
+ } ;
121
+ } ;
122
+
123
+ gd2py = {
124
+ type = "app" ;
125
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gd2py" ;
126
+ meta = with pkgs . lib ; {
127
+ description = "GDScript to Python transpiler" ;
128
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
129
+ license = licenses . mit ;
130
+ platforms = platforms . all ;
131
+ } ;
132
+ } ;
133
+
134
+ gdradon = {
135
+ type = "app" ;
136
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdradon" ;
137
+ meta = with pkgs . lib ; {
138
+ description = "GDScript code complexity analysis" ;
139
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
140
+ license = licenses . mit ;
141
+ platforms = platforms . all ;
142
+ } ;
143
+ } ;
144
+
145
+ default = self . apps . ${ system } . help ;
146
+ } ;
147
+
148
+ devShells = {
149
+ default = pkgs . mkShell {
150
+ name = "gdtoolkit-dev-env" ;
151
+ packages = [ pythonWithPkgs ] ;
152
+
153
+ shellHook = ''
154
+ export HISTFILE=$HOME/.history_nix
155
+ export PYTHONPATH=${ builtins . toString ./. } :$PYTHONPATH
156
+ export PATH=${ pythonWithPkgs } /bin:$PATH
157
+ alias gdparse="python -m gdtoolkit.parser"
158
+ alias gdlint="python -m gdtoolkit.linter"
159
+ alias gdformat="python -m gdtoolkit.formatter"
160
+ alias gd2py="python -m gdtoolkit.gd2py"
161
+ alias gdradon="python -m gdtoolkit.gdradon"
162
+ echo "GDScript Toolkit development environment activated"
163
+ echo "Available commands: gdparse, gdlint, gdformat, gd2py, gdradon"
164
+ '' ;
165
+ } ;
166
+ } ;
167
+ } ) ;
168
+ }
0 commit comments