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

Commits on Dec 1, 2022

  1. nixos/doc: fix some options

    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    e0adfa1 View commit details
    Browse the repository at this point in the history
  2. lib/generators.toPretty: don't evaluate derivations

    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`.
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    baa1a0c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    59bde9a View commit details
    Browse the repository at this point in the history
  4. nixos/doc: render option values using lib.generators.toPretty

    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`.
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    42abb5a View commit details
    Browse the repository at this point in the history
  5. lib/trivial: add manualRevision

    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.
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    e9fe624 View commit details
    Browse the repository at this point in the history
  6. lib/strings: add lookupPrefix

    A generic function to convert a path into a documentation-friendly
    {path, source, url} triple based on a list of file sources.
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    5fa06d9 View commit details
    Browse the repository at this point in the history
  7. lib/generators.toPretty: add searchPath

    Provides a mechanism for rendering paths relative to a known prefix
    using angle bracket syntax. Backed by `lib.strings.lookupPrefix`.
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    a79632a View commit details
    Browse the repository at this point in the history
  8. module system: internalise prefix-stripping logic

    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).
    ncfavier committed Dec 1, 2022
    Configuration menu
    Copy the full SHA
    b3ab3a4 View commit details
    Browse the repository at this point in the history