I would love to have all of the builtins automatically added to my global scope when I’m playing around in Nix Repl. Even a little trick that someone might know so I can add it as a nix repl -E '...' wrapper or something as a shell alias.
I CANNOT be bothered to write builtins. ever again.
Essentially I want with builtins; or with lib; statements to persist for the life of the REPL. :l <nixpkgs/lib> actually accomplishes this for lib, but it wouldn’t work for actual attributes.
I’d prefer to have something like Haskell’s .ghci file. You can have one in your working directory or your home directory, and each line in the file is used as a command to ghci when it starts up. So you could just add :a builtins to such a file for nix repl
Yes!
I might need to spend a weekend to extend it or something. I’m sure its not even a big push. I get the sense that the repl just wasnt developed all that much.
λ nix repl <(echo builtins)
Welcome to Nix version 2.2. Type :? for help.
Loading '/proc/self/fd/12'...
error: getting status of '/proc/self/fd/pipe:[183479]': No such file or directory
=(echo builtins) must be a zsh thing? That’s certainly not supported by Bash. The Fish equivalent is nix repl (echo builtins | psub) which also works on NixOS. I’m not aware of any Bash equivalent for “write the contents to a temporary file, pass it to the command, and delete the file when the job completes”.
Not meant seriously, but if you don’t want to create a file¹ or use a different shell you could also vastly overengineer this by using a base64-encoded tar.xz passed via file:// URI:
Clearly someone needs to submit a PR to teach nix repl to accept a data: URI, thus allowing you to say nix repl data:text/plain,builtins. Or maybe just teach it accept plain text URLs in addition to tar.xz ones so you can say file://<(echo builtins).
Or I guess we could figure out why nix repl <(echo builtins) fails and fix it.