about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
AgeCommit message (Collapse)AuthorFilesLines
2013-12-10 Bump language version for new storePath featureShea Levy1-1/+1
This will allow e.g. channel expressions to use builtins.storePath IFF it is safe to do so without knowing if the path is valid yet. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-10 builtins.storePath: Try to substitute the path if it is not yet validShea Levy1-2/+2
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-19 Shorter error messageEelco Dolstra1-2/+1
2013-11-19 Add a toJSON primopEelco Dolstra1-0/+14
2013-11-18 Add a primop unsafeGetAttrPos to return the position of an attributeEelco Dolstra1-1/+15
2013-10-28 Fix building without a garbage collectorEelco Dolstra1-5/+5
http://hydra.nixos.org/build/6695350
2013-10-28 Fix a segfault in genericClosureEelco Dolstra1-16/+25
It kept temporary data in STL containers that were not scanned by Boehm GC, so Nix programs using genericClosure could randomly crash if the garbage collector kicked in at a bad time. Also make it a bit more efficient by copying points to values rather than values.
2013-10-28 Slightly optimize listToAttrsEelco Dolstra1-8/+8
2013-10-24 Rename "attribute sets" to "sets"Eelco Dolstra1-15/+15
We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose.
2013-10-24 Add a typeOf primopEelco Dolstra1-3/+28
We already have some primops for determining the type of a value, such as isString, but they're incomplete: for instance, there is no isPath. Rather than adding more isBla functions, the generic typeOf function returns a string representing the type of the argument (e.g. "int").
2013-10-17 Fold two stack trace messages in derivationsEelco Dolstra1-4/+2
Combined with the previous changes, stack traces involving derivations are now much less verbose, since something like while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': while instantiating the derivation named `gtk+-2.24.20' at `/home/eelco/Dev/nixpkgs/pkgs/development/libraries/gtk+/2.x.nix:11:3': while evaluating the derivation attribute `propagatedNativeBuildInputs' at `/home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/default.nix:78:17': while evaluating the attribute `outPath' at `/nix/store/212ngf4ph63mp6p1np2bapkfikpakfv7-nix-1.6/share/nix/corepkgs/derivation.nix:18:9': ... now reads while evaluating the attribute `propagatedNativeBuildInputs' of the derivation `gtk+-2.24.20' at `/home/eelco/Dev/nixpkgs/pkgs/development/libraries/gtk+/2.x.nix:11:3': ...
2013-10-17 Don't show <nix/derivation.nix> in stack tracesEelco Dolstra1-1/+3
Messages like while evaluating the attribute `outPath' at `/nix/store/212ngf4ph63mp6p1np2bapkfikpakfv7-nix-1.6/share/nix/corepkgs/derivation.nix:18:9': are redundant, because Nix already shows that it's evaluating a derivation: while instantiating the derivation named `firefox-24.0' at `/home/eelco/Dev/nixpkgs/pkgs/applications/networking/browsers/firefox/default.nix:131:5': while evaluating the derivation attribute `nativeBuildInputs' at `/home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/default.nix:76:17':
2013-09-03 Get rid of the parse tree cacheEelco Dolstra1-3/+2
Since we already cache files in normal form (fileEvalCache), caching parse trees is redundant. Note that getting rid of this cache doesn't actually save much memory at the moment, because parse trees are currently not freed / GC'ed.
2013-09-02 Fix whitespaceEelco Dolstra1-15/+15
2013-08-19 Store Nix integers as longsEelco Dolstra1-1/+1
So on 64-bit systems, integers are now 64-bit. Fixes #158.
2013-08-02 Let the ordering operators also work on stringsEelco Dolstra1-3/+6
E.g. ‘"foo" < "bar"’ now works.
2013-03-08 Revert "Prevent config.h from being clobbered"Eelco Dolstra1-0/+16
This reverts commit 28bba8c44f484eae38e8a15dcec73cfa999156f6.
2013-03-07 Prevent config.h from being clobberedEelco Dolstra1-16/+0
2013-02-08 Rename "hash" to "hashString" and handle SHA-1Eelco Dolstra1-19/+9
2013-02-08 experimental/hashMarc Weber1-0/+26
adding primop function calculating hash of a string Signed-off-by: Marc Weber <marco-oweber@gmx.de>
2012-12-04 Tiny optimisation in the filter primopEelco Dolstra1-2/+9
2012-11-27 Optionally ignore null-valued derivation attributesEelco Dolstra1-10/+22
This allows adding attributes like attr = if stdenv.system == "bla" then something else null; without changing the resulting derivation on non-<bla> platforms. We once considered adding a special "ignore" value for this purpose, but using null seems more elegant.
2012-11-27 Add builtin constants ‘langVersion’ and ‘nixVersion’Eelco Dolstra1-0/+10
The integer constant ‘langVersion’ denotes the current language version. It gets increased every time a language feature is added/changed/removed. It's currently 1. The string constant ‘nixVersion’ contains the current Nix version, e.g. "1.2pre2980_9de6bc5".
2012-11-15 Revert "prim_toPath: Actually make the string a path"Eelco Dolstra1-3/+1
This reverts commit 2980d1fba97069805c3649c5d99d0356bce6c303. It causes a regression in NixOS evaluation: string `/nix/store/ya3s5gmj3b28170fpbjhgsk8wzymkpa1-pommed-1.39/etc/pommed.conf' cannot refer to other paths
2012-10-23 prim_toPath: Actually make the string a pathShea Levy1-1/+3
2012-10-03 Add a ‘--repair’ flag to nix-instantiateEelco Dolstra1-3/+3
This allows repairing corrupted derivations and other source files.
2012-09-19 Templatise tokenizeString()Eelco Dolstra1-1/+1
2012-08-27 Merge branch 'master' into no-manifestsEelco Dolstra1-8/+73
2012-08-13 Add a primop ‘elemAt’ to get an element from a listEelco Dolstra1-5/+19
2012-08-13 Add a primop ‘concatLists’Eelco Dolstra1-0/+10
This can serve as a generic efficient list builder. For instance, the function ‘catAttrs’ in Nixpkgs can be rewritten from attr: l: fold (s: l: if hasAttr attr s then [(getAttr attr s)] ++ l else l) [] l to attr: l: builtins.concatLists (map (s: if hasAttr attr s then [(getAttr attr s)] else []) l) Statistics before: time elapsed: 1.08683 size of a value: 24 environments allocated: 1384376 (35809568 bytes) list elements: 6946783 (55574264 bytes) list concatenations: 37434 values allocated: 1760440 (42250560 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18273 number of thunks: 1297673 number of thunks avoided: 1380759 number of attr lookups: 430802 number of primop calls: 628912 number of function calls: 1333544 Statistics after (including new catAttrs): time elapsed: 0.959854 size of a value: 24 environments allocated: 1010198 (26829296 bytes) list elements: 1984878 (15879024 bytes) list concatenations: 30488 values allocated: 1589760 (38154240 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18274 number of thunks: 1040925 number of thunks avoided: 1038428 number of attr lookups: 438419 number of primop calls: 474844 number of function calls: 959366
2012-08-13 Provide an efficient implementation of ‘elem’Eelco Dolstra1-2/+17
The one in Nixpkgs is O(n^2), this one is O(n). Big reduction in the number of list allocations. Statistics before (on a NixOS system config): time elapsed: 1.17982 size of a value: 24 environments allocated: 1543334 (39624560 bytes) list elements: 9612638 (76901104 bytes) list concatenations: 37434 values allocated: 1854933 (44518392 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18272 number of thunks: 1392467 number of thunks avoided: 1507311 number of attr lookups: 430801 number of primop calls: 691600 number of function calls: 1492502 Statistics after: time elapsed: 1.08683 size of a value: 24 environments allocated: 1384376 (35809568 bytes) list elements: 6946783 (55574264 bytes) list concatenations: 37434 values allocated: 1760440 (42250560 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18273 number of thunks: 1297673 number of thunks avoided: 1380759 number of attr lookups: 430802 number of primop calls: 628912 number of function calls: 1333544
2012-08-13 Add a "filter" primopEelco Dolstra1-0/+25
Evaluation of a NixOS configuration spends quite a lot of time in the "filter" function in Nixpkgs. As implemented in Nixpkgs, this is a O(n^2) operation, so it's a good candidate for providing a more efficient (i.e. primop) implementation. Using it gives a ~10% speed increase and a significant reduction in the number of evaluations. Statistics before (on a NixOS system config): time elapsed: 1.3258 size of a value: 24 environments allocated: 1980939 (50127080 bytes) list elements: 14679308 (117434464 bytes) list concatenations: 50828 values allocated: 2098938 (50374512 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18271 number of thunks: 1645752 number of thunks avoided: 1921196 number of attr lookups: 430798 number of primop calls: 838807 number of function calls: 1930107 Statistics after: time elapsed: 1.17982 size of a value: 24 environments allocated: 1543334 (39624560 bytes) list elements: 9612638 (76901104 bytes) list concatenations: 37434 values allocated: 1854933 (44518392 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18272 number of thunks: 1392467 number of thunks avoided: 1507311 number of attr lookups: 430801 number of primop calls: 691600 number of function calls: 1492502
2012-08-12 Add some basic profiling support to the evaluatorEelco Dolstra1-1/+2
Setting the environment variable NIX_COUNT_CALLS to 1 enables some basic profiling in the evaluator. It will count calls to functions and primops as well as evaluations of attributes. For example, to see where evaluation of a NixOS configuration spends its time: $ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 ./src/nix-instantiate/nix-instantiate '<nixos>' -A system --readonly-mode ... calls to 39 primops: 239532 head 233962 tail 191252 hasAttr ... calls to 1595 functions: 224157 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:19' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:14' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:10' ... evaluations of 7088 attributes: 167377 undefined position 132459 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:119:41' 47322 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:13:21' ...
2012-07-30 Refactor settings processingEelco Dolstra1-3/+3
Put all Nix configuration flags in a Settings object.
2012-07-26 Merge branch 'master' into no-manifestsEelco Dolstra1-1/+25
2012-07-25 prim_import: When importing .drvs, allocate the intermediate attrset on the ↵Shea Levy1-1/+1
heap just in case it escapes the stack frame.
2012-07-25 import: If the path is a valid .drv file, parse it and generate a derivation ↵Shea Levy1-1/+25
attrset. The generated attrset has drvPath and outPath with the right string context, type 'derivation', outputName with the right name, all with a list of outputs, and an attribute for each output. I see three uses for this (though certainly there may be more): * Using derivations generated by something besides nix-instantiate (e.g. guix) * Allowing packages provided by channels to be used in nix expressions. If a channel installed a valid deriver for each package it provides into the store, then those could be imported and used as dependencies or installed in environment.systemPackages, for example. * Enable hydra to be consistent in how it treats inputs that are outputs of another build. Right now, if an input is passed as an argument to the job, it is passed as a derivation, but if it is accessed via NIX_PATH (i.e. through the <> syntax), then it is a path that can be imported. This is problematic because the build being depended upon may have been built with non-obvious arguments passed to its jobset file. With this feature, hydra can just set the name of that input to the path to its drv file in NIX_PATH
2012-07-18 Merge branch 'master' into no-manifestsEelco Dolstra1-1/+5
2012-07-12 builtins.storePath: resolve symlinksEelco Dolstra1-1/+5
Needed for Charon/Hydra interaction.
2012-07-09 prim_import(): prefetch substitute info in parallel using queryMissing()Eelco Dolstra1-0/+6
2012-06-27 nix-store -r: do substitutions in parallelEelco Dolstra1-1/+1
I.e. when multiple non-derivation arguments are passed to ‘nix-store -r’ to be substituted, do them in parallel.
2012-02-04 * Inline some functions and get rid of the indirection throughEelco Dolstra1-0/+1
EvalState::eval(). This gives a 12% speedup on ‘nix-instantiate /etc/nixos/nixos/ -A system --readonly-mode’ (from 1.01s to 0.89s).
2012-01-26 * Fix importing a derivation. This gave a segfault.Eelco Dolstra1-8/+23
2012-01-19 * Add some debug output to print the derivation name once it's known.Eelco Dolstra1-1/+4
This makes it easier to pinpoint the source of a crash.
2012-01-03 * Drop the inefficient "Path" suffix in output attribute names.Eelco Dolstra1-3/+1
2012-01-03 * Move the implementation of the ‘derivation’ primop into a separateEelco Dolstra1-23/+1
file.
2011-12-21 * The ‘foo.drvPath’ feature was already broken in read-only mode.Eelco Dolstra1-1/+2
Since it's rarely used and fixing it is too much work right now, just document it.
2011-12-21 * Simplify the context handling logic.Eelco Dolstra1-24/+13
2011-12-16 * Sync with the trunk.Eelco Dolstra1-14/+3
2011-12-02 * Move parseHash16or32 into libutil, and use in nix-hash.Eelco Dolstra1-11/+1