Nix Repl : add `builtins.*` to global scope

You can use an expect wrapper around nix repl that does what you need after it starts. The following always imports builtins:

#!/usr/bin/env nix-shell
#!nix-shell -i expect -p expect
spawn -noecho nix repl {*}$argv
expect "nix-repl> " {
  send ":a builtins\n"
  interact
}

But you can see that it’s easy to add more commands :slight_smile:

6 Likes