Update flake.lock (#760)

* flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/19cbff58383a4ae384dea4d1d0c823d72b49d614' (2023-11-22)
  → 'github:NixOS/nixpkgs/8cfef6986adfb599ba379ae53c9f5631ecd2fd9c' (2023-11-27)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/e558068cba67b23b4fbc5537173dbb43748a17e8' (2023-11-15)
  → 'github:cachix/pre-commit-hooks.nix/e5ee5c5f3844550c01d2131096c7271cec5e9b78' (2023-11-25)

* docs: Fix NixOS manpage generation

NixOS/nixpkgs#269942 changed the signature of the NixOS ManpageConverter
to require a header and a footer. As those were the only changes in
nixvim-render-docs, we now use nixos-render-docs directly.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Miguel Gross Valle <Iggle@users.noreply.github.com>
This commit is contained in:
Gaétan Lepage 2023-11-29 10:30:27 +01:00 committed by GitHub
parent fda9e1e9a4
commit 5638a3f3a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 169 deletions

12
flake.lock generated
View file

@ -97,11 +97,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1700612854,
"narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=",
"lastModified": 1701068326,
"narHash": "sha256-vmMceA+q6hG1yrjb+MP8T0YFDQIrW3bl45e7z24IEts=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "19cbff58383a4ae384dea4d1d0c823d72b49d614",
"rev": "8cfef6986adfb599ba379ae53c9f5631ecd2fd9c",
"type": "github"
},
"original": {
@ -163,11 +163,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1700064067,
"narHash": "sha256-1ZWNDzhu8UlVCK7+DUN9dVQfiHX1bv6OQP9VxstY/gs=",
"lastModified": 1700922917,
"narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "e558068cba67b23b4fbc5537173dbb43748a17e8",
"rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78",
"type": "github"
},
"original": {

View file

@ -8,9 +8,7 @@
url = "https://github.com/${user}/${repo}/blob/master/${subpath}";
name = "<${repo}/${subpath}>";
};
in rec {
nixvim-render-docs = pkgs.callPackage ./nixvim-render-docs {};
in {
man-docs = let
eval = pkgs.lib.evalModules {
inherit modules;
@ -38,13 +36,16 @@ in rec {
};
in
pkgs.runCommand "nixvim-configuration-reference-manpage" {
nativeBuildInputs = with pkgs; [installShellFiles nixvim-render-docs];
nativeBuildInputs = with pkgs; [installShellFiles nixos-render-docs];
} ''
# Generate man-pages
mkdir -p $out/share/man/man5
nixvim-render-docs -j $NIX_BUILD_CORES options manpage \
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision unstable \
--header ${./nixvim-header.5} \
--footer ${./nixvim-footer.5} \
${options.optionsJSON}/share/doc/nixos/options.json \
$out/share/man/man5/nixvim.5
compressManPages $out
'';
}

3
man-docs/nixvim-footer.5 Normal file
View file

@ -0,0 +1,3 @@
.SH "AUTHORS"
.PP
nixvim maintainers

15
man-docs/nixvim-header.5 Normal file
View file

@ -0,0 +1,15 @@
.TH "NIXVIM" "5" "01/01/1980" "Nixvim" "Nixvim Reference Pages"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" enable line breaks after slashes
.cflags 4 /
.SH "NAME"
nixvim options specification
.SH "DESCRIPTION"
.PP
This page lists all the options that can be used in nixvim. Nixvim can either be used as a Home-Manager module, an NixOS module or a standalone package. Please refer to the installation instructions for more details.
.SH "OPTIONS"
.PP
You can use the following options in a nixvim module.

View file

@ -1,31 +0,0 @@
{
python3,
lib,
nixos-render-docs,
}:
python3.pkgs.buildPythonApplication {
pname = "nixvim-render-docs";
version = "0.0";
format = "pyproject";
src = lib.cleanSourceWith {
filter = name: type:
lib.cleanSourceFilter name type
&& ! (type
== "directory"
&& builtins.elem (baseNameOf name) [
".pytest_cache"
".mypy_cache"
"__pycache__"
]);
src = ./src;
};
nativeBuildInputs = with python3.pkgs; [
setuptools
];
propagatedBuildInputs = [
nixos-render-docs
];
}

View file

@ -1,113 +0,0 @@
# Very laregly inspired by nixos_render_docs, in nixpkgs at:
# `pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs`
import argparse
import sys
import traceback
import json
import nixos_render_docs
from nixos_render_docs import parallel
from nixos_render_docs import options as nx_options
from nixos_render_docs.manpage import man_escape
from nixos_render_docs.md import md_escape
class NixvimManpageConverter(nx_options.ManpageConverter):
def __init__(self, revision, *, _options_by_id=None):
super().__init__(revision, _options_by_id=_options_by_id)
def finalize(self):
result = []
result += [
r'''.TH "NIXVIM" "5" "01/01/1980" "Nixvim" "Nixvim Reference Pages"''',
r""".\" disable hyphenation""",
r""".nh""",
r""".\" disable justification (adjust text to left margin only)""",
r""".ad l""",
r""".\" enable line breaks after slashes""",
r""".cflags 4 /""",
r'''.SH "NAME"''',
self._render("nixvim options specification"),
r'''.SH "DESCRIPTION"''',
r""".PP""",
self._render(
"This page lists all the options that can be used in nixvim. "
"Nixvim can either be used as a Home-Manager module, an NixOS module or a standalone package. "
"Please refer to the installation instructions for more details."
),
r'''.SH "OPTIONS"''',
r""".PP""",
self._render("You can use the following options in a nixvim module."),
]
for name, opt in self._sorted_options():
result += [
".PP",
f"\\fB{man_escape(name)}\\fR",
".RS 4",
]
result += opt.lines
if links := opt.links:
result.append(self.__option_block_separator__)
md_links = ""
for i in range(0, len(links)):
md_links += "\n" if i > 0 else ""
if links[i].startswith("#opt-"):
md_links += f"{i+1}. see the {{option}}`{self._options_by_id[links[i]]}` option"
else:
md_links += f"{i+1}. " + md_escape(links[i])
result.append(self._render(md_links))
result.append(".RE")
result += [
r'''.SH "AUTHORS"''',
r""".PP""",
r"""nixvim maintainers""",
]
return "\n".join(result)
def run_manpage_options(args):
md = NixvimManpageConverter(revision=args.revision)
with open(args.infile, "r") as f:
md.add_options(json.load(f))
with open(args.outfile, "w") as f:
f.write(md.finalize())
def run_options(args):
if args.format == "manpage":
run_manpage_options(args)
else:
raise RuntimeError("format not hooked up", args)
def main():
parser = argparse.ArgumentParser(description="render nixos manual bits")
parser.add_argument("-j", "--jobs", type=int, default=None)
commands = parser.add_subparsers(dest="command", required=True)
options = commands.add_parser("options")
formats = options.add_subparsers(dest="format", required=True)
manpage = formats.add_parser("manpage")
manpage.add_argument("--revision", required=True)
manpage.add_argument("infile")
manpage.add_argument("outfile")
args = parser.parse_args()
try:
parallel.pool_processes = args.jobs
if args.command == "options":
run_options(args)
else:
raise RuntimeError("command not hooked up", args)
except Exception as e:
traceback.print_exc()
nixos_render_docs.pretty_print_exc(e)
sys.exit(1)

View file

@ -1,14 +0,0 @@
[project]
name = "nixvim-render-docs"
version = "0.0"
description = "Renderer for Nixvim option docs"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
[project.scripts]
nixvim-render-docs = "nixvim_render_docs:main"
[build-system]
requires = ["setuptools"]