90 lines
2.1 KiB
Nix
90 lines
2.1 KiB
Nix
# 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";
|
|
};
|
|
};
|
|
}
|