This commit is contained in:
parent
1936fadea5
commit
75ebf874f0
2 changed files with 78 additions and 0 deletions
62
modules/scripts/build-adoc.nix
Normal file
62
modules/scripts/build-adoc.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
flake.modules.homeManager.base =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "build-adoc";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
asciidoctor-with-extensions
|
||||
];
|
||||
|
||||
excludeShellChecks = [ "SC2034" ];
|
||||
|
||||
text = ''
|
||||
ls book
|
||||
|
||||
echo ""
|
||||
|
||||
date=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo "The current date is $date."
|
||||
|
||||
pwd=$(pwd)
|
||||
parent=$(basename "$(dirname "$pwd")")
|
||||
name=$(basename "$pwd")
|
||||
|
||||
echo "The parent directory is $parent."
|
||||
echo "The current directory is $name."
|
||||
|
||||
echo ""
|
||||
echo "Generating the HTML..."
|
||||
asciidoctor \
|
||||
-D book \
|
||||
-a "date=$date" \
|
||||
-o index.html \
|
||||
./book/index.adoc
|
||||
|
||||
echo ""
|
||||
echo "Generating the EPUB..."
|
||||
asciidoctor-epub3 \
|
||||
-D book \
|
||||
-a "date=$date" \
|
||||
-o "$parent-$name.epub" \
|
||||
./book/index.adoc
|
||||
|
||||
echo ""
|
||||
echo "Generating the PDF..."
|
||||
asciidoctor-pdf \
|
||||
-D book \
|
||||
-a "date=$date" \
|
||||
-o "$parent-$name.pdf" \
|
||||
./book/index.adoc
|
||||
|
||||
echo ""
|
||||
|
||||
ls book
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
16
modules/scripts/build.nix
Normal file
16
modules/scripts/build.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
flake.modules.homeManager.base =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "build";
|
||||
|
||||
text = ''
|
||||
test -r book/index.adoc && exec build-adoc "$@"
|
||||
test -x build && exec ./build "$@"
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue