2023-07-07 08:02:38 +00:00
|
|
|
{ config, lib, pkgs, baseModules, modules, ... }:
|
2019-05-04 13:38:17 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.documentation;
|
|
|
|
|
2021-12-20 21:49:23 +00:00
|
|
|
# To reference the regular configuration from inside the docs evaluation further down.
|
|
|
|
# While not strictly necessary, this extra binding avoids accidental name capture in
|
|
|
|
# the future.
|
|
|
|
regularConfig = config;
|
|
|
|
|
|
|
|
argsModule = {
|
2023-07-24 22:24:20 +00:00
|
|
|
config._module.args = regularConfig._module.args // {
|
2021-12-20 21:49:23 +00:00
|
|
|
modules = [ ];
|
2023-07-24 22:24:20 +00:00
|
|
|
};
|
2021-12-20 21:49:23 +00:00
|
|
|
};
|
|
|
|
|
2019-05-04 13:38:17 +00:00
|
|
|
/* For the purpose of generating docs, evaluate options with each derivation
|
|
|
|
in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}".
|
|
|
|
It isn't perfect, but it seems to cover a vast majority of use cases.
|
|
|
|
Caveat: even if the package is reached by a different means,
|
|
|
|
the path above will be shown and not e.g. `${config.services.foo.package}`. */
|
2023-06-21 23:15:18 +00:00
|
|
|
realManual = import ../../doc/manual {
|
2019-05-04 13:38:17 +00:00
|
|
|
inherit pkgs config;
|
2019-05-04 19:03:17 +00:00
|
|
|
version = config.system.darwinVersion;
|
|
|
|
revision = config.system.darwinRevision;
|
2023-07-07 08:02:38 +00:00
|
|
|
inherit (config.system) nixpkgsRevision;
|
2019-05-04 13:38:17 +00:00
|
|
|
options =
|
|
|
|
let
|
2023-07-24 22:24:20 +00:00
|
|
|
scrubbedEval = evalModules {
|
|
|
|
modules = baseModules ++ [ argsModule ];
|
2019-05-04 13:38:17 +00:00
|
|
|
specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
|
|
|
|
};
|
|
|
|
scrubDerivations = namePrefix: pkgSet: mapAttrs
|
|
|
|
(name: value:
|
|
|
|
let wholeName = "${namePrefix}.${name}"; in
|
|
|
|
if isAttrs value then
|
|
|
|
scrubDerivations wholeName value
|
|
|
|
// (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; })
|
|
|
|
else value
|
|
|
|
)
|
|
|
|
pkgSet;
|
|
|
|
in scrubbedEval.options;
|
|
|
|
};
|
|
|
|
|
2023-06-21 23:15:18 +00:00
|
|
|
# TODO: Remove this when dropping 22.11 support.
|
|
|
|
manual = realManual //
|
2023-07-07 00:30:20 +00:00
|
|
|
lib.optionalAttrs (!pkgs.buildPackages ? nixos-render-docs) rec {
|
2023-06-21 23:15:18 +00:00
|
|
|
optionsJSON = pkgs.writeTextFile {
|
|
|
|
name = "options.json-stub";
|
|
|
|
destination = "/share/doc/darwin/options.json";
|
|
|
|
text = "{}";
|
|
|
|
};
|
|
|
|
manpages = pkgs.writeTextFile {
|
|
|
|
name = "darwin-manpages-stub";
|
|
|
|
destination = "/share/man/man5/configuration.nix.5";
|
|
|
|
text = ''
|
|
|
|
.TH "CONFIGURATION\&.NIX" "5" "01/01/1980" "Darwin" "Darwin Reference Pages"
|
|
|
|
.SH "NAME"
|
|
|
|
\fIconfiguration\&.nix\fP \- Darwin system configuration specification
|
|
|
|
.SH "DESCRIPTION"
|
|
|
|
.PP
|
|
|
|
The nix\-darwin documentation now requires nixpkgs 23.05 to build.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
manualHTML = pkgs.writeTextFile {
|
|
|
|
name = "darwin-manual-html-stub";
|
|
|
|
destination = "/share/doc/darwin/index.html";
|
|
|
|
text = ''
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<title>Darwin Configuration Options</title>
|
|
|
|
The nix-darwin documentation now requires nixpkgs 23.05 to build.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
manualHTMLIndex = "${manualHTML}/share/doc/darwin/index.html";
|
|
|
|
};
|
|
|
|
|
2019-05-04 13:38:17 +00:00
|
|
|
helpScript = pkgs.writeScriptBin "darwin-help"
|
|
|
|
''
|
|
|
|
#! ${pkgs.stdenv.shell} -e
|
|
|
|
open ${manual.manualHTMLIndex}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
documentation.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2019-05-04 13:38:17 +00:00
|
|
|
Whether to install documentation of packages from
|
2023-06-22 11:21:32 +00:00
|
|
|
{option}`environment.systemPackages` into the generated system path.
|
2019-05-04 13:38:17 +00:00
|
|
|
|
|
|
|
See "Multiple-output packages" chapter in the nixpkgs manual for more info.
|
|
|
|
'';
|
|
|
|
# which is at ../../../doc/multiple-output.xml
|
|
|
|
};
|
|
|
|
|
|
|
|
documentation.man.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2023-06-22 11:21:32 +00:00
|
|
|
Whether to install manual pages and the {command}`man` command.
|
2019-05-04 13:38:17 +00:00
|
|
|
This also includes "man" outputs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
documentation.info.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2023-06-22 11:21:32 +00:00
|
|
|
Whether to install info pages and the {command}`info` command.
|
2019-05-04 13:38:17 +00:00
|
|
|
This also includes "info" outputs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
documentation.doc.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2023-06-22 11:21:32 +00:00
|
|
|
Whether to install documentation distributed in packages' `/share/doc`.
|
2019-05-04 13:38:17 +00:00
|
|
|
Usually plain text and/or HTML.
|
|
|
|
This also includes "doc" outputs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
programs.man.enable = cfg.man.enable;
|
|
|
|
programs.info.enable = cfg.info.enable;
|
|
|
|
|
|
|
|
environment.systemPackages = mkMerge [
|
|
|
|
(mkIf cfg.man.enable [ manual.manpages ])
|
|
|
|
(mkIf cfg.doc.enable [ manual.manualHTML helpScript ])
|
|
|
|
];
|
|
|
|
|
|
|
|
system.build.manual = manual;
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|