about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
AgeCommit message (Collapse)AuthorFilesLines
2015-07-23 Add primops all and anyEelco Dolstra1-0/+33
These are used thousands of times during NixOS evaluation, so it's useful to speed them up.
2015-07-23 Importing derivations: Add name attribute to make a valid drvShea Levy1-1/+3
2015-07-23 Allow derivations-as-srcs in the context of builtins.toFile filesShea Levy1-2/+6
2015-07-23 Add foldl' primopEelco Dolstra1-0/+24
2015-07-17 OCD: foreach -> C++11 ranged forEelco Dolstra1-50/+45
2015-06-01 Fix fetchurl/fetchTarballEelco Dolstra1-1/+2
2015-06-01 readFile: Check against nul bytesEelco Dolstra1-1/+4
2015-05-05 Allow URLs in the Nix search pathEelco Dolstra1-85/+3
E.g. to install "hello" from the latest Nixpkgs: $ nix-build '<nixpkgs>' -A hello -I nixpkgs=https://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz Or to install a specific version of NixOS: $ nixos-rebuild switch -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/63def04891a0abc328b1b0b3a78ec02c58f48583.tar.gz
2015-04-09 Use cached result if there is a network errorEelco Dolstra1-7/+12
2015-04-09 Move curl stuff into a separate fileEelco Dolstra1-112/+6
2015-04-09 Implement a TTL on cached fetchurl/fetchTarball resultsEelco Dolstra1-13/+24
This is because we don't want to do HTTP requests on every evaluation, even though we can prevent a full redownload via the cached ETag. The default is one hour.
2015-04-09 Implement caching of fetchurl/fetchTarball resultsEelco Dolstra1-14/+119
ETags are used to prevent redownloading unchanged files.
2015-03-25 Add fetchTarball builtinEelco Dolstra1-0/+119
This function downloads and unpacks the given URL at evaluation time. This is primarily intended to make it easier to deal with Nix expressions that have external dependencies. For instance, to fetch Nixpkgs 14.12: with import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-14.12.tar.gz) {}; Or to fetch a specific revision: with import (fetchTarball https://github.com/NixOS/nixpkgs/archive/2766a4b44ee6eafae03a042801270c7f6b8ed32a.tar.gz) {}; This patch also adds a ‘fetchurl’ builtin that downloads but doesn't unpack its argument. Not sure if it's useful though.
2015-03-25 addToStore(): Take explicit name argumentEelco Dolstra1-1/+1
2015-03-24 Don't rely on __noChroot for corepkgsEelco Dolstra1-2/+5
This doesn't work anymore if the "strict" chroot mode is enabled. Instead, add Nix's store path as a dependency. This ensures that its closure is present in the chroot.
2015-03-06 Fix typos: s/the the/the/Daniel Hahler1-1/+1
2015-02-23 Add restricted evaluation modeEelco Dolstra1-7/+21
If ‘--option restrict-eval true’ is given, the evaluator will throw an exception if an attempt is made to access any file outside of the Nix search path. This is primarily intended for Hydra, where we don't want people doing ‘builtins.readFile ~/.ssh/id_dsa’ or stuff like that.
2015-02-05 Remove tabEelco Dolstra1-1/+1
2015-01-29 Merge remote-tracking branch 'shlevy/baseNameOf-no-copy'Shea Levy1-1/+1
baseNameOf: Don't copy paths to the store first
2015-01-09 Fix builtins.readDir on XFSEelco Dolstra1-1/+1
The DT_UNKNOWN fallback code was getting the type of the wrong path, causing readDir to report "directory" as the type of every file. Reported by deepfire on IRC.
2015-01-07 Show position info for failing <...> lookupsEelco Dolstra1-1/+1
2014-12-12 Remove canary stuffEelco Dolstra1-27/+0
2014-12-10 builtins.readFile: realise context associated with the pathShea Levy1-2/+6
2014-12-02 Allow external code using libnixexpr to add typesShea Levy1-0/+3
Code that links to libnixexpr (e.g. plugins loaded with importNative, or nix-exec) may want to provide custom value types and operations on values of those types. For example, nix-exec is currently using sets where a custom IO value type would be more appropriate. This commit provides a generic hook for such types in the form of tExternal and the ExternalBase virtual class, which contains all functions necessary for libnixexpr's type-polymorphic functions (e.g. `showType`) to be implemented.
2014-11-25 Add a primop for regular expression pattern matchingEelco Dolstra1-1/+29
The function ‘builtins.match’ takes a POSIX extended regular expression and an arbitrary string. It returns ‘null’ if the string does not match the regular expression. Otherwise, it returns a list containing substring matches corresponding to parenthesis groups in the regex. The regex must match the entire string (i.e. there is an implied "^<pat>$" around the regex). For example: match "foo" "foobar" => null match "foo" "foo" => [] match "f(o+)(.*)" "foooobar" => ["oooo" "bar"] match "(.*/)?([^/]*)" "/dir/file.nix" => ["/dir/" "file.nix"] match "(.*/)?([^/]*)" "file.nix" => [null "file.nix"] The following example finds all regular files with extension .nix or .patch underneath the current directory: let findFiles = pat: dir: concatLists (mapAttrsToList (name: type: if type == "directory" then findFiles pat (dir + "/" + name) else if type == "regular" && match pat name != null then [(dir + "/" + name)] else []) (readDir dir)); in findFiles ".*\\.(nix|patch)" (toString ./.)
2014-11-25 forceString(): Accept pos argumentEelco Dolstra1-2/+2
2014-11-20 import derivation: cleanupShea Levy1-8/+11
Before this there was a bug where a `find` was being called on a not-yet-sorted set. The code was just a mess before anyway, so I cleaned it up while fixing it.
2014-11-15 realiseContext: Handle all context typesShea Levy1-2/+2
Avoids an assertion
2014-10-18 baseNameOf: Don't copy paths to the store firstShea Levy1-1/+1
2014-10-17 Export realiseContext in libnixexprShea Levy1-9/+3
Useful for importNative plugins
2014-10-04 Add primop ‘catAttrs’Eelco Dolstra1-0/+30
2014-10-04 Add primop ‘attrValues’Eelco Dolstra1-1/+23
2014-10-04 TweakEelco Dolstra1-1/+1
2014-10-03 Remove some duplicate codeEelco Dolstra1-15/+8
2014-10-03 Add readDir primopShea Levy1-0/+37
2014-09-23 Add missing staticEelco Dolstra1-2/+2
2014-09-22 Don't evaluate inside a "throw"Eelco Dolstra1-3/+4
Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41174. This caused hydra-eval-jobs to ignore SIGINT.
2014-09-22 Add ‘deepSeq’ primopEelco Dolstra1-0/+11
Note that unlike ‘lib.deepSeq’ in Nixpkgs, this handles cycles.
2014-09-22 Add ‘seq’ primopEelco Dolstra1-0/+12
2014-09-22 Add a function ‘valueSize’Eelco Dolstra1-0/+10
It returns the size of value, including all other values and environments reachable from it. It is intended for debugging memory consumption issues.
2014-09-19 attrNames: Don't allocate duplicates of the symbolsEelco Dolstra1-6/+4
2014-09-19 Fix off-by-oneEelco Dolstra1-1/+1
2014-09-17 Add some instrumentation for debugging GC leaksEelco Dolstra1-0/+27
2014-08-20 Use proper quotes everywhereEelco Dolstra1-40/+40
2014-07-30 Rename nixPath to __nixPathEelco Dolstra1-2/+2
The name ‘nixPath’ breaks existing code.
2014-07-09 Fix compilation error on some versions of GCCEelco Dolstra1-0/+1
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-04 Add builtin function ‘fromJSON’Eelco Dolstra1-0/+10
Fixes #294.
2014-06-24 Only add the importNative primop if the ↵Shea Levy1-1/+2
allow-arbitrary-code-during-evaluation option is true (default false)
2014-06-17 Add importNative primopShea Levy1-0/+42
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-12 Drop ImportError and FindErrorEelco Dolstra1-4/+0
We're not catching these anywhere.