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

module system: internalise prefix-stripping logic #203994

Closed
wants to merge 8 commits into from

Conversation

ncfavier
Copy link
Member

@ncfavier ncfavier commented Dec 1, 2022

Split out from #199363, see discussions there.

Based on top of that PR to avoid conflicts, the first new commit is e9fe624.

Fixes #66917.

To do before merging:

  • prepare nixos-search for the new declaration format

To do after merging:

  • add information about lib.trivial.manualRevision to the release wiki
  • take advantage of these changes in nmd and home-manager

With the goal of making `toPretty` suitable for rendering option
values, render derivations as `<derivation foo-1.0>` instead of
`<derivation /nix/store/…-foo-1.0.drv>`.

This is to avoid causing sudden evaluation errors for out-of-tree
projects that have options with `default = pkgs.someUnfreePackage;` and
no `defaultText`.
Render un`_type`d defaults and examples as `literalExpression`s using
`lib.generators.toPretty` so that consumers don't have to reinvent Nix
pretty-printing. `renderOptionValue` is kept internal for now intentionally.

Make `toPretty` print floats as valid Nix values (without a tilde).

Get rid of the now-obsolete `substSpecial` function.

Move towards disallowing evaluation of packages in the manual by
raising a warning on `pkgs.foo.{outPath,drvPath}`; later, this should
throw an error. Instead, module authors should use `literalExpression`
and `mkPackageOption`.
This variable is set to "master" on master and "release-YY.DD" on the
release branches so that the manual can link to the correct revision.
A generic function to convert a path into a documentation-friendly
{path, source, url} triple based on a list of file sources.
Provides a mechanism for rendering paths relative to a known prefix
using angle bracket syntax. Backed by `lib.strings.lookupPrefix`.
Add an internal `_module.sources` option which specifies a list of
sources to be used by `lib.strings.lookupPrefix` to render paths in
option values and declarations.
The sources always include the `nixpkgsSource`, which links to the
manual for `lib.trivial.manualRevision`.

Implement this logic in a new `lib.optionsToDocTemplate` function which
deprecates `lib.optionAttrSetToDocList`. The returned option
declarations are now attrsets as returned by `lookupPrefix`.
If `decl.source` is set, then the declaration is rendered using angle
bracket syntax: `<${decl.source}/${decl.path}>`. Other consumers are
free to treat the source name as they intend.

Deprecate `documentation.nixos.extraModuleSources`, converting it to
`_module.sources` with `name` set to `_unknown`.

We now call `eval-cacheable-options.nix` with a single filtered nixpkgs
source, which is easier to maintain than a bunch of paths and allows
things to work more smoothly (mainly `lib.trivial.release` can access
../.version, and `lib.nixpkgsSource` works as intended so we don't
need to special-case anything).
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 1, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 1, 2022
@infinisil infinisil added the 6.topic: module system About "NixOS" module system internals label Apr 14, 2023
@ncfavier ncfavier closed this Nov 5, 2023
@bb010g
Copy link
Contributor

bb010g commented Nov 21, 2023

@ncfavier Why did you close this?

@ncfavier
Copy link
Member Author

ncfavier commented Nov 21, 2023

I hardly remember what it was about and I have no interest any more, feel free to steal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: module system About "NixOS" module system internals 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

nixos/doc: Source links are broken, pointing at "release-19.09"
3 participants