diff --git a/flake.nix b/flake.nix index 6a19d09..b386925 100644 --- a/flake.nix +++ b/flake.nix @@ -65,11 +65,33 @@ # --- Linting, Formatting & Static Analysis Checks --- # Executed via `nix flake check` or `nix build .#checks..` checks.${system} = { + # Shell script linting via ShellCheck + shellcheck = pkgs.runCommand "check-shellcheck" { + nativeBuildInputs = [ pkgs.shellcheck ]; + } '' + echo "🐚 [ShellCheck] Checking shell scripts..." + find ${self} -type f -name "*.sh" -exec shellcheck -s bash {} + + echo "✅ [ShellCheck] All shell scripts passed!" + touch $out + ''; + + # Lua linting via luacheck + luacheck = pkgs.runCommand "check-luacheck" { + nativeBuildInputs = [ pkgs.luaPackages.luacheck ]; + } '' + echo "🌙 [Lua] Checking Neovim Lua configuration..." + luacheck ${self}/home/config/nvim --globals vim + echo "✅ [Lua] All Lua files passed!" + touch $out + ''; + # Python linting via ruff ruff-lint = pkgs.runCommand "check-ruff-lint" { nativeBuildInputs = [ pkgs.ruff ]; } '' + echo "🐍 [Ruff] Running Python linter (ruff check)..." ruff check --no-cache ${self} + echo "✅ [Ruff] All Python files passed linting!" touch $out ''; @@ -77,7 +99,9 @@ ruff-format = pkgs.runCommand "check-ruff-format" { nativeBuildInputs = [ pkgs.ruff ]; } '' + echo "🎨 [Ruff] Checking Python formatting (ruff format)..." ruff format --check ${self} + echo "✅ [Ruff] All Python files properly formatted!" touch $out ''; @@ -85,15 +109,9 @@ pyright = pkgs.runCommand "check-pyright" { nativeBuildInputs = [ pkgs.pyright ]; } '' + echo "🔬 [Pyright] Running Python type analysis..." pyright ${self} - touch $out - ''; - - # Shell script linting via ShellCheck - shellcheck = pkgs.runCommand "check-shellcheck" { - nativeBuildInputs = [ pkgs.shellcheck ]; - } '' - find ${self} -type f -name "*.sh" -exec shellcheck -s bash {} + + echo "✅ [Pyright] All Python type checks passed!" touch $out ''; }; diff --git a/home/config/nvim/lsp.lua b/home/config/nvim/lsp.lua index 8de1075..db3bc0c 100644 --- a/home/config/nvim/lsp.lua +++ b/home/config/nvim/lsp.lua @@ -53,7 +53,7 @@ vim.api.nvim_create_autocmd('LspAttach', { callback = function(ev) local opts = { buffer = ev.buf } local client = vim.lsp.get_client_by_id(ev.data.client_id) - + -- Standard navigation & actions vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) diff --git a/home/shell.nix b/home/shell.nix index 8ca9352..a6a8d1f 100644 --- a/home/shell.nix +++ b/home/shell.nix @@ -193,6 +193,8 @@ in zed = "zeditor"; reload = "exec bash"; ts = "tmux-sessionizer"; + check = "~/Config/scripts/test"; + nfc = "nix flake check -L"; ff = "fastfetch --logo none"; # System Navigation diff --git a/home/shell/interactive.sh b/home/shell/interactive.sh index 411fcfd..094d179 100644 --- a/home/shell/interactive.sh +++ b/home/shell/interactive.sh @@ -17,3 +17,13 @@ fi if [[ $- == *i* ]]; then fastfetch --logo none fi + +# --- Nix Command Ergonomics --- +# Ensure `nix flake check` always prints build and verification logs (-L) +nix() { + if [[ "${1:-}" == "flake" && "${2:-}" == "check" && "$*" != *"--log-format"* && "$*" != *"-L"* ]]; then + command nix flake check -L "${@:3}" + else + command nix "$@" + fi +} diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..3a55de9 --- /dev/null +++ b/scripts/test @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# scripts/test - Automated test & invariant verification runner for Workstation Config +set -euo pipefail + +cd "$(dirname "$0")/.." + +echo "🐚 Running ShellCheck across shell scripts..." +find . -type f -name "*.sh" -not -path "./.git/*" -exec shellcheck -s bash {} + +echo "✅ ShellCheck passed!" + +echo "🌙 Checking Neovim Lua configuration (luacheck)..." +nix-shell -p luaPackages.luacheck --run "luacheck home/config/nvim --globals vim" +echo "✅ Lua checks passed!" + +echo "🐍 Running Python linters & type analysis (Ruff & Pyright)..." +nix-shell -p ruff pyright --run "ruff check --no-cache . && ruff format --check . && pyright ." +echo "✅ Python checks passed!" + +echo "❄️ Verifying NixOS flake & sandbox checks..." +nix flake check -L + +echo "✨ All checks and static analyses passed successfully!"