Skip to content

Commit c727317

Browse files
committed
add documentation.overrideAttrs
One use case is if your documentation depends on `recursive-nix`.
1 parent dcf7d40 commit c727317

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

modules/documentation.nix

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ in
6767
description = "Runtime inputs of mkdocs. Allows to make additional tools available when building the documentation.";
6868
};
6969

70+
overrideAttrs = lib.mkOption {
71+
type = lib.types.raw;
72+
default = _final: _prev: { };
73+
defaultText = "final: prev: {}";
74+
example = ''
75+
final: prev: {
76+
requiredSystemFeatures = [ "recursive-nix" ];
77+
NIX_CONFIG = '''
78+
experimental-features = nix-command recursive-nix
79+
store = unix:///build/.nix-socket
80+
substituters = unix:///build/.nix-socket
81+
''';
82+
}
83+
'';
84+
description = "Extension (`overrideAttrs`) for the `documentation` derivation.";
85+
};
86+
7087
strict = lib.mkEnableOption ''
7188
Build the documentation with `--strict`
7289
@@ -106,28 +123,30 @@ in
106123
# so we link to the project from the build dir.
107124
# the hook allows the user to prepopulate font files to help avoid mkdocs
108125
# connecting to the internet.
109-
packages.documentation = pkgs.runCommand "mkdocs-flake-documentation" { } ''
110-
cd ${abs_docs_dir}
111-
mkdocs_args=(
112-
--site-dir $out
113-
${strict}
114-
)
115-
config_file=${lib.optionalString (configFile != null) (toString configFile)}
116-
if [[ ! -z "$config_file" ]]; then
117-
mkdocs_args+=(
118-
--config-file "$config_file"
126+
packages.documentation =
127+
(pkgs.runCommand "mkdocs-flake-documentation" { } ''
128+
cd ${abs_docs_dir}
129+
mkdocs_args=(
130+
--site-dir $out
131+
${strict}
119132
)
120-
if [[ -f mkdocs.yml ]]; then
121-
2>&1 echo 'warning: local file `mkdocs.yml'"'"' ignored due to `documentation.settings'"'"
133+
config_file=${lib.optionalString (configFile != null) (toString configFile)}
134+
if [[ ! -z "$config_file" ]]; then
135+
mkdocs_args+=(
136+
--config-file "$config_file"
137+
)
138+
if [[ -f mkdocs.yml ]]; then
139+
2>&1 echo 'warning: local file `mkdocs.yml'"'"' ignored due to `documentation.settings'"'"
140+
fi
141+
elif [[ -f mkdocs.yml ]]; then
142+
mkdocs_args+=(
143+
--config-file mkdocs.yml
144+
)
122145
fi
123-
elif [[ -f mkdocs.yml ]]; then
124-
mkdocs_args+=(
125-
--config-file mkdocs.yml
126-
)
127-
fi
128-
eval "${cfg.mkdocs-preBuildHook}"
129-
${cfg.mkdocs-package}/bin/mkdocs build "''${mkdocs_args[@]}"
130-
'';
146+
eval "${cfg.mkdocs-preBuildHook}"
147+
${cfg.mkdocs-package}/bin/mkdocs build "''${mkdocs_args[@]}"
148+
'').overrideAttrs
149+
cfg.overrideAttrs;
131150

132151
apps.watch-documentation = {
133152
type = "app";

0 commit comments

Comments
 (0)