I'm trying to debug a module I'm writing with builtins.trace
, but it's being more complicated than I anticipated.
Let's say I have a module:
{ config, lib, pkgs, modulesPath, ... }:
{
config =
let
some-list = lib.attrsets.mapAttrsToList (n: v: {
some-attr = "${n} ${v}";
}) { n1 = "v1"; n2 = "v2"; };
in {
users.mutableUsers = builtins.trace (some-list) false;
};
}
This will print
trace: [ <code> <code> ]
because builtins.trace
(for whatever reason?) evaluates its first argument only shallowly.
Changing the trace
expression to:
builtins.trace (builtins.toJSON some-list) false;
helps a lot, but as soon as one tries to print a long list or a structure with some complexity the output is completely unreadable, and it's not like it can easily be piped into jq
(I mean... &| grep ^trace: | sed 's/trace: //' | jq
works*, but there must be a "better" way?)
(*) in fish shell, IDK about bash
edit: It's not like I specifically want JSON output: any format will do (ideally, nix would be nice)
I don't see the reasoning in your answer (I do see its passive-aggressiveness, but chose to ignore it).
I asked "why?"; does your reply mean "because lack of manpower", "because lack of skill" or something else entirely?
In case you are new to the FOSS world, that being "open source" doesn't mean that something cannot be criticized or that people without the skill (or time!) to submit PRs must shut the fu*k up.