Added flake with dev deps and git hooks
This commit is contained in:
parent
51abefb9b4
commit
f202c5b3eb
19
.direnv/bin/nix-direnv-reload
Executable file
19
.direnv/bin/nix-direnv-reload
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ ! -d "/home/nate/source/fosscat-site" ]]; then
|
||||
echo "Cannot find source directory; Did you move it?"
|
||||
echo "(Looking for "/home/nate/source/fosscat-site")"
|
||||
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# rebuild the cache forcefully
|
||||
_nix_direnv_force_reload=1 direnv exec "/home/nate/source/fosscat-site" true
|
||||
|
||||
# Update the mtime for .envrc.
|
||||
# This will cause direnv to reload again - but without re-building.
|
||||
touch "/home/nate/source/fosscat-site/.envrc"
|
||||
|
||||
# Also update the timestamp of whatever profile_rc we have.
|
||||
# This makes sure that we know we are up to date.
|
||||
touch -r "/home/nate/source/fosscat-site/.envrc" "/home/nate/source/fosscat-site/.direnv"/*.rc
|
52
.githooks/pre-commit
Executable file
52
.githooks/pre-commit
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running pre-commit checks..."
|
||||
|
||||
# Get list of staged markdown files
|
||||
STAGED_MD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.md$' || true)
|
||||
|
||||
if [ -z "$STAGED_MD_FILES" ]; then
|
||||
echo "No markdown files to check."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Checking markdown files..."
|
||||
|
||||
# Check markdown formatting with markdownlint-cli
|
||||
if command -v markdownlint &> /dev/null; then
|
||||
echo "Running markdownlint..."
|
||||
markdownlint $STAGED_MD_FILES || {
|
||||
echo "❌ Markdown linting failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "⚠️ markdownlint not found, skipping markdown linting"
|
||||
fi
|
||||
|
||||
# Spell check
|
||||
if command -v aspell &> /dev/null; then
|
||||
echo "Running spell check..."
|
||||
MISSPELLED=0
|
||||
for file in $STAGED_MD_FILES; do
|
||||
# Extract text, strip markdown syntax, check spelling
|
||||
ERRORS=$(cat "$file" | aspell list --mode=markdown --personal=./.aspell.personal 2>/dev/null | sort -u)
|
||||
if [ ! -z "$ERRORS" ]; then
|
||||
echo "⚠️ Possible misspellings in $file:"
|
||||
echo "$ERRORS" | sed 's/^/ /'
|
||||
MISSPELLED=1
|
||||
fi
|
||||
done
|
||||
if [ $MISSPELLED -eq 1 ]; then
|
||||
echo ""
|
||||
echo "Review spelling errors above. Add correct terms to .aspell.personal"
|
||||
echo "Use 'git commit --no-verify' to skip if needed."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "⚠️ aspell not found, skipping spell check"
|
||||
fi
|
||||
|
||||
echo "✅ Pre-commit checks passed!"
|
||||
exit 0
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,3 +11,6 @@ hugo.linux
|
||||
|
||||
# Temporary lock file while building
|
||||
/.hugo_build.lock
|
||||
|
||||
# direnv stuff
|
||||
.direnv/**
|
||||
|
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1759036355,
|
||||
"narHash": "sha256-0m27AKv6ka+q270dw48KflE0LwQYrO7Fm4/2//KCVWg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e9f00bd893984bc8ce46c895c3bf7cac95331127",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
37
flake.nix
Normal file
37
flake.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
description = "Hugo static site development environment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
hugo
|
||||
marksman # Markdown LSP server
|
||||
nodePackages.prettier # Format markdown and other files
|
||||
markdownlint-cli
|
||||
aspell
|
||||
aspellDicts.en
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "Hugo development environment loaded"
|
||||
echo "Hugo version: $(hugo version)"
|
||||
# Auto-install git hooks if not already installed
|
||||
if [ ! -L .git/hooks/pre-commit ]; then
|
||||
bash scripts/install_hooks.sh
|
||||
fi
|
||||
echo "Hugo development environment loaded"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
29
scripts/install_hooks.sh
Normal file
29
scripts/install_hooks.sh
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
HOOKS_DIR=".githooks"
|
||||
GIT_HOOKS_DIR=".git/hooks"
|
||||
|
||||
echo "Installing git hooks..."
|
||||
|
||||
# Create .git/hooks directory if it doesn't exist
|
||||
mkdir -p "$GIT_HOOKS_DIR"
|
||||
|
||||
# Symlink all hooks from .githooks to .git/hooks
|
||||
for hook in "$HOOKS_DIR"/*; do
|
||||
hook_name=$(basename "$hook")
|
||||
target="$GIT_HOOKS_DIR/$hook_name"
|
||||
|
||||
# Remove existing hook or symlink
|
||||
[ -e "$target" ] && rm "$target"
|
||||
|
||||
# Create symlink
|
||||
ln -s "../../$HOOKS_DIR/$hook_name" "$target"
|
||||
chmod +x "$hook"
|
||||
|
||||
echo "✅ Installed $hook_name"
|
||||
done
|
||||
|
||||
echo "Git hooks installed successfully!"
|
Loading…
Reference in New Issue
Block a user