diff --git a/.gitignore b/.gitignore index b7bbb3d..b66b7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ !flake.nix !flake.lock !docs/**/*.nix +!docs/man/*.5 !lib/**/*.nix !modules/**/*.nix diff --git a/docs/default.nix b/docs/default.nix index 0e43095..68e0751 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -6,6 +6,8 @@ }: let + man = pkgs.callPackage ./man { inherit self; }; + baseModule = _: { # Hide documentation relating to _module.args, which isn't a part # of this flake @@ -35,6 +37,8 @@ let commonMark = docs.optionsCommonMark; json = docs.optionsJSON; nix = docs.optionsNix; + + man = man.build "modules" subcomponent docs.optionsJSON; }; in { diff --git a/docs/man/default.nix b/docs/man/default.nix new file mode 100644 index 0000000..a2f8448 --- /dev/null +++ b/docs/man/default.nix @@ -0,0 +1,30 @@ +{ pkgs, self, ... }: +{ + build = type: subcomponent: json: + pkgs.runCommand "hylonix-${subcomponent}-manpage" + { + header = ./header.5; + footer = ./footer.5; + inherit type subcomponent json; + revision = self.lastModifiedDate; + + nativeBuildInputs = [ + pkgs.buildPackages.installShellFiles + pkgs.nixos-render-docs + ]; + allowedReferences = [ "out" ]; + } + '' + substitute "$header" ./header \ + --subst-var subcomponent \ + --subst-var type + + nixos-render-docs -j $NIX_BUILD_CORES options manpage \ + --revision "$revision" \ + --header ./header \ + --footer "$footer" \ + "$json/share/doc/nixos/options.json" \ + "hylonix-$subcomponent.5" + installManPage hylonix-*.5 + ''; +} diff --git a/docs/man/footer.5 b/docs/man/footer.5 new file mode 100644 index 0000000..2f8f7a8 --- /dev/null +++ b/docs/man/footer.5 @@ -0,0 +1,3 @@ +.SH "AUTHORS" +.PP +hylodon diff --git a/docs/man/header.5 b/docs/man/header.5 new file mode 100644 index 0000000..cccafe8 --- /dev/null +++ b/docs/man/header.5 @@ -0,0 +1,11 @@ +.TH "HYLONIX" "5" "01/01/1970" "hylonix" +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" enable line breaks after slashes +.cflags 4 / +.SH "NAME" +\fIhylonix-@subcomponent@\fP \- @type@ from the hylonix flake +.SH "OPTIONS" +.PP