edolstra / nix-repl Goto Github PK
View Code? Open in Web Editor NEWREPL for Nix
License: GNU General Public License v3.0
REPL for Nix
License: GNU General Public License v3.0
$ NIX_PATH=nixpkgs=http://nixos.org/channels/nixos-16.03/nixexprs.tar.xz nix-shell -p nix-repl --run nix-repl
/run/user/499/nix-shell.ZX0UGk/rc: line 1: 15369 Segmentation fault nix-repl
$ nix-build -A nix-repl '<nixpkgs>'
/nix/store/3f0k61j9kr5l99156m0s8ydx101yymwa-nix-repl-1.11.2-8a2f5f0
$ nix-repl --help
error: unrecognised option ‘--help’
Try ‘nix-repl --help’ for more information.
This is true for nix-repl 1.8 and 1.9.
~ nix-repl
Welcome to Nix version 1.7. Type :? for help.
nix-repl> builtins.readFile ""
error: boost::too_many_args: format-string refered to less arguments than were passed
~
Sometimes I have noticed the need for this. What do you think?
Now that nix-repl supports multiline expressions, I think it's a good time to add support for comments as well. So that when you copy multiline expressions that have comments, it doesn't message up the interpretation. It should be just like nix in files. With # ... \n|$
identified as a comment.
While let x-y = "blah"; in 1
works. Running x-y = "blah"
results in:
error: syntax error, unexpected '=', expecting $end, at (string):1:5
When using nix-repl
built against nix
commit 6519f06f397448c3f1677e87e385012e2507164b
:
$ nix-repl '<nixpkgs>'
nix-repl: src/libexpr/eval.cc:266: nix::EvalState::EvalState(const Strings&): Assertion `gcInitialised' failed.
Aborted (core dumped)
To reproduce...
nix-repl> builtins.toPath "a"
error: boost::too_many_args: format-string refered to less arguments than were passed
Exits to shell. Seems like a harsh penalty :-)
I have nix 1.8pre3679_f609eec, but https://github.com/edolstra/nix-repl/blob/master/nix-repl.cc#L86 expects NIX_VERSION to be a valid literal.
simple like that (nix-repl-1.7-1734e8a
)
nix-repl> { type = "derivation"; drvPath = "crash me please"; }
error: boost::too_many_args: format-string refered to less arguments than were passed
«derivation
A man page describing what the program is all about, how it works and how to work with it would be nice to have.
The show-trace option is accepted, but it doesn't seem to do anything, at least there's no trace displayed.
Simple example:
$ nix-build --eval --expr "let a = z: 7 ++ 7; in a 0" --show-trace
error: while evaluating ‘a’ at (string):1:9, called from (string):1:23:
value is an integer while a list was expected, at (string):1:12
whereas
$ nix-repl --show-trace
nix-repl> let a = z: 7 ++ 7; in a 0
error: value is an integer while a list was expected, at (string):1:12
(the while evaluating ...
is missing)
See the trace below.
[maarten@maarten-laptop:~/nixpkgs]$ nix-repl
Welcome to Nix version 1.11.2. Type :? for help.
nix-repl> builtins.tail (({ __functor = self: arg: [(self.x) arg]; x=1; }) "a")
[ "a" ]
nix-repl> builtins.head (({ __functor = self: arg: [(self.x) arg]; x=1; }) "a")
1
nix-repl> ({ __functor = self: arg: [(self.x) arg]; x=1; }) "a"
[ Aborted
Writing `foo.‹tab›' makes the program exit due to unhandled error.
Solution:
// Quietly ignore parse errors.
}catch (EvalError & e) {
// Quietly ignore evaluation errors.
+ }catch (UndefinedVarError & e) {
+ // Quietly ignore undefined variable errors.
}
}
}
How to reproduce:
$ nix-env -iA nixpkgs.nix-repl
replacing old ‘nix-repl-1.8-f924081’
installing ‘nix-repl-1.10-8a2f5f0’
$ NIX_PATH="nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz" nix-repl
Segmentation fault
Welcome to Nix version 1.11.6. Type :? for help.
nix-repl> :l <nixpkgs>
Added 6646 variables.
nix-repl> mendeley.name
error: Package ‘mendeley-1.16.3-stable_amd64’ in ‘/nix/store/lwmgp564z0bl06svlnw21gg3qy8kw3vb-nixos-16.09.1512.6b28bd0/nixos/pkgs/applications/office/mendeley/default.nix:62’ has an unfree license (‘unfree’), refusing to evaluate.
a) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.
b) For `nix-env`, `nix-build` or any other Nix command you can add
{ allowUnfree = true; }
to ~/.nixpkgs/config.nix.
I feel that turning nixpkgs.config.allowUnfree
to true
just to see the name of the package is a bit much to ask. But of course, this might not be easy to fix...
I stumbled upon this issue while trying to use nix-repl to tweak my allowUnfreePredicate
. Needless to say I did not get very far.
The current REPL doesn't seem to support expressions over multiple lines. This would make it easier to test how Nix understands an expression that has newlines in between certain areas.
Im getting the following error after following the install instructions.
~/c/nix-repl git:master ❯❯❯ nix-repl
nix-repl: src/libexpr/eval.cc:266: nix::EvalState::EvalState(const Strings&): Assertion `gcInitialised' failed.
[1] 23753 abort nix-repl
Something has changed which it appears from a conversation in #nixos would imply that we actually want to load <nixpkgs/nixos>
instead in 16.09 to get the config set and related fields.
# nix-repl
Welcome to Nix version 1.11.4. Type :? for help.
nix-repl> :l <nixos>
Added 6637 variables.
nix-repl> :l <nixpkgs>
Added 6637 variables.
Something that clears the screen.
Also I noticed that all the builtins are available as __getEnv
instead of builtins.getEnv
. Which one should I be using?
Curious to the new floating-point support I found out that nix-repl
fails to build against nixUnstable
with NixOS/nixpkgs@7215118
$ nix-shell -p 'nix-repl.override{nix=nixUnstable;}' -I nixpkgs=.
these derivations will be built:
/nix/store/4qgb5zg3yrwa90i2fly58167bgs69qgj-nix-repl-1.12pre4911_b30d1e7-2016-02-28.drv
building path(s) ‘/nix/store/5cvngz9clyqb906pp96w4h7q2plpy7ds-nix-repl-1.12pre4911_b30d1e7-2016-02-28’
unpacking sources
unpacking source archive /nix/store/q8h2ng6wzgxsqrsczyam6szms15icg8k-nix-repl-a1ea85e92b067a0a42354a28355c633eac7be65c-src
source root is nix-repl-a1ea85e92b067a0a42354a28355c633eac7be65c-src
patching sources
configuring
no configure script, doing nothing
installing
nix-repl.cc: In constructor 'NixRepl::NixRepl(const Strings&)':
nix-repl.cc:78:44: error: no matching function for call to 'nix::EvalState::EvalState(const Strings&)'
, staticEnv(false, &state.staticBaseEnv)
^
In file included from nix-repl.cc:10:0:
/nix/store/nx8gzz0aqk755ixmijzw8q1i0aql6qfm-nix-1.12pre4911_b30d1e7-dev/include/nix/eval.hh:103:5: note: candidate: nix::EvalState::EvalState(const Strings&, nix::ref<nix::Store>)
EvalState(const Strings & _searchPath, ref<Store> store);
^
/nix/store/nx8gzz0aqk755ixmijzw8q1i0aql6qfm-nix-1.12pre4911_b30d1e7-dev/include/nix/eval.hh:103:5: note: candidate expects 2 arguments, 1 provided
/nix/store/nx8gzz0aqk755ixmijzw8q1i0aql6qfm-nix-1.12pre4911_b30d1e7-dev/include/nix/eval.hh:63:7: note: candidate: nix::EvalState::EvalState(const nix::EvalState&)
class EvalState
^
/nix/store/nx8gzz0aqk755ixmijzw8q1i0aql6qfm-nix-1.12pre4911_b30d1e7-dev/include/nix/eval.hh:63:7: note: no known conversion for argument 1 from 'const Strings {aka const std::__cxx11::list<std::__cxx11::basic_string<char> >}' to 'const nix::EvalState&'
nix-repl.cc: In member function 'bool NixRepl::processLine(std::__cxx11::string)':
nix-repl.cc:337:31: error: 'store' was not declared in this scope
if (drvPath == "" || !store->isValidPath(drvPath))
^
nix-repl.cc: In lambda function:
nix-repl.cc:648:9: error: 'store' was not declared in this scope
store = openStore();
^
builder for ‘/nix/store/4qgb5zg3yrwa90i2fly58167bgs69qgj-nix-repl-1.12pre4911_b30d1e7-2016-02-28.drv’ failed with exit code 1
error: build of ‘/nix/store/4qgb5zg3yrwa90i2fly58167bgs69qgj-nix-repl-1.12pre4911_b30d1e7-2016-02-28.drv’ failed
/run/current-system/sw/bin/nix-shell: failed to build all dependencies
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.