Nix library¶
Main functions¶
- nixdomainLib.documentObjects[source]¶
Document the given objects.
- Type:
{ sources; options; packages; library; } -> store path- Parameters:
sources (attrSet of strings) – a
source-name -> source-pathattribute set. The sourceselfis expected to be your project’s root path.options (attrSet) – the set of options to document, forwarded to
options.document. See its documentation for more information.packages (attrSet) – the set of packages to document, forwarded to
packages.document. See its documentation for more information.library (attrSet) – the set of functions to document, forwarded to
library.document. See its documentation for more information.
- Returns:
a JSON file used by the
sphinxcontrib-nixdomainSphinx extension, to be passed through theNIXDOMAIN_OBJECTSenvironment variable.
Example usage¶lib.documentObjects { sources = { self = inputs.self.outPath; nixpkgs = inputs.nixpkgs.outPath; }; options = { options = (inputs.nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ self.nixosModules.default ]; }).options; extraFilters = [ # Example filter: the option has a description (opt: opt ? description) ]; packages.packages = inputs.self.packages.x86_64-linux; library = { # Choosing a name different than "lib" is recommended, # to avoid confusion with Nixpkgs' "lib" name = "myLib"; library = inputs.self.lib; }; }; }
Customize options¶
- nixdomainLib.options.document[source]¶
Document the given options.
Tip
This function is called by
nixdomainLib.documentObjectswith itsoptionsattribute value. There is no need to call it directly, pass the arguments of this function to theoptionsattribute of thenixdomainLib.documentObjectsfunction.- Type:
{ sources; options; filters; extraFilters; modifiers; extraModifiers; } -> attrSet
- Parameters:
sources (attrSet of strings) – see
nixdomainLib.documentObjects.options (attrSet of options) – the set of options to document, as returned by
(lib.nixosSystem { ... }).options.filters (list of (option -> bool) functions) – a list of function that filters the set of options to document. By default, keep only visible options that are declared in the
selfsource.extraFilters (list of (option -> bool) functions) – extra filters to apply in addition to
filters.modifiers (list of (option -> option) functions) – apply this list of function to each option. By default, make the option declarations relative to the given
sources.extraModifiers (list of (option -> option) functions) – extra modifiers to apply in addition to
modifiers.
- Returns:
an attribute set of options, usable by the
sphinxcontrib-nixdomainSphinx extension.
- nixdomainLib.options.attrSetToDocList[source]¶
Generate documentation template from the list of option declaration like the set generated with filterOptionSets.
Originally taken from nixpkgs’
lib.optionAttrSetToDocList.
- nixdomainLib.options.renderOptionValue[source]¶
Ensures that the given option value (default or example) is a string by rendering Nix values.
- nixdomainLib.options.filters.isVisible[source]¶
Returns whether the given option should be visible in the documentation.
- Type:
option :: option -> bool- Parameters:
option (option) – the option to check
- nixdomainLib.options.filters.isDeclaredIn[source]¶
Returns whether the given option is declared in the given directory.
- Type:
prefix :: string -> option :: option -> bool- Parameters:
prefix (string) – the directory where the option should be declared
option (option) – the option to check
- nixdomainLib.options.modifiers.relativeDeclaration[source]¶
URLify the declarations of the given option.
- Type:
sources :: attrSet -> option :: option -> bool- Parameters:
sources (attrSet of strings) – the available sources to replace
option (option) – the option whose declarations to change
- Returns:
the modified option
Customize packages¶
- nixdomainLib.packages.document[source]¶
Document the given packages.
Tip
This function is called by
nixdomainLib.documentObjectswith itspackagesattribute value. There is no need to call it directly, pass the arguments of this function to thepackagesattribute of thenixdomainLib.documentObjectsfunction.- Type:
{ sources; packages; filters; extraFilters; modifiers; extraModifiers; metaAttributes; } -> attrSet
- Parameters:
sources (attrSet of strings) – see
nixdomainLib.documentObjects.packages (attrSet of packages) – the set of packages to document. Follows the
lib.recurseIntoAttrsindicator when recursing into children attribute sets.filters (list of (package -> bool) functions) – a list of function that filters the set of packages to document. By default, no filter is applied.
extraFilters (list of (package -> bool) functions) – extra filters to apply in addition to
filters.modifiers (list of (package -> package) functions) – apply this list of function to each package. By default, make the package declaration relative to the given
sources, and keep only the tier 1 and tier 2 platforms inplatformsattribute.extraModifiers (list of (package -> package) functions) – extra modifiers to apply in addition to
modifiers.
- Returns:
an attribute set of packages, usable by the
sphinxcontrib-nixdomainSphinx extension.
- nixdomainLib.packages.tier1Platforms[source]¶
The list of Nixpkgs tier 1 platforms.
- Type:
list of strings
- nixdomainLib.packages.tier2Platforms[source]¶
The list of Nixpkgs tier 2 platforms.
- Type:
list of strings
- nixdomainLib.packages.collectPackage[source]¶
Collect information about a given package, with the given meta attributes.
- Type:
metaAttrs :: list -> pkg :: package -> package- Parameters:
metaAttrs (list of str) – the meta attributes to collect for the given package
pkg (package) – the package to collect information from
- nixdomainLib.packages.collect[source]¶
Collect all packages recursively, into an attribute set of
loc->derivation.Respects Nixpkgs’s
recurseIntoAttrs.Inspired by flake-utils’ flattenTree.
- Parameters:
metaAttrs (list of str) – the meta attributes to collect for each package
set (attribute set) – the set containing the packages to collect
- nixdomainLib.packages.modifiers.relativePosition[source]¶
URLify the position of the given package.
- Type:
sources :: attrSet -> pkg :: package -> package- Parameters:
sources (attrset of str) – the available sources to replace
pkg (package) – the package whose position to change
- Returns:
the modified package
- nixdomainLib.packages.modifiers.filterPlatforms[source]¶
Change the package’s declared platform to only show the given ones.
This function is useful to limit the shown platforms to only the supported ones.
- Type:
shownPlatforms :: list -> pkg :: package -> package- Parameters:
shownPlatforms (list of str) – the platforms to show
pkg (package) – the package to change
- Returns:
the modified package
Customize library¶
- nixdomainLib.library.document[source]¶
Document the given functions.
Tip
This function is called by
nixdomainLib.documentObjectswith itslibraryattribute value. There is no need to call it directly, pass the arguments of this function to thelibraryattribute of thenixdomainLib.documentObjectsfunction.- Type:
{ sources; library; name; } -> list
- Parameters:
sources (attrSet of strings) – see
nixdomainLib.documentObjects.library (attrSet of functions) – the set of functions to document. Recurses into children attribute sets and ignores undocumented functions.
name (string) – The name/prefix of the library. Defaults to
"lib".
- Returns:
a list of
nixdocinvocations to be run bynixdomainLib.documentObjects, which is then usable by thesphinxcontrib-nixdomainSphinx extension.
Utilities¶
- nixdomainLib.utils.pathToURL[source]¶
Convert a path that’s inside the Nix store to a URL to be passed to
nixdomain_linkcode_resolve.- Parameters:
sources (attrset of str) – the available sources to replace
path (str) – the path whose prefix to replace
- Returns:
the path with the prefix replaced