Skip to content

formatting trace-printed values #378

Description

@KiaraGrouwstra

one technique in debugging nix code is to use the trace functions.
in practice however, this would output something like:

trace: { __toString = «thunk»; _type = "option"; declarationPositions = «thunk»; declarations = «thunk»; default = «thunk»; definitions = «thunk»; definitionsWithLocations = «thunk»; description = "Hardcoded file secrets.\n"; files = «thunk»; highestPrio = «thunk»; isDefined = «thunk»; loc = [ "nodes" "machine" "testing" "hardcoded-secret" ]; options = [ ]; type = { _type = "option-type"; check = { __functor = «lambda __functor @ /home/kiara/code/nixpkgs/lib/types.nix:1279:21»; isV2MergeCoherent = true; }; deprecationMessage = null; description = «thunk»; descriptionClass = null; emptyValue = «thunk»; functor = «thunk»; getSubModules = [ { _file = «thunk»; imports = [ «lambda @ /home/kiara/code/nixpkgs/nixos/modules/testing/hardcoded-secret.nix:39:7» ]; } ]; getSubOptions = «thunk»; merge = { __functor = «thunk»; v2 = «lambda v2 @ /home/kiara/code/nixpkgs/lib/types.nix:1306:11»; }; name = "submodule"; nestedTypes = «thunk»; substSubModules = «thunk»; typeMerge = «thunk»; }; value = { directory = «thunk»; instances = «thunk»; }; valueMeta = «thunk»; }

now, given unformatted structures aren't particularly clear to the eye, one might then well hope to obtain a formatted version of such output.
however, one barrier in doing this is that this contains «thunk» and «lambda v2 @ /home/kiara/code/nixpkgs/lib/types.nix:1306:11», which make the formatter balk on such snippets.

this would then perhaps beg the question: how would y'all handle such a case? is there any way in which we could reuse what we have for formatting nix code to handle such use-cases as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions