aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
AgeCommit message (Collapse)Author
2014-08-20Use proper quotes everywhereEelco Dolstra
2014-08-20Add some colorEelco Dolstra
2014-08-13Refactor option handlingEelco Dolstra
2014-08-13Fix warning about non-existant -I directoriesEelco Dolstra
2014-07-30Rename nixPath to __nixPathEelco Dolstra
The name ‘nixPath’ breaks existing code.
2014-07-23Remove some obsolete filesEelco Dolstra
2014-07-09Fix compilation error on some versions of GCCEelco Dolstra
src/libexpr/primops.cc:42:8: error: looser throw specifier for 'virtual nix::InvalidPathError::~InvalidPathError()' src/libexpr/nixexpr.hh:12:1: error: overriding 'virtual nix::EvalError::~EvalError() noexcept (true)' http://hydra.nixos.org/build/12385750
2014-07-04Add builtin function ‘fromJSON’Eelco Dolstra
Fixes #294.
2014-06-24Only add the importNative primop if the ↵Shea Levy
allow-arbitrary-code-during-evaluation option is true (default false)
2014-06-17Add importNative primopShea Levy
This can be used to import a dynamic shared object and return an arbitrary value, including new primops. This can be used both to test new primops without having to recompile nix every time, and to build specialized primops that probably don't belong upstream (e.g. a function that calls out to gpg to decrypt a nixops secret as-needed). The imported function should initialize the Value & as needed. A single import can define multiple values by creating an attrset or list, of course. An example initialization function might look like: extern "C" void initialize(nix::EvalState & state, nix::Value & v) { v.type = nix::tPrimOp; v.primOp = NEW nix::PrimOp(myFun, 1, state.symbols.create("myFun")); } Then `builtins.importNative ./example.so "initialize"` will evaluate to the primop defined in the myFun function.
2014-06-12Drop ImportError and FindErrorEelco Dolstra
We're not catching these anywhere.
2014-06-12findFile: Realise the context of the path attributesShea Levy
2014-06-12Share code between scopedImport and importShea Levy
In addition to reducing duplication, this fixes both import from derivation and import of derivation for scopedImport
2014-06-10== operator: Ignore string contextEelco Dolstra
There really is no case I can think of where taking the context into account is useful. Mostly it's just very inconvenient.
2014-05-29Sort nixPath attributesEelco Dolstra
2014-05-26Use std::unordered_setEelco Dolstra
2014-05-26Remove ExprBuiltinEelco Dolstra
It's slower than ExprVar since it doesn't compute a static displacement. Since we're not using the throw primop in the implementation of <...> anymore, it's also not really needed.
2014-05-26Make the Nix search path declarativeEelco Dolstra
Nix search path lookups like <nixpkgs> are now desugared to ‘findFile nixPath <nixpkgs>’, where ‘findFile’ is a new primop. Thus you can override the search path simply by saying let nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ]; in ... <nixpkgs> ... In conjunction with ‘scopedImport’ (commit c273c15cb13bb86420dda1e5341a4e19517532b5), the Nix search path can be propagated across imports, e.g. let overrides = { nixPath = [ ... ] ++ builtins.nixPath; import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; builtins = builtins // overrides; }; in scopedImport overrides ./nixos
2014-05-26Ensure that -I flags get included in nixPathEelco Dolstra
Also fixes #261.
2014-05-26Add constant ‘nixPath’Eelco Dolstra
It contains the Nix expression search path as a list of { prefix, path } sets, e.g. [ { path = "/nix/var/nix/profiles/per-user/root/channels/nixos"; prefix = ""; } { path = "/etc/nixos/configuration.nix"; prefix = "nixos-config"; } { path = "/home/eelco/Dev/nix/inst/share/nix/corepkgs"; prefix = "nix"; } ]
2014-05-26Add primop ‘scopedImport’Eelco Dolstra
‘scopedImport’ works like ‘import’, except that it takes a set of attributes to be added to the lexical scope of the expression, essentially extending or overriding the builtin variables. For instance, the expression scopedImport { x = 1; } ./foo.nix where foo.nix contains ‘x’, will evaluate to 1. This has a few applications: * It allows getting rid of function argument specifications in package expressions. For instance, a package expression like: { stdenv, fetchurl, libfoo }: stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } can now we written as just stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } and imported in all-packages.nix as: bar = scopedImport pkgs ./bar.nix; So whereas we once had dependencies listed in three places (buildInputs, the function, and the call site), they now only need to appear in one place. * It allows overriding builtin functions. For instance, to trace all calls to ‘map’: let overrides = { map = f: xs: builtins.trace "map called!" (map f xs); # Ensure that our override gets propagated by calls to # import/scopedImport. import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; # Also update ‘builtins’. builtins = builtins // overrides; }; in scopedImport overrides ./bla.nix * Similarly, it allows extending the set of builtin functions. For instance, during Nixpkgs/NixOS evaluation, the Nixpkgs library functions could be added to the default scope. There is a downside: calls to scopedImport are not memoized, unlike import. So importing a file multiple times leads to multiple parsings / evaluations. It would be possible to construct the AST only once, but that would require careful handling of variables/environments.
2014-05-26Shut up some signedness warningsEelco Dolstra
2014-05-15Provide a more useful error message when a dynamic attr lookup failsShea Levy
2014-04-08If a .drv cannot be parsed, show its pathEelco Dolstra
Otherwise you just get ‘expected string `Derive(['’ which isn't very helpful.
2014-04-04Show position info in attribute selection errorsEelco Dolstra
2014-04-04Show position info in Boolean operationsEelco Dolstra
2014-04-04Show position info in string concatenation / addition errorsEelco Dolstra
2014-04-04forceString: Show position infoEelco Dolstra
2014-04-04forceAttrs: Show position infoEelco Dolstra
2014-04-04forceList: Show position infoEelco Dolstra
2014-04-04forceInt: Show position infoEelco Dolstra
2014-04-04Pass position information to primop callsEelco Dolstra
For example: error: `tail' called on an empty list, at /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix:13:7
2014-04-04Remove unnecessary quotes around file namesEelco Dolstra
2014-04-04Include position info in function applicationEelco Dolstra
This allows error messages like: error: the anonymous function at `/etc/nixos/configuration.nix:1:1' called without required argument `foo', at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
2014-04-01Fix potential segfaultEelco Dolstra
The newEnv variable was accessed (via the dynamicEnv) pointer after it had gone out of scope. Fixes #234.
2014-03-30boost::shared_ptr -> std::shared_ptrEelco Dolstra
2014-03-29Drop pointless #includeEelco Dolstra
2014-03-10The expr of AttrNames/DynamicAttrDefs is always an ExprConcatStringsShea Levy
2014-03-10If a dynamic attribute name evaluates to null, remove it from the setShea Levy
2014-03-05Revert "Make ifs and asserts tail-recursive"Eelco Dolstra
This reverts commit 273322c7732093a354e86df82cf75d6604b8bce8.
2014-02-27Correctly detect infinite recursion in function applicationEelco Dolstra
If we're evaluating some application ‘v = f x’, we can't store ‘f’ temporarily in ‘v’, because if ‘f x’ refers to ‘v’, it will get ‘f’ rather than an infinite recursion error. Unfortunately, this breaks the tail call optimisation introduced in c897bac54954373f63511702731fe2cb23c0c98e. Fixes #217.
2014-02-26Warn about missing -I pathsEelco Dolstra
Fixes #121. Note that we don't warn about missing $NIX_PATH entries because it's intended that some may be missing (cf. the default $NIX_PATH on NixOS, which includes paths like /etc/nixos/nixpkgs for backward compatibility).
2014-02-18lexer-tab.o and parser-tab.o require each other's headersShea Levy
2014-02-01More "make dist" fixesEelco Dolstra
2014-02-01Fix "make dist"Eelco Dolstra
2014-02-01Remove AutomakefilesEelco Dolstra
2014-02-01Update Makefile variable namesEelco Dolstra
2014-01-30Rename Makefile -> local.mkEelco Dolstra
2014-01-21Fix some clang warningsEelco Dolstra
2014-01-21Fix building against Bison 3.0.2Eelco Dolstra