From c477b7865e8c5ec923ae42ebac14b8dd410c873d Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 23 Oct 2024 18:45:41 +0100 Subject: [PATCH] docs/mdbook: use a fileset union for source --- docs/mdbook/default.nix | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index bf6ab987..dc52da5c 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -292,21 +292,34 @@ pkgs.stdenv.mkDerivation (finalAttrs: { pkgs.mdbook-alerts ]; - inputs = lib.sourceFilesBySuffices ./. [ - ".md" - ".toml" - ".js" - ]; + # Build a source from the fileset containing the following paths, + # as well as all .md, .toml, & .js files in this directory + src = lib.fileset.toSource { + root = ../../.; + fileset = lib.fileset.unions [ + ../user-guide + ../modules + ../../CONTRIBUTING.md + (lib.fileset.fileFilter ( + { type, hasExt, ... }: + type == "regular" + && lib.any hasExt [ + "md" + "toml" + "js" + ] + ) ./.) + ]; + }; buildPhase = '' dest=$out/share/doc/nixvim mkdir -p $dest - # Copy inputs into the build directory - cp -r --no-preserve=all $inputs/* ./ - cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md - cp -r ${../user-guide} ./user-guide - cp -r ${../modules} ./modules + # Copy (and flatten) src into the build directory + cp -r --no-preserve=all $src/* ./ + mv ./docs/* ./ && rmdir ./docs + mv ./mdbook/* ./ && rmdir ./mdbook # Copy the generated MD docs into the build directory bash -e ${finalAttrs.passthru.copy-docs}