2020-10-12 00:22:58 +00:00
|
|
|
{ pkgs
|
|
|
|
|
|
|
|
# Note, this should be "the standard library" + HM extensions.
|
2023-08-08 10:19:01 +00:00
|
|
|
, lib ? import ../modules/lib/stdlib-extended.nix pkgs.lib
|
|
|
|
|
|
|
|
, release, isReleaseBranch }:
|
2020-10-12 00:22:58 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
nmdSrc = fetchTarball {
|
|
|
|
url =
|
2024-01-05 11:06:15 +00:00
|
|
|
"https://git.sr.ht/~rycee/nmd/archive/f18defadcc25e69e95b04493ee02682005472255.tar.gz";
|
|
|
|
sha256 = "14fazjqbc6sfsxycwadfhcymi37xg5wmrlvg3jb8d4mpbcdwfwz4";
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
|
2023-08-08 10:19:01 +00: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; };
|
|
|
|
};
|
|
|
|
};
|
2020-10-12 00:22:58 +00:00
|
|
|
|
|
|
|
# Make sure the used package is scrubbed to avoid actually
|
|
|
|
# instantiating derivations.
|
|
|
|
scrubbedPkgsModule = {
|
|
|
|
imports = [{
|
|
|
|
_module.args = {
|
|
|
|
pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
|
|
|
|
pkgs_i686 = lib.mkForce { };
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
dontCheckDefinitions = { _module.check = false; };
|
|
|
|
|
2023-08-08 10:19:01 +00: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-07-02 22:36:30 +00:00
|
|
|
|
2023-08-08 10:19:01 +00:00
|
|
|
hmPath = toString ./..;
|
|
|
|
|
|
|
|
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" ];
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
} // builtins.removeAttrs args [ "modules" "includeModuleSystemOptions" ]);
|
|
|
|
|
|
|
|
hmOptionsDocs = buildOptionsDocs {
|
2020-10-12 00:22:58 +00:00
|
|
|
modules = import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
|
|
|
check = false;
|
|
|
|
} ++ [ scrubbedPkgsModule ];
|
2023-08-08 10:19:01 +00:00
|
|
|
variablelistId = "home-manager-options";
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
|
2023-08-08 10:19:01 +00:00
|
|
|
nixosOptionsDocs = buildOptionsDocs {
|
2023-01-10 09:35:00 +00:00
|
|
|
modules = [ ../nixos scrubbedPkgsModule dontCheckDefinitions ];
|
2023-08-08 10:19:01 +00:00
|
|
|
includeModuleSystemOptions = false;
|
|
|
|
variablelistId = "nixos-options";
|
|
|
|
optionIdPrefix = "nixos-opt-";
|
2021-07-02 22:36:30 +00:00
|
|
|
};
|
|
|
|
|
2023-08-08 10:19:01 +00:00
|
|
|
nixDarwinOptionsDocs = buildOptionsDocs {
|
2023-01-10 09:35:00 +00:00
|
|
|
modules = [ ../nix-darwin scrubbedPkgsModule dontCheckDefinitions ];
|
2023-08-08 10:19:01 +00:00
|
|
|
includeModuleSystemOptions = false;
|
|
|
|
variablelistId = "nix-darwin-options";
|
|
|
|
optionIdPrefix = "nix-darwin-opt-";
|
2021-07-02 22:36:30 +00:00
|
|
|
};
|
|
|
|
|
2024-01-05 11:06:15 +00:00
|
|
|
release-config = builtins.fromJSON (builtins.readFile ../release.json);
|
|
|
|
revision = "release-${release-config.release}";
|
|
|
|
# Generate the `man home-configuration.nix` package
|
|
|
|
home-configuration-manual =
|
|
|
|
pkgs.runCommand "home-configuration-reference-manpage" {
|
|
|
|
nativeBuildInputs =
|
|
|
|
[ pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs ];
|
|
|
|
allowedReferences = [ "out" ];
|
|
|
|
} ''
|
|
|
|
# Generate manpages.
|
|
|
|
mkdir -p $out/share/man/man5
|
|
|
|
mkdir -p $out/share/man/man1
|
|
|
|
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
|
|
|
--revision ${revision} \
|
|
|
|
--header ${./home-configuration-nix-header.5} \
|
|
|
|
--footer ${./home-configuration-nix-footer.5} \
|
|
|
|
${hmOptionsDocs.optionsJSON}/share/doc/nixos/options.json \
|
|
|
|
$out/share/man/man5/home-configuration.nix.5
|
|
|
|
cp ${./home-manager.1} $out/share/man/man1/home-manager.1
|
2020-10-12 00:22:58 +00:00
|
|
|
'';
|
2024-01-05 11:06:15 +00:00
|
|
|
# Generate the HTML manual pages
|
|
|
|
home-manager-manual = pkgs.callPackage ./home-manager-manual.nix {
|
|
|
|
nmd = nmdSrc;
|
|
|
|
home-manager-options = {
|
|
|
|
home-manager = hmOptionsDocs.optionsJSON;
|
|
|
|
nixos = nixosOptionsDocs.optionsJSON;
|
|
|
|
nix-darwin = nixDarwinOptionsDocs.optionsJSON;
|
|
|
|
};
|
|
|
|
inherit revision;
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
2024-01-05 11:06:15 +00:00
|
|
|
html = home-manager-manual;
|
|
|
|
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix { } { inherit html; };
|
2020-10-12 00:22:58 +00:00
|
|
|
in {
|
|
|
|
inherit nmdSrc;
|
|
|
|
|
|
|
|
options = {
|
2023-08-08 10:19:01 +00: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"
|
|
|
|
'';
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
|
2024-01-05 11:06:15 +00:00
|
|
|
manPages = home-configuration-manual;
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2024-01-05 11:06:15 +00:00
|
|
|
manual = { inherit html htmlOpenTool; };
|
2023-01-10 09:35:00 +00: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);
|
2020-10-12 00:22:58 +00:00
|
|
|
}
|