aboutsummaryrefslogtreecommitdiff
path: root/src/nix/repl.cc
AgeCommit message (Collapse)Author
2020-03-19nix repl: Put EvalState on the heapEelco Dolstra
See 0629601da1d163a059fa19004256961f8ecdeb78.
2020-03-19nix repl: Scan NixRepl for GC rootsEelco Dolstra
Fixes #3175.
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-05Make subcommand construction in MultiCommand lazyEelco Dolstra
(cherry picked from commit a0de58f471c9087d8e6cc60a6078f9940a125b15)
2019-10-28nix repl: also handle lambda editzimbatm
2019-10-28editorFor: take a pos object insteadzimbatm
2019-10-28libexpr: findDerivationFilename return Pos instead of tuplezimbatm
2019-10-23libexpr: add findDerivationFilenamezimbatm
extract the derivation to filename:lineno heuristic
2019-10-23libutil: add editorFor heuristiczimbatm
2019-10-23nix repl: add :edit commandzimbatm
This allows to have a repl-centric workflow to working on nixpkgs. Usage: :edit <package> - heuristic that find the package file path :edit <path> - just open the editor on the file path Once invoked, `nix repl` will open $EDITOR on that file path. Once the editor exits, `nix repl` will automatically reload itself.
2019-07-03Fix C++ compatibility with older editline versions.Niklas Hambüchen
For example, Ubuntu 16.04 and many similar long-term-support distros have older versions.
2019-03-24repl: Restore CTRL-C behaviourxbreak
Install signal handler during `readline` to handle SIGINT to abort partially typed expressions.
2019-02-05Revert "Restore parent mount namespace before executing a child process"Eelco Dolstra
This reverts commit a0ef21262f4d5652bfb65cfacaec01d89c475a93. This doesn't work in 'nix run' and nix-shell because setns() fails in multithreaded programs, and Boehm GC mark threads are uncancellable. Fixes #2646.
2018-12-25remove some dead code in nix/repl.ccDmitry Kalinkin
Fixes a static analyzer warning: Expression 'isDrv' is always false. Fixes: 3beb6f6e7 ('Show derivations more concisely')
2018-12-12nix repl: don't create result symlinksDaiderd Jordan
2018-11-20repl: give user the choice between libeditline and libreadlineKai Harries
The goal is to support libeditline AND libreadline and let the user decide at compile time which one to use. Add a compile time option to use libreadline instead of libeditline. If compiled against libreadline completion functionality is lost because of a incompatibility between libeditlines and libreadlines completion function. Completion with libreadline is possible and can be added later. To use libreadline instead of libeditline the environment variables 'EDITLINE_LIBS' and 'EDITLINE_CFLAGS' have to been set during the ./configure step. Example: EDITLINE_LIBS="/usr/lib/x86_64-linux-gnu/libhistory.so /usr/lib/x86_64-linux-gnu/libreadline.so" EDITLINE_CFLAGS="-DREADLINE" The reason for this change is that for example on Debian already three different editline libraries exist but none of those is compatible the flavor used by nix. My hope is that with this change it would be easier to port nix to systems that have already libreadline available.
2018-11-20repl: Remove code that was commented outKai Harries
2018-11-13Merge branch 'feature/editline-pr' of https://github.com/dtzWill/nixEelco Dolstra
2018-11-13Restore parent mount namespace before executing a child processEelco Dolstra
This ensures that they can't write to /nix/store. Fixes #2535.
2018-10-29repl: complete if all matches share prefixWill Dietz
2018-10-29editline: wipWill Dietz
2018-09-10auto args on replDing Xiang Fei
2018-08-07repl: don't add trailing spaces to history linesIvan Kozik
2018-06-23repl: use `nix build` for building instead of `nix-store -r`Will Dietz
progress bar!
2018-06-12Move EvalState from the stack to the heapEelco Dolstra
EvalState contains a few counters (e.g. nrValues) that increase quickly enough that they end up being interpreted as pointers by the garbage collector. Moving it to the heap makes them invisible to the garbage collector. This reduces the max RSS doing 100 evaluations of nixos.tests.firefox.x86_64-linux.drvPath from 455 MiB to 292 MiB. Note: ideally, allocations would be much further up in the 64-bit address space to reduce the odds of an integer being misinterpreted as a pointer. Maybe we can use some linker magic to move the .bss segment to a higher address.
2018-04-16nix repl: Fix multiline SIGINT handling.Félix Baylac-Jacqué
Fixes #2076
2018-04-11Fix #2057Eelco Dolstra
2017-12-26nix repl: use linenoiseKeyType to differentiate ^C and ^DWill Dietz
Fixes #1757.
2017-11-27no "linenoiseFree" in linenoise-ngWill Dietz
2017-10-24nix: Respect -I, --arg, --argstrEelco Dolstra
Also, random cleanup to argument handling.
2017-08-09nix repl: Support printing floating-point numbersEelco Dolstra
2017-07-30Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-07-20nix-shell: Use bashInteractive from <nixpkgs>Eelco Dolstra
This adds about 0.1s to nix-shell runtime in the case where bashInteractive already exists. See discussion at https://github.com/NixOS/nixpkgs/issues/27493.
2017-05-10Replace readline by linenoiseEelco Dolstra
Using linenoise avoids a license compatibility issue (#1356), is a lot smaller and doesn't pull in ncurses.
2017-04-28Check for libreadlineEelco Dolstra
2017-04-25nix repl: Fix Ctrl-CEelco Dolstra
2017-04-25Minor cleanupEelco Dolstra
2017-04-25"using namespace std" considered harmfulEelco Dolstra
2017-04-25nix repl: Use $XDG_DATA_HOME for the readline historyEelco Dolstra
2017-04-25Make "nix repl" buildEelco Dolstra
2017-04-25Cleanup in preparation of merging nix-repl repo into nix repoEelco Dolstra