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, ... }: { pkgs, lib, ... }:
let let
eval = lib.evalModules { modules = [ ../nixos/options.nix ]; }; eval = lib.evalModules { modules = [ ../nixos/options.nix ]; };
doc = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark; markdown = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark;
in in
pkgs.stdenvNoCC.mkDerivation { {
name = "nixos-configuration-book"; inherit markdown;
src = ./.; docs = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book";
src = ./.;
patchPhase = '' patchPhase = ''
# copy generated options removing the declared by statement # copy generated options removing the declared by statement
sed '/^\*Declared by:\*$/,/^$/d' <${doc} >> src/options.md 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" ]; supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; }); forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
# Module documentation # Module documentation
doc = forEachSupportedSystem ({ pkgs }: { doc = import ./docs { inherit pkgs lib; }; }); doc = forEachSupportedSystem ({ pkgs }: import ./docs { inherit pkgs lib; });
in in
{ {
# Schemas tell Nix about the structure of your flake's outputs # Schemas tell Nix about the structure of your flake's outputs