Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-options-doc: expose Nix set and add asciidoc variant #66436

Merged
merged 3 commits into from Aug 13, 2019

Conversation

domenkozar
Copy link
Member

No description provided.

@grahamc
Copy link
Member

grahamc commented Aug 10, 2019

What does this do?

@domenkozar
Copy link
Member Author

Allows you to render options via Nix structures instead of using JSON.

@domenkozar domenkozar changed the title make-options-doc: expose Nix set make-options-doc: expose Nix set and add asciidoc variant Aug 10, 2019
@domenkozar
Copy link
Member Author

domenkozar commented Aug 10, 2019

Given that you have ./module.nix with your own custom nixos modules you can now do:

{ pkgs }:

let
  eval = import (pkgs.path + "/nixos/lib/eval-config.nix") {
    baseModules = [
      ../module.nix
    ];
    modules = [];
  };
  options = pkgs.nixosOptionsDoc {
    options = eval.options;
  };

in {
  options = pkgs.writeText "my-nixos-options" ''
  = NixOS Options

  ${options.optionsAsciiDoc}
  '' ;
}

I'll post the result example :)

singleAsciiDoc = name: value: ''
== ${name}

${value.description}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, options docs assume Docbook in many places. Things like </para><para> and <literal> are pretty common in descriptions. So it would be more complicated than this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to process those, but this is a good start for options outside of nixos (I don't expect asciidoc to be used in nixos).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, so it was not clear that this is not a start if asciidocization, but just a helper function for modules written outside of Nixpkgs. And nobody should really try to use this against default Nixos modules.

And really, only optionsNix has to be exposed here. Everything else can be built on top of outside of Nixpkgs. This asciidoc variant is more of an example, but a useful example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a start, but it's only really useful outside of nixpkgs and partially inside nixpkgs.

Everything else can be built on top of outside of Nixpkgs.

Nixpkgs is supposed to be the central Nix packaging repo and since Hydra doesn't allow IFD, there's little choice here. Flakes will make it easier, but as of today in order to distribute reusable Nix code, nixpkgs is the only sane place.

Think of it this way: if we never challenge docbook tooling, we'll be stuck with it forever. Some might like this, but why kill the efforts of those that don't?

Copy link
Contributor

@danbst danbst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I like optionsNix is exposed and another type of options formatting method is presented.

@domenkozar domenkozar merged commit 0047672 into NixOS:master Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants