173 lines
5.4 KiB
Nix
173 lines
5.4 KiB
Nix
{
|
|
description = "Alabama Progress dev shell: Python static site builder + Discord bot + VSCodium";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
};
|
|
|
|
outputs =
|
|
{ self, nixpkgs }:
|
|
let
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
|
in
|
|
{
|
|
devShells = forAllSystems (
|
|
pkgs:
|
|
let
|
|
lib = pkgs.lib;
|
|
|
|
# Python with everything the builder and the bot will need.
|
|
# Declared here so the dev shell and (later) the server module can share it.
|
|
python = pkgs.python3.withPackages (
|
|
ps: with ps; [
|
|
jinja2 # templates
|
|
mistune # Markdown -> HTML for news posts
|
|
python-frontmatter # parse front matter in .md files
|
|
pyyaml # config / front matter
|
|
nh3 # HTML sanitizer for rendered post bodies
|
|
pillow # resize/convert uploaded images to WebP
|
|
python-slugify # safe slugs from titles
|
|
discordpy # the bot
|
|
watchfiles # rebuild on change during development
|
|
pytest # tests for the builder / slugging / validation
|
|
]
|
|
);
|
|
|
|
# Extensions as attribute paths under pkgs.vscode-extensions.
|
|
# Any that don't exist in your nixpkgs revision are silently skipped
|
|
# instead of breaking the whole shell.
|
|
wanted = [
|
|
[
|
|
"esbenp"
|
|
"prettier-vscode"
|
|
] # formatter (HTML/CSS/JS/MD)
|
|
[
|
|
"dbaeumer"
|
|
"vscode-eslint"
|
|
] # JS linting (join form, etc.)
|
|
[
|
|
"ritwickdey"
|
|
"liveserver"
|
|
] # live reload for public/
|
|
[
|
|
"formulahendry"
|
|
"auto-rename-tag"
|
|
] # rename paired HTML tags
|
|
[
|
|
"formulahendry"
|
|
"auto-close-tag"
|
|
] # auto-close HTML tags
|
|
[
|
|
"christian-kohler"
|
|
"path-intellisense"
|
|
] # file path autocomplete
|
|
[
|
|
"usernamehw"
|
|
"errorlens"
|
|
] # inline error messages
|
|
[
|
|
"editorconfig"
|
|
"editorconfig"
|
|
] # .editorconfig support
|
|
[
|
|
"ms-python"
|
|
"python"
|
|
] # Python support
|
|
[
|
|
"charliermarsh"
|
|
"ruff"
|
|
] # Python lint + format
|
|
[
|
|
"samuelcolvin"
|
|
"jinjahtml"
|
|
] # Jinja2 syntax highlighting
|
|
[
|
|
"jnoortheen"
|
|
"nix-ide"
|
|
] # Nix syntax/LSP
|
|
[
|
|
"mkhl"
|
|
"direnv"
|
|
] # auto-load the flake env (if you use direnv)
|
|
[
|
|
"redhat"
|
|
"vscode-yaml"
|
|
] # YAML (front matter, configs)
|
|
[
|
|
"yzhang"
|
|
"markdown-all-in-one"
|
|
] # Markdown preview/shortcuts for posts
|
|
[
|
|
"continue"
|
|
"continue"
|
|
] # local line-completion
|
|
];
|
|
|
|
extensions = lib.filter (e: e != null) (
|
|
map (path: lib.attrByPath path null pkgs.vscode-extensions) wanted
|
|
);
|
|
|
|
codium = pkgs.vscode-with-extensions.override {
|
|
vscode = pkgs.vscodium;
|
|
vscodeExtensions = extensions;
|
|
};
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
name = "alabama-progress";
|
|
|
|
packages = [
|
|
codium
|
|
python
|
|
pkgs.ruff # CLI for lint/format
|
|
pkgs.djlint # lint/format Jinja + HTML templates
|
|
pkgs.lychee # link checker: catches broken links in public/ (good for SEO)
|
|
pkgs.prettier
|
|
pkgs.git
|
|
pkgs.nixpkgs-fmt
|
|
];
|
|
|
|
shellHook = ''
|
|
# Build the site (expects build.py in the current directory)
|
|
build() {
|
|
python build.py "$@"
|
|
}
|
|
|
|
# Build, then serve public/ at http://localhost:8000 (or `serve 3000`)
|
|
serve() {
|
|
local port="''${1:-8000}"
|
|
python build.py || return 1
|
|
echo "Serving public/ at http://localhost:$port"
|
|
python -m http.server "$port" --directory public
|
|
}
|
|
|
|
# Rebuild automatically whenever templates, pages, static files, or posts change.
|
|
# Run `serve` in one terminal and `watch` in another.
|
|
watch() {
|
|
watchfiles "python build.py" templates pages static ../content
|
|
}
|
|
|
|
# Check public/ for broken internal links
|
|
linkcheck() {
|
|
lychee --offline --no-progress public
|
|
}
|
|
|
|
echo "Alabama Progress dev shell ready."
|
|
echo " codium . - open the editor in this directory"
|
|
echo " build - generate public/"
|
|
echo " serve [p] - build, then serve public/ (default port 8000)"
|
|
echo " watch - rebuild on file changes"
|
|
echo " linkcheck - scan public/ for broken links"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|