From c7026a993c4b837dcee39f669e1cc4123f4eb53d Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 8 Nov 2021 16:26:42 +0100 Subject: initial commit --- mdbook.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 mdbook.nix (limited to 'mdbook.nix') diff --git a/mdbook.nix b/mdbook.nix new file mode 100644 index 0000000..d336042 --- /dev/null +++ b/mdbook.nix @@ -0,0 +1,45 @@ +{ outputAttrPath, optionsAttrPath, optionsInternal ? true, }: + +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = getAttrFromPath (optionsAttrPath ++ [ "mdbook" ]) config; +in +{ + options = setAttrByPath optionsAttrPath { + mdbook = { + src = mkOption { + type = with types; either path package; + description = '' + Root directory of mdbook sources to compile. + ''; + internal = optionsInternal; + }; + }; + }; + + config = setAttrByPath outputAttrPath { + # TODO: make pandoc pre-processor + mdbook = pkgs.runCommand "mdbook" + { + src = cfg.src; + nativeBuildInputs = with pkgs; [ mdbook ]; + } '' + unpackFile "$src" + chmod -R u+w . + cd */ + + mkdir theme + cp ${pkgs.documentation-highlighter}/highlight.pack.js theme/highlight.js + cp ${pkgs.documentation-highlighter}/mono-blue.css theme/highlight.css + + cp "${getAttrFromPath (outputAttrPath ++ ["doc-options-md"]) config}" src/options.md + + mdbook build + + cp -r book "$out" + ''; + }; +} -- cgit v1.2.3