This repository has been archived on 2024-05-03. You can view files and clone it, but cannot push or open issues or pull requests.
treefmt/nix/docs.nix
Brian McGee 311e46a409
doc: fix docs package build
Vitepress cli does some funky stuff with the tty.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-02 11:41:38 +01:00

73 lines
1.7 KiB
Nix

_: {
perSystem = {
pkgs,
self',
...
}: {
packages.docs = pkgs.buildNpmPackage {
pname = "treefmt-docs";
inherit (self'.packages.default) version;
src = ../docs;
npmDepsHash = "sha256-J9qTWueOcSBq7qRec6YdTuWI2VlVQ0q6AynDLovf6s0=";
# we have to use a custom build phase because vitepress is doing something funky with the ttty
buildPhase = ''
cat | npm run build 2>&1 | cat
'';
installPhase = ''
runHook preInstall
cp -rv .vitepress/dist/ $out
runHook postInstall
'';
};
devshells.default = {
packages = [
pkgs.nodejs
];
commands = let
category = "docs";
in [
{
inherit category;
name = "docs:dev";
help = "serve docs for local development";
command = "cd $PRJ_ROOT/docs && npm dev";
}
{
inherit category;
name = "docs:build";
help = "create a production build of docs";
command = "cd $PRJ_ROOT/docs && npm build";
}
{
inherit category;
name = "docs:preview";
help = "preview a production build of docs";
command = "cd $PRJ_ROOT/docs && npm preview";
}
{
inherit category;
package = pkgs.vhs;
help = "generate terminal gifs";
}
{
category = "docs";
help = "regenerate gifs for docs";
name = "gifs";
command = ''
set -xeuo pipefail
for tape in $PRJ_ROOT/docs/vhs/*; do
vhs $tape -o "$PRJ_ROOT/docs/public/$(basename $tape .tape).gif"
done
'';
}
];
};
};
}