feat(docs): Also output raw markdown

This commit is contained in:
Jalil David Salamé Messina 2024-01-15 14:35:33 +01:00
parent 2d11a56619
commit e665e52fe2
Signed by: jalil
GPG key ID: F016B9E770737A0B
2 changed files with 13 additions and 10 deletions

View file

@ -1,16 +1,19 @@
{ pkgs, lib, ... }:
let
eval = lib.evalModules { modules = [ ../nixos/options.nix ]; };
doc = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark;
markdown = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark;
in
pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book";
src = ./.;
{
inherit markdown;
docs = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book";
src = ./.;
patchPhase = ''
# copy generated options removing the declared by statement
sed '/^\*Declared by:\*$/,/^$/d' <${doc} >> src/options.md
'';
patchPhase = ''
# copy generated options removing the declared by statement
sed '/^\*Declared by:\*$/,/^$/d' <${markdown} >> src/options.md
'';
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
};
}

View file

@ -31,7 +31,7 @@
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
# Module documentation
doc = forEachSupportedSystem ({ pkgs }: { doc = import ./docs { inherit pkgs lib; }; });
doc = forEachSupportedSystem ({ pkgs }: import ./docs { inherit pkgs lib; });
in
{
# Schemas tell Nix about the structure of your flake's outputs