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