docs/packages/md-manual/default.nix

82 lines
2.1 KiB
Nix
Raw Normal View History

2024-06-30 05:43:43 +00:00
{
lib,
2024-06-30 21:43:38 +00:00
pkgs,
2024-06-30 05:43:43 +00:00
nixos-render-docs,
python3,
perl,
stdenvNoCC,
inputs,
2024-06-30 21:43:38 +00:00
...
2024-06-30 05:43:43 +00:00
}:
stdenvNoCC.mkDerivation {
name = "nixpkgs-manual-md";
nativeBuildInputs = [
nixos-render-docs
python3
perl
];
src = inputs.nixpkgs;
patchPhase = ''
cd doc
find . -type f ! -name '*.md' ! -name '*.md.in' -exec rm {} \+
'';
postPatch = ''
2024-06-30 22:00:37 +00:00
ln -s ${pkgs.amg.options-doc.optionsJSON}/share/doc/nixos/options.json ./config-options.json
2024-06-30 05:43:43 +00:00
'';
2024-06-30 22:00:37 +00:00
pythonInterpreterTable = lib.amg.python-interp-table;
2024-06-30 05:43:43 +00:00
passAsFile = [ "pythonInterpreterTable" ];
buildPhase = ''
substituteInPlace ./languages-frameworks/python.section.md --subst-var-by python-interpreter-table "$(<"$pythonInterpreterTablePath")"
cat \
./functions/library.md.in \
2024-06-30 22:00:37 +00:00
${pkgs.amg.lib-docs}/index.md \
2024-06-30 05:43:43 +00:00
> ./functions/library.md
substitute ./manual.md.in ./manual.md \
--replace-fail '@MANUAL_VERSION@' '${lib.version}'
mkdir out
mkdir out/assets
2024-06-30 22:00:37 +00:00
cp ${pkgs.amg.manual-assets}/* out/assets/
2024-06-30 05:43:43 +00:00
mv preface.chapter.md out/index.md
mv build-helpers out/build-helpers
mv build-helpers.md out/build-helpers/index.md
mv development out/development
mv development.md out/development/index.md
mv functions out/functions
mv functions.md out/functions/index.md
mv hooks out/hooks
mv languages-frameworks out/languages-frameworks
mkdir out/lib
2024-06-30 22:00:37 +00:00
cp ${pkgs.amg.lib-docs}/*.md out/lib/
2024-06-30 21:32:24 +00:00
rm out/lib/index.md
2024-06-30 05:43:43 +00:00
mv module-system out/module-system
mv packages out/packages
mv stdenv out/stdenv
mv stdenv.md out/stdenv/index.md
mv using out/using
mv using-nixpkgs.md out/using/index.md
pushd out
find . -type f -exec perl -pi -e 's/\s*:::{.note}\n/!!! note\n\ \ /' {} \;
find . -type f -exec perl -pi -e 's/\s*:::{.warning}\n/!!! warning\n\ \ /' {} \;
find . -type f -exec perl -pi -e 's/\s*:::{.tip}\n/!!! tip\n\ \ \ \ /' {} \;
find . -type f -exec perl -pi -e 's/\s*:::{.example}\n/!!! example\n\ \ \ \ /' {} \;
find . -type f -exec sed -i 's/\s*::://g' {} \;
popd
'';
installPhase = ''
mkdir $out
mv out/* $out
'';
}