refactor(docs): move to flake modules
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

No need for a separate default.nix
This commit is contained in:
Jalil David Salamé Messina 2024-12-26 22:47:38 +01:00
parent d667c7a537
commit 8dd1b00967
Signed by: jalil
GPG key ID: F016B9E770737A0B
2 changed files with 48 additions and 70 deletions

View file

@ -1,60 +0,0 @@
{ pkgs, lib }:
let
# 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=";
};
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
{
inherit nixos-markdown nvim-markdown home-markdown;
docs = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-configuration-book";
src = ./.;
patchPhase = ''
mkdir -p ./theme
ln -s ${highlight} ./theme/highlight.js
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
# copy generated options removing the declared by statement
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
'';
nativeBuildInputs = [ pkgs.mdbook-toc ];
buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out";
};
}

View file

@ -1,24 +1,62 @@
{ lib, ... }:
{ lib, inputs, ... }:
{
perSystem =
{ pkgs, ... }:
{
packages =
let
docs-pkg = import ../docs { inherit pkgs lib; };
inherit (docs-pkg)
docs
home-markdown
nixos-markdown
nvim-markdown
;
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
{
# Documentation
inherit docs;
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";
};
};
};
}