Hello, I am having difficulties in the way of debugging nix config.
For nix eval, --json isn’t applicable for outputs that contain functions (error: cannot convert a function to JSON). So manually piping to nixfmt is an option, but nixfmt can’t handle «» ( guillemets/double angle quotation marks). I tried using a simple to string conversion sed --null-data -E 's/«([^»]*?)»/"«\1»"/g' | nixfmt, but then nested guillemets (««»») stop it.
It’s just one example among the possibilities. My actual thing:
{
# each attr is in a different file, using import-tree
options.flake.my-options = {
# bunch of sub options with some types
};
options.flake.my-options.pkgs-overlay-attach-list = (lib.mkOption { default = [ ]; });
config.flake.my-options.pkgs-overlay-attach-list = [
(import inputs.emacs-overlay)
];
}
nix eval .#my-options => prints an attr set, some are functions so I’m looking for a formatter that works regardless
Or… this is an XY problem and I was using them wrong?
I didn’t know that, but curiously nix eval never prettified for me by default.
flake.nix example:
{
inputs.emacs-overlay.url = "github:nix-community/emacs-overlay";
outputs = (
inputs: {
foo = {
a = (import inputs.emacs-overlay);
b = 1;
c = false;
d = "str";
e = [0 1 2];
};
}
);
}
nix eval .#foo
Observed: { a = «lambda @ «github:nix-community/emacs-overlay/74cb2e9f130bba564295453b8a19eef53af202c5?narHash=sha256-TeI6bJI/AOaIG2Q0u9emJRt5EkWD0vwp9pVC2/yJMTs%3D»/default.nix:1:1»; b = 1; c = false; d = "str"; e = [ 0 1 2 ]; }
Expected:
{
a = "«lambda @ «github:nix-community/emacs-overlay/74cb2e9f130bba564295453b8a19eef53af202c5?narHash=sha256-TeI6bJI/AOaIG2Q0u9emJRt5EkWD0vwp9pVC2/yJMTs%3D»/default.nix:1:1»";
b = 1;
c = false;
d = "str";
e = [
0
1
2
];
}