diff --git a/templates/python/.envrc b/templates/python/.envrc new file mode 100644 index 0000000..bc49353 --- /dev/null +++ b/templates/python/.envrc @@ -0,0 +1 @@ +use flake .# diff --git a/templates/python/.gitignore b/templates/python/.gitignore new file mode 100644 index 0000000..63c8a9a --- /dev/null +++ b/templates/python/.gitignore @@ -0,0 +1,4 @@ +/.direnv +\.\#* +\#*\# +*~ \ No newline at end of file diff --git a/templates/python/flake.lock b/templates/python/flake.lock new file mode 100644 index 0000000..cc0b1a4 --- /dev/null +++ b/templates/python/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1740695751, + "narHash": "sha256-D+R+kFxy1KsheiIzkkx/6L63wEHBYX21OIwlFV8JvDs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6313551cd05425cd5b3e63fe47dbc324eabb15e4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/templates/python/flake.nix b/templates/python/flake.nix new file mode 100644 index 0000000..46f66db --- /dev/null +++ b/templates/python/flake.nix @@ -0,0 +1,26 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = {self, nixpkgs, ...}: let + inherit (nixpkgs) lib; + systems = ["x86_64-linux" "aarch64-linux"]; + forAllSystems = f: lib.genAttrs systems ( + system: f system (import nixpkgs { + inherit system; + }) + ); + in { + packages = forAllSystems (system: pkgs: { + REPLACE_ME = pkgs.callPackage ./flake/package.nix {}; + default = self.packages.${system}.REPLACE_ME; + }); + + devShells = forAllSystems (_: pkgs: { + default = pkgs.callPackage ./flake/shell.nix {}; + }); + + formatter = forAllSystems (_: pkgs: pkgs.callPackage ./flake/formatter.nix {}); + }; +} diff --git a/templates/python/flake/package.nix b/templates/python/flake/package.nix new file mode 100644 index 0000000..d0fffa9 --- /dev/null +++ b/templates/python/flake/package.nix @@ -0,0 +1,16 @@ +{ + python3Packages +}: let + ps = python3Packages; +in ps.buildPythonApplication { + pname = "sm64pcport-for-dummies"; + version = "2025.03"; + + src = builtins.filterSource (path: _: baseNameOf path != ".git") ../.; + + pyproject = true; + + build-system = [ + ps.setuptools + ]; +} diff --git a/templates/python/flake/shell.nix b/templates/python/flake/shell.nix new file mode 100644 index 0000000..cea1b5b --- /dev/null +++ b/templates/python/flake/shell.nix @@ -0,0 +1,11 @@ +{mkShell, python3, ruff, ruff-lsp}: let + python3' = python3.withPackages (ps: []); +in + mkShell { + name = "python-env"; + packages = [ + python3' + ruff + ruff-lsp + ]; + } diff --git a/templates/python/pyproject.toml b/templates/python/pyproject.toml new file mode 100644 index 0000000..ed4737a --- /dev/null +++ b/templates/python/pyproject.toml @@ -0,0 +1,11 @@ +[project] +name = "REPLACE_ME" +description = "Dumbed-down frontend for the SM64 PC Port compiler." +version = "2025.03" + +[project.scripts] +REPLACE_ME = "REPLACE_ME.__main__:main" + +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/templates/python/src/REPLACE_ME/__main__.py b/templates/python/src/REPLACE_ME/__main__.py new file mode 100644 index 0000000..7d32a56 --- /dev/null +++ b/templates/python/src/REPLACE_ME/__main__.py @@ -0,0 +1,6 @@ +def main(): + print("Hello, world!") + + +if __name__ == "__main__": + main()