summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorEmily <vcs@emily.moe>2023-07-07 09:02:38 +0100
committerEmily <vcs@emily.moe>2023-07-09 07:26:00 +0100
commit72b7e8668c24950b8300ffe3d135dad1ae72a4f5 (patch)
treed2afd23e4d9a287018302065b56ecfaae998e71c /doc
parente25eeff158ceb415079e38f6e78a470c5664fa2f (diff)
version: default Git revision options to `null`
This allows for more uniform handling in the documentation generator, and avoids lying about the Git reference being `master` internally.
Diffstat (limited to 'doc')
-rw-r--r--doc/manual/default.nix30
1 files changed, 16 insertions, 14 deletions
diff --git a/doc/manual/default.nix b/doc/manual/default.nix
index 2225b51..5a0072a 100644
--- a/doc/manual/default.nix
+++ b/doc/manual/default.nix
@@ -13,28 +13,30 @@ with pkgs;
let
lib = pkgs.lib;
+ gitHubDeclaration = user: repo: ref: subpath:
+ # Default to `master` if we don't know what revision the system
+ # configuration is using (custom nixpkgs, etc.).
+ let urlRef = if ref != null then ref else "master";
+ in {
+ url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}";
+ name = "<${repo}/${subpath}>";
+ };
+
optionsDoc = buildPackages.nixosOptionsDoc {
- inherit options revision;
+ inherit options;
transformOptions = opt: opt // {
# Clean up declaration sites to not refer to the nix-darwin source tree.
# TODO: handle `extraSources`? (it's not set anywhere)
declarations = map
(decl:
if lib.hasPrefix (toString prefix) (toString decl) then
- let
- subpath = lib.removePrefix "/"
- (lib.removePrefix (toString prefix) (toString decl));
- in {
- url = "https://github.com/LnL7/nix-darwin/blob/${revision}/${subpath}";
- name = "<nix-darwin/${subpath}>";
- }
+ gitHubDeclaration "LnL7" "nix-darwin" revision
+ (lib.removePrefix "/"
+ (lib.removePrefix (toString prefix) (toString decl)))
# TODO: handle this in a better way (may require upstream
# changes to nixpkgs)
else if decl == "lib/modules.nix" then
- {
- url = "https://github.com/NixOS/nixpkgs/blob/${nixpkgsRevision}/${decl}";
- name = "<nixpkgs/${decl}>";
- }
+ gitHubDeclaration "NixOS" "nixpkgs" nixpkgsRevision decl
else decl)
opt.declarations;
};
@@ -73,7 +75,7 @@ in rec {
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
substitute ${./manual.md} manual.md \
- --replace '@DARWIN_VERSION@' "${version}"\
+ --replace '@DARWIN_VERSION@' "${version}" \
--replace \
'@DARWIN_OPTIONS_JSON@' \
${optionsJSON}/share/doc/darwin/options.json
@@ -82,7 +84,7 @@ in rec {
nixos-render-docs -j $NIX_BUILD_CORES manual html \
--manpage-urls ${pkgs.writeText "manpage-urls.json" "{}"} \
--revision ${lib.escapeShellArg revision} \
- --generator "nixos-render-docs ${pkgs.lib.version}" \
+ --generator "nixos-render-docs ${lib.version}" \
--stylesheet style.css \
--stylesheet overrides.css \
--stylesheet highlightjs/mono-blue.css \