Skip to main content

Module nix

Module nix 

Source
Expand description

Lexical helpers over Nix text, shared by the source and target observations.

No Nix parser is embedded: these scanners know comments, strings, bracket depth, let … in, and attribute tokens, which is what a presence judgement needs and no more. Where they cannot judge, the callers report a manual pair rather than a guess.

Functions§

attribute_range
The byte range of the attribute name’s value in text, as attribute_value slices it.
attribute_value
The value of the attribute name where text binds it, as name = <value>; or through a path name.<rest> = <value>;: the text after the = up to the ; that closes the binding.
binding_value
The text of one binding’s value, up to the ; that closes it.
input_declaration
The declaration of the flake input input inside a flake text.
is_default_package_path
Whether text binds a default package path at index.
is_ident
Whether a byte can continue a Nix identifier.
names_attribute
Whether text binds the attribute name: the name as a whole token, bare or quoted, followed by =.
scrub
Nix text with block comments, line comments, and string contents blanked, so a word inside any of them never reads as syntax.
without_let_bindings
The text with every let … in binding list blanked, so a local binding never reads as an attribute of the value the expression returns.