Nixify rundoc.sh

This commit is contained in:
Sridhar Ratnakumar 2024-02-29 17:44:58 -05:00 committed by Sridhar Ratnakumar
parent 11b457aefc
commit d066315e0a
5 changed files with 31 additions and 29 deletions

View File

@ -27,6 +27,11 @@
packages = with pkgs; [
just
];
shellHook = ''
echo
echo "🍎🍎 Run 'just <recipe>' to get started"
just
'';
};
};
};

View File

@ -37,6 +37,22 @@
};
formatter = pkgs.nixpkgs-fmt;
checks.linkcheck = inputs'.flake-parts-website.checks.linkcheck;
packages.flake-parts = inputs'.flake-parts-website.packages.default;
apps.flake-parts.program = pkgs.writeShellApplication {
name = "docs-flake-parts";
meta.description = "Open flake.parts docs, previewing local haskell-flake version";
text = ''
DOCSHTML="${self'.packages.flake-parts}/options/haskell-flake.html"
if [ "$(uname)" == "Darwin" ]; then
open $DOCSHTML
else
if type xdg-open &>/dev/null; then
xdg-open $DOCSHTML
fi
fi
'';
};
};
};
}

View File

@ -30,6 +30,8 @@
dir = "doc";
overrideInputs = {
"haskell-flake" = ./.;
# TODO: It is better to add a update-flake-lock.yaml CI action to
# update this just like ./example inputs.
"flake-parts-website" = "github:hercules-ci/flake.parts-website";
};
};

View File

@ -12,3 +12,11 @@ check:
# Auto-format the Nix files in project tree
fmt:
treefmt
# Open haskell-flake docs live preview
docs:
cd ./doc && nix run
# Open flake.parts docs, previewing local haskell-flake version
docs-flake-parts:
cd ./doc && nix run .#flake-parts

View File

@ -1,29 +0,0 @@
#!/usr/bin/env sh
# TODO: Move this dev/flake.nix as flake app
if [ -z "$1" ]; then
nix run github:srid/emanote -- -L ./doc
else
# Renders the docs, prints the location of the docs, opens the docs if possible
#
# Does not run the link checker. That's done in nixci checks.
nix --option sandbox false \
build ${OVERRIDE_HASKELL_FLAKE} \
-L --show-trace \
github:hercules-ci/flake.parts-website \
"$@"
DOCSHTML="$PWD/result/options/haskell-flake.html"
echo "Docs rendered to $DOCSHTML"
if [ "$(uname)" == "Darwin" ]; then
open $DOCSHTML
else
if type xdg-open &>/dev/null; then
xdg-open $DOCSHTML
fi
fi
fi