1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Printing a string with escapes in it will render as a string normally.

  nix-repl> "meow\n\nmeowmeowmeow"
  "meow\n\nmeowmeowmeow"

But with :p on the string itself it will print it literally to the output.

  nix-repl> :p "meow\n\nmeowmeowmeow"
  meow

  meowmeowmeow

  nix-repl> builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
  {
    meow0 = { ... };
    meow1 = { ... };
    meow2 = { ... };
    meow3 = { ... };
    meow4 = { ... };
    meow5 = { ... };
    meow6 = { ... };
    meow7 = { ... };
    meow8 = { ... };
    meow9 = { ... };
  }

Also, :p will expand attrs, but it will leave the strings escaped as normal if
they aren't the top level item being printed.

  nix-repl> :p builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
  {
    meow0 = {
      meow = {
        s = "meowmeow\n\n0";
        x = 0;
      };
    };
    meow1 = {
      meow = {
        s = "meowmeow\n\n1";
        x = 1;
      };
    };
    meow2 = {
      meow = {
        s = "meowmeow\n\n2";
        x = 2;
      };
    };
    meow3 = {
      meow = {
        s = "meowmeow\n\n3";
        x = 3;
      };
    };
    meow4 = {
      meow = {
        s = "meowmeow\n\n4";
        x = 4;
      };
    };
    meow5 = {
      meow = {
        s = "meowmeow\n\n5";
        x = 5;
      };
    };
    meow6 = {
      meow = {
        s = "meowmeow\n\n6";
        x = 6;
      };
    };
    meow7 = {
      meow = {
        s = "meowmeow\n\n7";
        x = 7;
      };
    };
    meow8 = {
      meow = {
        s = "meowmeow\n\n8";
        x = 8;
      };
    };
    meow9 = {
      meow = {
        s = "meowmeow\n\n9";
        x = 9;
      };
    };
  }

Printing an environment with :env after adding a variable to the scope

  nix-repl> foo = "bar"
  nix-repl> :env
  Env level 0
  static: foo

  Env level 1
  abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true

Printing a derivation or something

  nix-repl> fakeDrv = let drvAttrs = { builder = "meow"; system = "meower"; name = "mrowmrow"; }; in { inherit (drvAttrs) builder system name; inherit drvAttrs; type = "derivation"; }
  nix-repl> :p fakeDrv
  {
    builder = "meow";
    drvAttrs = «3 attributes elided»;
    name = "mrowmrow";
    system = "meower";
    type = "derivation";
  }