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
+ in {
23
+ packages = {
24
+ gdtoolkit = pkgs . python3 . pkgs . buildPythonPackage {
25
+ pname = "gdtoolkit" ;
26
+ version = appVersion ;
27
+ src = self ;
28
+
29
+ propagatedBuildInputs = with pkgs . python3 . pkgs ; [
30
+ lark
31
+ docopt-ng
32
+ pyyaml
33
+ radon
34
+ setuptools
35
+ ] ;
36
+
37
+ # Create console scripts
38
+ postInstall = ''
39
+ mkdir -p $out/bin
40
+ echo '#!/usr/bin/env python' > $out/bin/gdparse
41
+ echo 'import sys; from gdtoolkit.parser.__main__ import main; sys.exit(main())' >> $out/bin/gdparse
42
+ echo '#!/usr/bin/env python' > $out/bin/gdlint
43
+ echo 'import sys; from gdtoolkit.linter.__main__ import main; sys.exit(main())' >> $out/bin/gdlint
44
+ echo '#!/usr/bin/env python' > $out/bin/gdformat
45
+ echo 'import sys; from gdtoolkit.formatter.__main__ import main; sys.exit(main())' >> $out/bin/gdformat
46
+ echo '#!/usr/bin/env python' > $out/bin/gd2py
47
+ echo 'import sys; from gdtoolkit.gd2py.__main__ import main; sys.exit(main())' >> $out/bin/gd2py
48
+ echo '#!/usr/bin/env python' > $out/bin/gdradon
49
+ echo 'import sys; from gdtoolkit.gdradon.__main__ import main; sys.exit(main())' >> $out/bin/gdradon
50
+ chmod +x $out/bin/*
51
+ '' ;
52
+ } ;
53
+
54
+ default = self . packages . ${ system } . gdtoolkit ;
55
+ } ;
56
+
57
+ apps = {
58
+ gdparse = {
59
+ type = "app" ;
60
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdparse" ;
61
+ meta = with pkgs . lib ; {
62
+ description = "GDScript parser" ;
63
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
64
+ license = licenses . mit ;
65
+ platforms = platforms . all ;
66
+ } ;
67
+ } ;
68
+
69
+ gdlint = {
70
+ type = "app" ;
71
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdlint" ;
72
+ meta = with pkgs . lib ; {
73
+ description = "GDScript linter" ;
74
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
75
+ license = licenses . mit ;
76
+ platforms = platforms . all ;
77
+ } ;
78
+ } ;
79
+
80
+ gdformat = {
81
+ type = "app" ;
82
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdformat" ;
83
+ meta = with pkgs . lib ; {
84
+ description = "GDScript formatter" ;
85
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
86
+ license = licenses . mit ;
87
+ platforms = platforms . all ;
88
+ } ;
89
+ } ;
90
+
91
+ gd2py = {
92
+ type = "app" ;
93
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gd2py" ;
94
+ meta = with pkgs . lib ; {
95
+ description = "GDScript to Python transpiler" ;
96
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
97
+ license = licenses . mit ;
98
+ platforms = platforms . all ;
99
+ } ;
100
+ } ;
101
+
102
+ gdradon = {
103
+ type = "app" ;
104
+ program = "${ self . packages . ${ system } . gdtoolkit } /bin/gdradon" ;
105
+ meta = with pkgs . lib ; {
106
+ description = "GDScript code complexity analysis" ;
107
+ homepage = "https://github.com/Scony/godot-gdscript-toolkit" ;
108
+ license = licenses . mit ;
109
+ platforms = platforms . all ;
110
+ } ;
111
+ } ;
112
+
113
+ default = self . apps . ${ system } . gdformat ;
114
+ } ;
115
+
116
+ devShells = {
117
+ default = pkgs . mkShell {
118
+ name = "gdtoolkit-dev-env" ;
119
+ packages = [ pythonWithPkgs ] ;
120
+
121
+ shellHook = ''
122
+ export HISTFILE=$HOME/.history_nix
123
+ export PYTHONPATH=${ builtins . toString ./. } :$PYTHONPATH
124
+ export PATH=${ pythonWithPkgs } /bin:$PATH
125
+ alias gdparse="python -m gdtoolkit.parser"
126
+ alias gdlint="python -m gdtoolkit.linter"
127
+ alias gdformat="python -m gdtoolkit.formatter"
128
+ alias gd2py="python -m gdtoolkit.gd2py"
129
+ alias gdradon="python -m gdtoolkit.gdradon"
130
+ echo "GDScript Toolkit development environment activated"
131
+ echo "Available commands: gdparse, gdlint, gdformat, gd2py, gdradon"
132
+ '' ;
133
+ } ;
134
+ } ;
135
+ } ) ;
136
+ }
0 commit comments