docs/mdbook: use a fileset union for source

This commit is contained in:
Matt Sturgeon 2024-10-23 18:45:41 +01:00
parent c2dbf7acf1
commit c477b7865e
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -292,21 +292,34 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
pkgs.mdbook-alerts pkgs.mdbook-alerts
]; ];
inputs = lib.sourceFilesBySuffices ./. [ # Build a source from the fileset containing the following paths,
".md" # as well as all .md, .toml, & .js files in this directory
".toml" src = lib.fileset.toSource {
".js" root = ../../.;
fileset = lib.fileset.unions [
../user-guide
../modules
../../CONTRIBUTING.md
(lib.fileset.fileFilter (
{ type, hasExt, ... }:
type == "regular"
&& lib.any hasExt [
"md"
"toml"
"js"
]
) ./.)
]; ];
};
buildPhase = '' buildPhase = ''
dest=$out/share/doc/nixvim dest=$out/share/doc/nixvim
mkdir -p $dest mkdir -p $dest
# Copy inputs into the build directory # Copy (and flatten) src into the build directory
cp -r --no-preserve=all $inputs/* ./ cp -r --no-preserve=all $src/* ./
cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md mv ./docs/* ./ && rmdir ./docs
cp -r ${../user-guide} ./user-guide mv ./mdbook/* ./ && rmdir ./mdbook
cp -r ${../modules} ./modules
# Copy the generated MD docs into the build directory # Copy the generated MD docs into the build directory
bash -e ${finalAttrs.passthru.copy-docs} bash -e ${finalAttrs.passthru.copy-docs}