executable_nix-repl 680 B

123456789101112131415161718192021222324252627
  1. #! /usr/bin/env cached-nix-shell
  2. #! nix-shell -i python3 -p python python3Packages.pexpect
  3. import os
  4. import sys
  5. import pexpect
  6. def main():
  7. prompt = ["nix-repl> "]
  8. child = pexpect.spawn("nix repl" + " ".join(sys.argv[2:]))
  9. child.logfile = sys.stdout.buffer
  10. child.expect(prompt)
  11. child.sendline(':a builtins.getFlake "github:nixos/nixpkgs"')
  12. child.expect(prompt)
  13. child.sendline(':a outputs.lib')
  14. child.expect(prompt)
  15. child.sendline(':a builtins')
  16. child.expect(prompt)
  17. child.sendline('pkgs = legacyPackages.x86_64-linux.pkgs')
  18. child.expect(prompt)
  19. child.logfile = None
  20. child.interact()
  21. if __name__ == '__main__':
  22. main()