mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
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.
This commit is contained in:
parent
e25eeff158
commit
72b7e8668c
3 changed files with 22 additions and 27 deletions
|
@ -13,28 +13,30 @@ with pkgs;
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
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 {
|
optionsDoc = buildPackages.nixosOptionsDoc {
|
||||||
inherit options revision;
|
inherit options;
|
||||||
transformOptions = opt: opt // {
|
transformOptions = opt: opt // {
|
||||||
# Clean up declaration sites to not refer to the nix-darwin source tree.
|
# Clean up declaration sites to not refer to the nix-darwin source tree.
|
||||||
# TODO: handle `extraSources`? (it's not set anywhere)
|
# TODO: handle `extraSources`? (it's not set anywhere)
|
||||||
declarations = map
|
declarations = map
|
||||||
(decl:
|
(decl:
|
||||||
if lib.hasPrefix (toString prefix) (toString decl) then
|
if lib.hasPrefix (toString prefix) (toString decl) then
|
||||||
let
|
gitHubDeclaration "LnL7" "nix-darwin" revision
|
||||||
subpath = lib.removePrefix "/"
|
(lib.removePrefix "/"
|
||||||
(lib.removePrefix (toString prefix) (toString decl));
|
(lib.removePrefix (toString prefix) (toString decl)))
|
||||||
in {
|
|
||||||
url = "https://github.com/LnL7/nix-darwin/blob/${revision}/${subpath}";
|
|
||||||
name = "<nix-darwin/${subpath}>";
|
|
||||||
}
|
|
||||||
# TODO: handle this in a better way (may require upstream
|
# TODO: handle this in a better way (may require upstream
|
||||||
# changes to nixpkgs)
|
# changes to nixpkgs)
|
||||||
else if decl == "lib/modules.nix" then
|
else if decl == "lib/modules.nix" then
|
||||||
{
|
gitHubDeclaration "NixOS" "nixpkgs" nixpkgsRevision decl
|
||||||
url = "https://github.com/NixOS/nixpkgs/blob/${nixpkgsRevision}/${decl}";
|
|
||||||
name = "<nixpkgs/${decl}>";
|
|
||||||
}
|
|
||||||
else decl)
|
else decl)
|
||||||
opt.declarations;
|
opt.declarations;
|
||||||
};
|
};
|
||||||
|
@ -73,7 +75,7 @@ in rec {
|
||||||
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
|
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
|
||||||
|
|
||||||
substitute ${./manual.md} manual.md \
|
substitute ${./manual.md} manual.md \
|
||||||
--replace '@DARWIN_VERSION@' "${version}"\
|
--replace '@DARWIN_VERSION@' "${version}" \
|
||||||
--replace \
|
--replace \
|
||||||
'@DARWIN_OPTIONS_JSON@' \
|
'@DARWIN_OPTIONS_JSON@' \
|
||||||
${optionsJSON}/share/doc/darwin/options.json
|
${optionsJSON}/share/doc/darwin/options.json
|
||||||
|
@ -82,7 +84,7 @@ in rec {
|
||||||
nixos-render-docs -j $NIX_BUILD_CORES manual html \
|
nixos-render-docs -j $NIX_BUILD_CORES manual html \
|
||||||
--manpage-urls ${pkgs.writeText "manpage-urls.json" "{}"} \
|
--manpage-urls ${pkgs.writeText "manpage-urls.json" "{}"} \
|
||||||
--revision ${lib.escapeShellArg revision} \
|
--revision ${lib.escapeShellArg revision} \
|
||||||
--generator "nixos-render-docs ${pkgs.lib.version}" \
|
--generator "nixos-render-docs ${lib.version}" \
|
||||||
--stylesheet style.css \
|
--stylesheet style.css \
|
||||||
--stylesheet overrides.css \
|
--stylesheet overrides.css \
|
||||||
--stylesheet highlightjs/mono-blue.css \
|
--stylesheet highlightjs/mono-blue.css \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
toplevel@{ config, lib, pkgs, baseModules, modules, ... }:
|
{ config, lib, pkgs, baseModules, modules, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -25,15 +25,7 @@ let
|
||||||
inherit pkgs config;
|
inherit pkgs config;
|
||||||
version = config.system.darwinVersion;
|
version = config.system.darwinVersion;
|
||||||
revision = config.system.darwinRevision;
|
revision = config.system.darwinRevision;
|
||||||
nixpkgsRevision =
|
inherit (config.system) nixpkgsRevision;
|
||||||
if toplevel.options.system.nixpkgsRevision.isDefined
|
|
||||||
then config.system.nixpkgsRevision
|
|
||||||
|
|
||||||
# If user does not use flakes and does not add rev to nixpkgs, we don't
|
|
||||||
# know which revision or even branch they're on. In this case we still want
|
|
||||||
# to link somewhere, so we hope that master hasn't changed too much.
|
|
||||||
else "master";
|
|
||||||
|
|
||||||
options =
|
options =
|
||||||
let
|
let
|
||||||
scrubbedEval = evalModules {
|
scrubbedEval = evalModules {
|
||||||
|
|
|
@ -67,8 +67,8 @@ in
|
||||||
|
|
||||||
system.darwinRevision = mkOption {
|
system.darwinRevision = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
default = "master";
|
default = null;
|
||||||
description = lib.mdDoc "The darwin git revision from which this configuration was built.";
|
description = lib.mdDoc "The darwin git revision from which this configuration was built.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,7 +92,8 @@ in
|
||||||
|
|
||||||
system.nixpkgsRevision = mkOption {
|
system.nixpkgsRevision = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
description = lib.mdDoc "The nixpkgs git revision from which this configuration was built.";
|
description = lib.mdDoc "The nixpkgs git revision from which this configuration was built.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue