Search code examples
nixnixos

Eager print in Nix in the repl


The documentation flake-utils has the following example as a doc

eachSystem [ system.x86_64-linux ] (system: { hello = 42; })
# => { hello = { x86_64-linux = 42; }; }
eachSystem allSystems (system: { hello = 42; })
# => {
   hello.aarch64-darwin = 42,
   hello.aarch64-genode = 42,
   hello.aarch64-linux = 42,
   ...
   hello.x86_64-redox = 42,
   hello.x86_64-solaris = 42,
   hello.x86_64-windows = 42
}

as far as I can tel, one has to

> nix repl
nix-repl> e = builtins.getFlake("github:numtide/flake-utils")
nix-repl> with e.outputs.lib;
          eachSystem [ system.x86_64-linux ] (system: { hello = 42; })

to get a result value (one can also do :a e.outputs.lib to "Add attributes from resulting set to scope" and not use the with ..; line )

{ hello = { ... }; }

Is there a way to "eagerly print" the value ?


Solution

  • What you are looking for is :p:

    > { a = 3; b = [ 1 2 3 ]; }
    { a = 3; b = [ ... ]; }
    > :p { a = 3; b = [ 1 2 3 ]; }
    { a = 3; b = [ 1 2 3 ]; }
    >