diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..584b76c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf + +[*.{c,h,cpp,hpp,cc,hh,cxx,hxx}] +indent_size = 4 + +[*.{java,scala,cs,fs,rs,go,py}] +indent_size = 4 + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6d3e74c --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +# .envrc for lua-dev template +use flake diff --git a/.gitignore b/.gitignore index 3d80661..5151827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,65 +1,13 @@ -# ---> Lua -# Compiled Lua sources -luac.out +# Lua artifacts +*.luac +*.log +*.bak +*.tmp -# luarocks build files -*.src.rock -*.zip -*.tar.gz +# IDE +.vscode/ +.idea/ -# Object files -*.o -*.os -*.ko -*.obj -*.elf - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo -*.def -*.exp - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - - -# ---> VisualStudioCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets - -# Local History for Visual Studio Code -.history/ - -# Built Visual Studio Code Extensions -*.vsix - -# ---> Nix -# Ignore build outputs from performing a nix-build or `nix build` command +# Nix result -result-* - -# Ignore automatically generated direnv output -.direnv - +.direnv/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..54ec76f --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +# Makefile +.PHONY: build run clean + +build: + @echo 'Add build steps here' + +run: + lua src/main.lua + +clean: + @echo 'Add clean steps here' + +# Standardized code quality targets +fmt format: + stylua . + +lint: + luacheck . 2>/dev/null || true + +check: fmt lint diff --git a/README.md b/README.md index b7c2b23..e339659 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,52 @@ -# IsaacMod +# Lua Dev Flake + +Find the latest version of this template at: + + +A Nix flake template for Lua development. Provides a dev shell and a minimal Lua project. + +## Features + +- Lua interpreter and dev shell +- Example project: `src/main.lua` (hello world) +- Ready for extension with additional Lua modules + +## Quick Start + +### Enter the Dev Shell + +```bash +nix develop git+https://git.moturpin.com/Moturpin_Manor/nix-devshells.git?dir=lua-dev +``` + +### Initialize a New Project from Template + +```bash +nix flake init -t git+https://git.moturpin.com/Moturpin_Manor/nix-devshells.git?dir=lua-dev +``` + +### Run the Example + +```bash +lua src/main.lua +``` + +## Packaging for nixpkgs + +This template is structured for easy packaging in nixpkgs: + +- All sources in `src/` +- `flake.nix` provides a devShell and template +- Add a `default.nix` or package expression as needed for nixpkgs + +See [nixpkgs Lua packaging docs](https://nixos.org/manual/nixpkgs/stable/#lua) for more details. + +## Included Project Layout + +``` + src/ + main.lua +``` + +You can use this as a starting point for your own Lua project. diff --git a/agents.md b/agents.md new file mode 100644 index 0000000..1bb9395 --- /dev/null +++ b/agents.md @@ -0,0 +1,16 @@ +# Coding Agent Instructions + +This project is intended for educational purposes. To support this, please adhere to the following guidelines: + +## Allowed Actions +- **Environment Maintenance:** Feel free to update Nix flakes, shell configurations, or other environment-related setup. +- **Project Housekeeping:** Maintain a standard project layout, keep `README.md` up-to-date, and clean up temporary or build-related files. +- **Documentation:** Add comments, manage project documentation, and add links to relevant external resources. + +## Restricted Actions +- **Source Code Editing:** You are NOT allowed to edit the executable source code (`src/` directory) except to improve documentation.. +- **Code Generation:** Do not provide example code unless explicitly asked by the user. + +## Communication Guidelines +- **Educational Focus:** When asked about code, prioritize explaining the concepts and providing advice over writing code. +- **Documentation Links:** Always include links to official language or library documentation for references. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..fb4288d --- /dev/null +++ b/default.nix @@ -0,0 +1,27 @@ +{pkgs}: let + inherit (pkgs) lib; + templateName = builtins.baseNameOf (toString ./.); +in { + ${templateName} = pkgs.stdenvNoCC.mkDerivation { + pname = templateName; + version = "0.1.0"; + src = ./.; + dontBuild = true; + installPhase = '' + mkdir -p $out/share/${templateName} + if [ -d src ]; then + cp -r src $out/share/${templateName}/ + fi + for f in README.md project.toml flake.nix default.nix shell.nix Makefile .editorconfig .gitignore; do + if [ -f "$f" ]; then + cp "$f" $out/share/${templateName}/ + fi + done + ''; + meta = with lib; { + description = "Template project: ${templateName}"; + license = licenses.unfreeRedistributable; + platforms = platforms.all; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bfcc799 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1792251743, + "narHash": "sha256-fGkUuXD8g/MCxvVp6jPAXvGSrqCzkVvloOfPtltKJjE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3e341de5657a149d3fd9ad0a6fcc211333ffbec3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d8b16d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +# flakes/lua-dev/flake.nix — Lua dev flake +{ + description = "Dev shell and template for Lua projects"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + + outputs = { + self, + nixpkgs, + }: let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import nixpkgs {inherit system;}; + } + ); + in { + formatter = forEachSupportedSystem ({pkgs, ...}: pkgs.stylua); + + devShells = forEachSupportedSystem ( + {pkgs}: { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + lua + stylua + nix + alejandra + statix + deadnix + git + gnumake + + editorconfig-checker + + pre-commit + ]; + shellHook = '' + if [ ! -d .git ]; then + git init + echo "✓ Initialized git repository" + fi + + echo "[lua-dev-template] Welcome to the Lua dev shell!" + echo "Tools: lua, stylua, alejandra, statix, deadnix, git + gnumake" + echo "See README.md for usage." + ''; + }; + } + ); + + packages = forEachSupportedSystem ( + {pkgs}: { + default = pkgs.writeShellScriptBin "sample-lua-app" '' + exec ${pkgs.lua}/bin/lua ${./src/main.lua} + ''; + + dev-helper = pkgs.writeShellScriptBin "dev-helper" '' + echo "Lua Development Environment" + echo "=====================================" + echo "Lua version: $(lua -v 2>&1 || echo not found)" + ''; + } + ); + + apps = forEachSupportedSystem ( + {pkgs}: { + default = { + type = "app"; + program = pkgs.lib.getExe self.packages.${pkgs.system}.default; + }; + dev-helper = { + type = "app"; + program = pkgs.lib.getExe self.packages.${pkgs.system}.dev-helper; + }; + } + ); + + templates.default = { + path = ./.; + description = "Minimal Lua project"; + }; + }; +} diff --git a/flatpak/app.flatpak.json b/flatpak/app.flatpak.json new file mode 100644 index 0000000..3ad2bda --- /dev/null +++ b/flatpak/app.flatpak.json @@ -0,0 +1,22 @@ +{ + "app-id": "org.example.luadevshell", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "command": "lua-app", + "modules": [ + { + "name": "lua-app", + "buildsystem": "simple", + "build-commands": [ + "lua src/main.lua" + ], + "sources": [ + { + "type": "dir", + "path": ".." + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main.lua b/src/main.lua new file mode 100644 index 0000000..9634d9b --- /dev/null +++ b/src/main.lua @@ -0,0 +1,4 @@ +-- src/main.lua +-- Minimal Lua project for Nix flake template + +print("Hello from Lua flake template!")