2022-06-26 20:55:07 +02:00
|
|
|
{ pkgs
|
2020-06-06 22:08:02 +02:00
|
|
|
|
2022-06-26 20:55:07 +02:00
|
|
|
# Note, this should be "the standard library" + HM extensions.
|
2023-06-28 23:55:00 +02:00
|
|
|
, lib ? import ../modules/lib/stdlib-extended.nix pkgs.lib
|
|
|
|
|
|
|
|
, release, isReleaseBranch }:
|
2018-05-06 22:14:50 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2022-06-26 20:55:07 +02:00
|
|
|
nmdSrc = fetchTarball {
|
|
|
|
url =
|
2023-06-24 19:28:15 +02:00
|
|
|
"https://git.sr.ht/~rycee/nmd/archive/824a380546b5d0d0eb701ff8cd5dbafb360750ff.tar.gz";
|
|
|
|
sha256 = "0vvj40k6bw8ssra8wil9rqbsznmfy1kwy7cihvm13rajwdg9ycgg";
|
2022-06-26 20:55:07 +02:00
|
|
|
};
|
|
|
|
|
2023-06-28 23:55:00 +02:00
|
|
|
nmd = import nmdSrc {
|
|
|
|
inherit lib;
|
|
|
|
# The DocBook output of `nixos-render-docs` doesn't have the change
|
|
|
|
# `nmd` uses to work around the broken stylesheets in
|
|
|
|
# `docbook-xsl-ns`, so we restore the patched version here.
|
|
|
|
pkgs = pkgs // {
|
|
|
|
docbook-xsl-ns =
|
|
|
|
pkgs.docbook-xsl-ns.override { withManOptDedupPatch = true; };
|
|
|
|
};
|
|
|
|
};
|
2018-12-18 18:09:56 +01:00
|
|
|
|
2019-08-27 23:40:52 +02:00
|
|
|
# Make sure the used package is scrubbed to avoid actually
|
|
|
|
# instantiating derivations.
|
|
|
|
scrubbedPkgsModule = {
|
2020-02-02 00:39:17 +01:00
|
|
|
imports = [{
|
|
|
|
_module.args = {
|
|
|
|
pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
|
|
|
|
pkgs_i686 = lib.mkForce { };
|
|
|
|
};
|
|
|
|
}];
|
2019-08-27 23:40:52 +02:00
|
|
|
};
|
|
|
|
|
2022-06-07 23:23:04 +02:00
|
|
|
dontCheckDefinitions = { _module.check = false; };
|
|
|
|
|
2023-06-28 23:55:00 +02:00
|
|
|
gitHubDeclaration = user: repo: subpath:
|
|
|
|
let urlRef = if isReleaseBranch then "release-${release}" else "master";
|
|
|
|
in {
|
|
|
|
url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}";
|
|
|
|
name = "<${repo}/${subpath}>";
|
|
|
|
};
|
2021-01-18 23:21:32 +01:00
|
|
|
|
2023-06-28 23:55:00 +02:00
|
|
|
hmPath = toString ./..;
|
|
|
|
|
2023-07-19 22:38:38 +02:00
|
|
|
buildOptionsDocs = args@{ modules, includeModuleSystemOptions ? true, ... }:
|
|
|
|
let options = (lib.evalModules { inherit modules; }).options;
|
|
|
|
in pkgs.buildPackages.nixosOptionsDoc ({
|
|
|
|
options = if includeModuleSystemOptions then
|
|
|
|
options
|
|
|
|
else
|
|
|
|
builtins.removeAttrs options [ "_module" ];
|
2023-06-28 23:55:00 +02:00
|
|
|
transformOptions = opt:
|
|
|
|
opt // {
|
|
|
|
# Clean up declaration sites to not refer to the Home Manager
|
|
|
|
# source tree.
|
|
|
|
declarations = map (decl:
|
|
|
|
if lib.hasPrefix hmPath (toString decl) then
|
|
|
|
gitHubDeclaration "nix-community" "home-manager"
|
|
|
|
(lib.removePrefix "/" (lib.removePrefix hmPath (toString decl)))
|
|
|
|
else if decl == "lib/modules.nix" then
|
|
|
|
# TODO: handle this in a better way (may require upstream
|
|
|
|
# changes to nixpkgs)
|
|
|
|
gitHubDeclaration "NixOS" "nixpkgs" decl
|
|
|
|
else
|
|
|
|
decl) opt.declarations;
|
|
|
|
};
|
2023-07-19 22:38:38 +02:00
|
|
|
} // builtins.removeAttrs args [ "modules" "includeModuleSystemOptions" ]);
|
2023-06-28 23:55:00 +02:00
|
|
|
|
|
|
|
hmOptionsDocs = buildOptionsDocs {
|
2020-02-02 00:39:17 +01:00
|
|
|
modules = import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
|
|
|
check = false;
|
|
|
|
} ++ [ scrubbedPkgsModule ];
|
2023-06-28 23:55:00 +02:00
|
|
|
variablelistId = "home-manager-options";
|
2018-12-18 18:09:56 +01:00
|
|
|
};
|
|
|
|
|
2023-06-28 23:55:00 +02:00
|
|
|
nixosOptionsDocs = buildOptionsDocs {
|
2022-06-07 23:23:04 +02:00
|
|
|
modules = [ ../nixos scrubbedPkgsModule dontCheckDefinitions ];
|
2023-07-19 22:38:38 +02:00
|
|
|
includeModuleSystemOptions = false;
|
2023-06-28 23:55:00 +02:00
|
|
|
variablelistId = "nixos-options";
|
|
|
|
optionIdPrefix = "nixos-opt-";
|
2021-01-18 23:21:32 +01:00
|
|
|
};
|
|
|
|
|
2023-06-28 23:55:00 +02:00
|
|
|
nixDarwinOptionsDocs = buildOptionsDocs {
|
2022-06-07 23:23:04 +02:00
|
|
|
modules = [ ../nix-darwin scrubbedPkgsModule dontCheckDefinitions ];
|
2023-07-19 22:38:38 +02:00
|
|
|
includeModuleSystemOptions = false;
|
2023-06-28 23:55:00 +02:00
|
|
|
variablelistId = "nix-darwin-options";
|
|
|
|
optionIdPrefix = "nix-darwin-opt-";
|
2021-01-18 23:21:32 +01:00
|
|
|
};
|
|
|
|
|
2018-12-18 18:09:56 +01:00
|
|
|
docs = nmd.buildDocBookDocs {
|
|
|
|
pathName = "home-manager";
|
2022-05-23 23:03:35 +02:00
|
|
|
projectName = "Home Manager";
|
2023-06-28 23:55:00 +02:00
|
|
|
modulesDocs = [{
|
|
|
|
docBook = pkgs.linkFarm "hm-module-docs-for-nmd" {
|
|
|
|
"nmd-result/home-manager-options.xml" = hmOptionsDocs.optionsDocBook;
|
|
|
|
"nmd-result/nix-darwin-options.xml" =
|
|
|
|
nixDarwinOptionsDocs.optionsDocBook;
|
|
|
|
"nmd-result/nixos-options.xml" = nixosOptionsDocs.optionsDocBook;
|
|
|
|
};
|
|
|
|
}];
|
2018-12-18 18:09:56 +01:00
|
|
|
documentsDirectory = ./.;
|
2020-04-19 11:53:31 +02:00
|
|
|
documentType = "book";
|
2018-12-18 18:09:56 +01:00
|
|
|
chunkToc = ''
|
|
|
|
<toc>
|
2018-05-06 22:14:50 +02:00
|
|
|
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-home-manager-manual"><?dbhtml filename="index.html"?>
|
|
|
|
<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry>
|
2021-01-18 23:21:32 +01:00
|
|
|
<d:tocentry linkend="ch-nixos-options"><?dbhtml filename="nixos-options.html"?></d:tocentry>
|
|
|
|
<d:tocentry linkend="ch-nix-darwin-options"><?dbhtml filename="nix-darwin-options.html"?></d:tocentry>
|
2019-06-09 01:47:43 +02:00
|
|
|
<d:tocentry linkend="ch-tools"><?dbhtml filename="tools.html"?></d:tocentry>
|
2019-01-20 17:38:34 +01:00
|
|
|
<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry>
|
2018-05-06 22:14:50 +02:00
|
|
|
</d:tocentry>
|
|
|
|
</toc>
|
|
|
|
'';
|
2018-12-18 18:09:56 +01:00
|
|
|
};
|
2018-05-06 22:14:50 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-08-28 20:36:11 +02:00
|
|
|
inherit nmdSrc;
|
2018-05-06 22:14:50 +02:00
|
|
|
|
2018-12-18 18:09:56 +01:00
|
|
|
options = {
|
2023-06-28 23:55:00 +02:00
|
|
|
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
|
|
|
|
# `nixosOptionsDoc` is more customizable.
|
|
|
|
json = pkgs.runCommand "options.json" {
|
|
|
|
meta.description = "List of Home Manager options in JSON format";
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/{share/doc,nix-support}
|
|
|
|
cp -a ${hmOptionsDocs.optionsJSON}/share/doc/nixos $out/share/doc/home-manager
|
|
|
|
substitute \
|
|
|
|
${hmOptionsDocs.optionsJSON}/nix-support/hydra-build-products \
|
|
|
|
$out/nix-support/hydra-build-products \
|
|
|
|
--replace \
|
|
|
|
'${hmOptionsDocs.optionsJSON}/share/doc/nixos' \
|
|
|
|
"$out/share/doc/home-manager"
|
|
|
|
'';
|
2018-12-18 18:09:56 +01:00
|
|
|
};
|
2018-05-06 22:14:50 +02:00
|
|
|
|
2018-12-18 18:09:56 +01:00
|
|
|
manPages = docs.manPages;
|
2018-05-06 22:14:50 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
manual = { inherit (docs) html htmlOpenTool; };
|
2021-12-29 10:15:39 +01:00
|
|
|
|
|
|
|
# Unstable, mainly for CI.
|
|
|
|
jsonModuleMaintainers = pkgs.writeText "hm-module-maintainers.json" (let
|
|
|
|
result = lib.evalModules {
|
|
|
|
modules = import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
|
|
|
check = false;
|
|
|
|
} ++ [ scrubbedPkgsModule ];
|
|
|
|
};
|
|
|
|
in builtins.toJSON result.config.meta.maintainers);
|
2018-05-06 22:14:50 +02:00
|
|
|
}
|