Skip to content

Commit d991fb9

Browse files
committed
feat: add Nix support for reproducible builds
1 parent b1bcaa1 commit d991fb9

File tree

3 files changed

+257
-0
lines changed

3 files changed

+257
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,35 @@ pip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git
4141
pipx install git+https://github.com/Scony/godot-gdscript-toolkit.git
4242
```
4343

44+
### Using Nix
45+
46+
If you have [Nix](https://nixos.org/) installed, you can run gdtoolkit tools without installing them:
47+
48+
```bash
49+
# Show available commands and usage help
50+
nix run github:Scony/godot-gdscript-toolkit
51+
52+
# Run specific tools
53+
nix run github:Scony/godot-gdscript-toolkit#gdformat -- --help
54+
nix run github:Scony/godot-gdscript-toolkit#gdlint -- myfile.gd
55+
nix run github:Scony/godot-gdscript-toolkit#gdparse -- myfile.gd -p
56+
nix run github:Scony/godot-gdscript-toolkit#gd2py -- myfile.gd
57+
nix run github:Scony/godot-gdscript-toolkit#gdradon -- cc myfile.gd
58+
```
59+
60+
Available commands:
61+
- `gdformat` - Code formatter
62+
- `gdlint` - Static analysis linter
63+
- `gdparse` - Parser for debugging/educational purposes
64+
- `gd2py` - GDScript to Python transpiler
65+
- `gdradon` - Cyclomatic complexity calculator
66+
67+
Or enter a development shell with all tools available:
68+
69+
```bash
70+
nix develop github:Scony/godot-gdscript-toolkit
71+
```
72+
4473
## Linting with gdlint [(more)](https://github.com/Scony/godot-gdscript-toolkit/wiki/3.-Linter)
4574

4675
To run a linter you need to execute `gdlint` command like:

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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

Comments
 (0)