Files
Jovian-NixOS/support/docs/default.nix
Samuel Dionne-Riel 82bf69ba5c docs: Update for pagefind deprecation notices
2 configuration warning(s):

  The `bundle-dir` option is deprecated as of Pagefind 1.0. Use either `output-subdir` or `output-path` instead:

  cli:    --output-subdir
  config: output_subdir
  env:    PAGEFIND_OUTPUT_SUBDIR
  └─ "Where to output the search files, relative to the processed site"

  cli:    --output-path
  config: output_path
  env:    PAGEFIND_OUTPUT_PATH
  └─ "Where to output the search files, relative to the working directory of the command"

  The `source` option is deprecated as of Pagefind 1.0. The `source` option has been renamed to `site`:

  cli:    --site
  config: site
  env:    PAGEFIND_SITE
  └─ "The location of your built static website"
2025-01-18 13:17:29 -05:00

126 lines
2.9 KiB
Nix

# This package provides the documentation
{ callPackage
, documentationPath ? ../../docs
, pagefind
, pkgs
}:
let
# Options
evalOptions = callPackage ./lib/eval-options.nix { };
makeOptionsDoc = callPackage ./lib/options-doc.nix { };
options = evalOptions { path = ../../modules; };
inherit (
(makeOptionsDoc { options = options.jovian; prefix = ../../.; })
) optionsJSON;
optionsJSONFile = "${optionsJSON}/share/doc/nixos/options.json";
# Overlay
evalOverlay = callPackage ./lib/eval-overlay.nix { };
overlay = evalOverlay { path = ../../overlay.nix; inherit pkgs; };
makeOverlayDoc = callPackage ./lib/overlay-doc.nix { };
inherit (
(makeOverlayDoc { inherit overlay; prefix = ../../.; })
) overlayJSON;
overlayJSONFile = "${overlayJSON}/overlay.json";
# Documentation resources
styles = callPackage "${./styles}" { };
# Documentation build
output = callPackage (
{ runCommand
, cmark-gfm
, ruby
, documentationPath
, styles
}:
runCommand "Jovian-NixOS-documentation" {
src = documentationPath;
nativeBuildInputs = [
cmark-gfm
(ruby.withPackages (pkgs: with pkgs; [ nokogiri rouge ]))
pagefind
];
} ''
export LANG="C.UTF-8"
export LC_ALL="C.UTF-8"
(PS4=" $ "; set -x
cp --no-preserve=mode -r $src src
chmod -R +w src
ruby ${./converter}/options.rb \
${./template} ${optionsJSONFile} src/options.md
ruby ${./converter}/options.rb \
--namespace jovian.steam --level 3 \
${./template} ${optionsJSONFile} src/steam.md
ruby ${./converter}/packages.rb \
${./template} ${overlayJSONFile} src/packages.md
ruby ${./converter}/main.rb \
--fixups ${./fixups.rb} \
${./template} src/ $out/
cp -r ${styles} $out/styles
)
# Copy the raw data, we never know if it'll end-up useful for someone!
cp -v ${optionsJSONFile} $out/options.json
cp -v ${overlayJSONFile} $out/overlay.json
# Pagefind indexing
(PS4=" $ "; set -x
cd $out
OPT_OUT=(
sitemap
search
)
for p in "''${OPT_OUT[@]}"; do
mv -v $p.html $p.xxx
done
# https://pagefind.app/docs/hosting/#hosting-on-github-pages
pagefind \
--verbose \
--output-subdir !pagefind \
--root-selector 'body > main' \
--keep-index-url \
--site .
for p in "''${OPT_OUT[@]}"; do
mv -v $p.xxx $p.html
done
)
''
) {
inherit documentationPath styles;
};
archive = callPackage (
{ runCommand, docs, name }:
runCommand "${name}.tar.xz" {
dir = name;
} ''
PS4=" $ "
(set -x
cp --no-preserve=mode,owner -r ${docs} $dir
tar -vcJf $out $dir
)
''
) {
docs = output;
name = "docs.tar.xz";
};
in
output // {
inherit archive;
}