configuration.nix/flake-modules/docs.nix
Jalil David Salamé Messina 8dd1b00967
All checks were successful
/ check (nvimDev) (push) Successful in 5s
/ check (nvimHeadless) (push) Successful in 2s
/ check (nvimNoBundledBins) (push) Successful in 4s
/ check (nvimNoLsp) (push) Successful in 5s
/ check (nvimNoTSGrammars) (push) Successful in 8s
/ check (treefmt) (push) Successful in 4s
/ build (audiomenu) (push) Successful in 1s
/ build (docs) (push) Successful in 1s
/ build (jpassmenu) (push) Successful in 1s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 2s
/ build (nvim) (push) Successful in 1s
/ report-size (push) Successful in 4s
refactor(docs): move to flake modules
No need for a separate default.nix
2024-12-26 23:06:49 +01:00

62 lines
2.2 KiB
Nix

{ lib, inputs, ... }:
{
perSystem =
{ pkgs, ... }:
{
packages =
let
filterVisible =
toplevelOption: option:
option // { visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption; };
home-eval = lib.evalModules {
modules = [ ../home/options.nix ];
specialArgs = {
inherit pkgs;
};
};
nvim-eval = lib.evalModules { modules = [ ../nvim/options.nix ]; };
nixos-eval = lib.evalModules { modules = [ ../system/options.nix ]; };
home-markdown =
(pkgs.nixosOptionsDoc {
inherit (home-eval) options;
transformOptions = filterVisible "jhome";
}).optionsCommonMark;
nvim-markdown =
(pkgs.nixosOptionsDoc {
inherit (nvim-eval) options;
transformOptions = filterVisible "jhome";
}).optionsCommonMark;
nixos-markdown =
(pkgs.nixosOptionsDoc {
inherit (nixos-eval) options;
transformOptions = filterVisible "jconfig";
}).optionsCommonMark;
in
{
docs-home-markdown = home-markdown;
docs-nixos-markdown = nixos-markdown;
docs-nvim-markdown = nvim-markdown;
# Documentation
docs = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book";
src = inputs.self + "/docs";
patchPhase = ''
cleanup_md() {
sed \
-e 's@\[/nix/store/[^\\]*-source/\(.*\)\\.nix\](.*)@[\1\\.nix](https://github.com/jalil-salame/configuration.nix/blob/main/\1.nix)@' \
-e 's/^## /### /' \
"$@"
}
# copy generated options removing the declared by statement
cleanup_md ${home-markdown} >> ./src/home-options.md
cleanup_md ${nvim-markdown} >> ./src/nvim-options.md
cleanup_md ${nixos-markdown} >> ./src/nixos-options.md
'';
nativeBuildInputs = [ pkgs.mdbook-toc ];
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
};
};
};
}