Skip to content

Instantly share code, notes, and snippets.

@mochienya
Last active October 29, 2025 22:40
Show Gist options
  • Select an option

  • Save mochienya/bbdb13458cb457d2213686d910490096 to your computer and use it in GitHub Desktop.

Select an option

Save mochienya/bbdb13458cb457d2213686d910490096 to your computer and use it in GitHub Desktop.
nix attrset stringifier
{
__toString =
self:
let
keys = builtins.filter (n: n != "__toString") (builtins.attrNames self);
pairs = builtins.map (key: " ${key} = ${self.${key}};") keys;
in
builtins.concatStringsSep "\n" (
builtins.concatLists [
[ "{" ]
pairs
[ "}" ]
]
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment