2024-05-04 20:57:33 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
}: let
|
2024-01-31 22:32:05 +01:00
|
|
|
# can be removed once https://github.com/rust-lang/mdBook/pull/2262 lands
|
|
|
|
highlight = pkgs.fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/rust-lang/mdBook/7b9bd5049ce15ae5f301d5a40c50ce8359d9e9a8/src/theme/highlight.js";
|
|
|
|
hash = "sha256-pLP73zlmGkbC/zV6bwnB6ijRf9gVkj5/VYMGLhiQ1/Q=";
|
|
|
|
};
|
2024-05-04 20:57:33 +02:00
|
|
|
filterVisible = toplevelOption: option:
|
|
|
|
option // {visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption;};
|
2024-04-05 11:55:35 +02:00
|
|
|
home-eval = lib.evalModules {
|
2024-05-04 20:57:33 +02:00
|
|
|
modules = [../home/options.nix];
|
2024-04-05 11:55:35 +02:00
|
|
|
specialArgs = {
|
|
|
|
inherit pkgs;
|
|
|
|
};
|
|
|
|
};
|
2024-05-04 20:57:33 +02:00
|
|
|
nvim-eval = lib.evalModules {modules = [../nvim/options.nix];};
|
|
|
|
nixos-eval = lib.evalModules {modules = [../system/options.nix];};
|
2024-04-05 11:55:35 +02:00
|
|
|
home-markdown =
|
|
|
|
(pkgs.nixosOptionsDoc {
|
|
|
|
inherit (home-eval) options;
|
|
|
|
transformOptions = filterVisible "jhome";
|
2024-05-04 20:57:33 +02:00
|
|
|
})
|
|
|
|
.optionsCommonMark;
|
2024-04-05 11:55:35 +02:00
|
|
|
nvim-markdown =
|
|
|
|
(pkgs.nixosOptionsDoc {
|
|
|
|
inherit (nvim-eval) options;
|
|
|
|
transformOptions = filterVisible "jhome";
|
2024-05-04 20:57:33 +02:00
|
|
|
})
|
|
|
|
.optionsCommonMark;
|
2024-04-05 11:55:35 +02:00
|
|
|
nixos-markdown =
|
|
|
|
(pkgs.nixosOptionsDoc {
|
|
|
|
inherit (nixos-eval) options;
|
|
|
|
transformOptions = filterVisible "jconfig";
|
2024-05-04 20:57:33 +02:00
|
|
|
})
|
|
|
|
.optionsCommonMark;
|
|
|
|
in {
|
2024-02-16 20:36:20 +01:00
|
|
|
inherit nixos-markdown nvim-markdown home-markdown;
|
2024-01-15 14:35:33 +01:00
|
|
|
docs = pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "nixos-configuration-book";
|
|
|
|
src = ./.;
|
2024-01-14 18:58:08 +01:00
|
|
|
|
2024-01-15 14:35:33 +01:00
|
|
|
patchPhase = ''
|
2024-01-31 22:32:05 +01:00
|
|
|
mkdir -p ./theme
|
|
|
|
ln -s ${highlight} ./theme/highlight.js
|
|
|
|
|
2024-02-18 16:06:32 +01:00
|
|
|
cat > sed-cmds <<EOF
|
|
|
|
# Replace nix store path to github url
|
|
|
|
s:\[/nix/store/[^\\]*-source/\(.*\)\\.nix\](.*):[\1\\.nix](https\://github.com/jalil-salame/configuration.nix/blob/main/\1.nix):
|
|
|
|
# Make <h2> <h3>
|
|
|
|
s/^## /### /
|
|
|
|
EOF
|
2024-01-15 14:35:33 +01:00
|
|
|
# copy generated options removing the declared by statement
|
2024-02-18 16:06:32 +01:00
|
|
|
sed -f sed-cmds <${home-markdown} >> ./src/home-options.md
|
|
|
|
sed -f sed-cmds <${nvim-markdown} >> ./src/nvim-options.md
|
|
|
|
sed -f sed-cmds <${nixos-markdown} >> ./src/nixos-options.md
|
2024-01-15 14:35:33 +01:00
|
|
|
'';
|
2024-01-14 18:58:08 +01:00
|
|
|
|
2024-05-04 20:57:33 +02:00
|
|
|
nativeBuildInputs = [pkgs.mdbook-toc];
|
2024-01-15 14:35:33 +01:00
|
|
|
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
|
|
|
|
};
|
2024-01-14 18:58:08 +01:00
|
|
|
}
|