Eelco Dolstra
17ef3e6f41
Enable more fromTOML tests
...
cpptoml now parses almost all examples from the spec.
2019-05-29 12:22:52 +02:00
Eelco Dolstra
cfd74aef1e
Fix eval-okay-fromTOML test
...
Turns out we were mis-parsing single-quoted attributes, e.g. 'key2'.
2019-05-29 12:12:02 +02:00
Eelco Dolstra
9eaebbf575
Merge branch 'attrPaths' of https://github.com/NinjaTrappeur/nix
2019-05-28 22:59:05 +02:00
Will Dietz
a834861876
fix hashfile test that wasn't failing due to eval laziness
...
See:
7becb1bf1c (r33450554)
2019-05-08 10:04:54 +02:00
Daniel Schaefer
3f192ac80c
Add builtins.hashFile
...
For text files it is possible to do it like so:
`builtins.hashString "sha256" (builtins.readFile /tmp/a)`
but that doesn't work for binary files.
With builtins.hashFile any kind of file can be conveniently hashed.
2019-05-03 17:23:36 +02:00
Eelco Dolstra
e489f5cabf
Update eval-okay-types.exp to match #1828
2019-03-27 21:07:04 +01:00
514b3c7f83
Add isPath primop
...
this is added for completeness' sake since all the other possible
`builtins.typeOf` results have a corresponding `builtins.is<Type>`
2019-03-24 11:36:49 +01:00
Shea Levy
b30be6b450
Add builtins.appendContext.
...
A partner of builtins.getContext, useful for the same reasons.
2019-01-31 08:52:23 -05:00
Shea Levy
1d757292d0
Add builtins.getContext.
...
This can be very helpful when debugging, as well as enabling complex
black magic like surgically removing a single dependency from a
string's context.
2019-01-14 11:27:10 -05:00
Eelco Dolstra
9b1bdf2db8
FIx floating point evaluation
...
Fixes #2361 .
2018-08-19 11:59:49 +02:00
volth
403a76a18f
lib.concatMap and lib.mapAttrs to be builtins
2018-07-05 02:54:09 +00:00
Eelco Dolstra
3b1f54cf06
Add a fromTOML primop
...
This is primarily useful for processing Cargo.lock files.
2018-07-03 18:39:36 +02:00
volth
88c1ea30e4
add docs and tests
2018-05-24 12:51:34 +00:00
Eelco Dolstra
1ad19232c4
Don't return negative numbers from the flex tokenizer
...
Fixes #1374 .
Closes #2129 .
2018-05-11 12:05:12 +02:00
Eelco Dolstra
548ad391d9
Fix builtins.add test
...
Nix prints the floating point number 4.0 as "4".
2018-05-02 13:49:32 +02:00
Félix Baylac-Jacqué
b2f3a7411a
nix-lang: Add deep nested mixed attrs test case.
2018-05-01 14:42:34 +02:00
Tim Sears
9a714f75af
add tests for builtins.add
2018-04-29 12:03:42 -07:00
Shea Levy
e2b028353b
Merge branch 'pos-crash-fix' of git://github.com/dezgeg/nix
2018-04-23 08:43:54 -04:00
Shea Levy
0aae411eaa
Merge branch 'add-test-eval-okay-nested-with' of git://github.com/ryantrinkle/nix
2018-04-23 08:43:14 -04:00
Félix Baylac-Jacqué
00584bb091
parser: Allow mixed nested and top-level attrpaths
...
Fixes #2077 .
2018-04-18 18:44:38 +02:00
Félix Baylac-Jacqué
10d33452e2
nix-lang parser: Add mixed nested attrs tests.
...
Part of issue #2077
2018-04-17 09:13:01 +02:00
Doug Beardsley
72902ec399
Add missing eval-okay-regex-split.exp test file
2018-04-06 12:18:59 -06:00
Tuomas Tynkkynen
af86132e1a
libexpr: Make unsafeGetAttrPos not crash on noPos
...
Currently e.g. `builtins.unsafeGetAttrPos "abort" builtins` will
eventually segfault because pos->file is an unset Symbol.
Found by afl-fuzz.
2018-04-03 15:54:42 +03:00
Ryan Trinkle
f2273b11f5
Add test eval-okay-nested-with
2018-03-30 15:41:16 -04:00
Tuomas Tynkkynen
a0e38c16bc
libexpr: Recognize newline in more places in lexer
...
Flex's regexes have an annoying feature: the dot matches everything
except a newline. This causes problems for expressions like:
"${0}\
"
where the backslash-newline combination matches this rule instead of the
intended one mentioned in the comment:
<STRING>\$|\\|\$\\ {
/* This can only occur when we reach EOF, otherwise the above
(...|\$[^\{\"\\]|\\.|\$\\.)+ would have triggered.
This is technically invalid, but we leave the problem to the
parser who fails with exact location. */
return STR;
}
However, the parser actually accepts the resulting token sequence
('"' DOLLAR_CURLY 0 '}' STR '"'), which is a problem because the lexer
rule didn't assign anything to yylval. Ultimately this leads to a crash
when dereferencing a NULL pointer in ExprConcatStrings::bindVars().
The fix does change the syntax of the language in some corner cases
but I think it's only turning previously invalid (or crashing) syntax
to valid syntax. E.g.
"a\
b"
and
''a''\
b''
were previously syntax errors but now both result in "a\nb".
Found by afl-fuzz.
2018-03-02 17:30:48 +02:00
Tuomas Tynkkynen
77e9e1ed91
libexpr: Fix prim_replaceStrings() to work on an empty source string
...
Otherwise, running e.g.
nix-instantiate --eval -E --strict 'builtins.replaceStrings [""] ["X"] "abc"'
would just hang in an infinite loop.
Found by afl-fuzz.
First attempt of this was reverted in e2d71bd186
because it caused
another infinite loop, which is fixed now and a test added.
2018-02-26 19:49:13 +02:00
Eelco Dolstra
e2d71bd186
Revert "libexpr: Fix prim_replaceStrings() to work on an empty source string"
...
This reverts commit 4ea9707591
.
It causes an infinite loop in Nixpkgs evaluation,
e.g. "nix-instantiate -A hello" hung.
PR #1886 .
2018-02-21 15:35:28 +01:00
Tuomas Tynkkynen
4ea9707591
libexpr: Fix prim_replaceStrings() to work on an empty source string
...
Otherwise, running e.g.
nix-instantiate --eval -E --strict 'builtins.replaceStrings [""] ["X"] "abc"'
would just hang in an infinite loop.
Found by afl-fuzz.
2018-02-19 23:20:26 +02:00
Shea Levy
b095c06139
Add splitVersion primop.
...
Fixes #1868 .
2018-02-14 09:55:43 -05:00
Shea Levy
48c192ca2d
builtins.path test: Don't rely on shlevy's XDG_RUNTIME_DIR
2018-02-07 10:26:53 -05:00
Shea Levy
69d82e5c58
Add path primop.
...
builtins.path allows specifying the name of a path (which makes paths
with store-illegal names now addable), allows adding paths with flat
instead of recursive hashes, allows specifying a filter (so is a
generalization of filterSource), and allows specifying an expected
hash (enabling safe path adding in pure mode).
2018-02-06 16:48:08 -05:00
Eelco Dolstra
2c39e4eca0
Revert "Don't parse "x:x" as a URI"
...
This reverts commit f90f660b24
.
This broke Hydra's release.nix, which contained
preCheck = ''export LOGNAME=${LOGNAME:-foo}'';
2017-11-14 15:10:52 +01:00
Eelco Dolstra
f90f660b24
Don't parse "x:x" as a URI
...
URIs now have to contain "://" or start with "channel:".
2017-10-30 17:58:01 +01:00
Nicolas B. Pierron
b8867a0239
Add builtins.string function.
...
The function 'builtins.split' takes a POSIX extended regular expression
and an arbitrary string. It returns a list of non-matching substring
interleaved by lists of matched groups of the regular expression.
```nix
with builtins;
assert split "(a)b" "abc" == [ "" [ "a" ] "c" ];
assert split "([ac])" "abc" == [ "" [ "a" ] "b" [ "c" ] "" ];
assert split "(a)|(c)" "abc" == [ "" [ "a" null ] "b" [ null "c" ] "" ];
assert split "([[:upper:]]+)" " FOO "
== [ " " [ "FOO" ] " " ];
```
2017-08-15 20:04:11 +00:00
Graham Christensen
364f75e03a
Update mailing list.
2017-07-18 08:04:01 -04:00
Eelco Dolstra
f134fc4cbe
Document that builtins.match takes a POSIX extended RE
2017-05-17 12:18:18 +02:00
Guillaume Maudoux
a474425425
Fix lexer to support $'
in multiline strings.
2017-05-01 01:15:40 +02:00
Guillaume Maudoux
e4b82af387
Improve error message on trailing path slashes
2016-11-27 17:48:46 +01:00
Guillaume Maudoux
a5e761dddb
Fix comments parsing
...
Fixed the parsing of multiline strings ending with an even number of
stars, like /** this **/.
Added test cases for comments.
2016-11-13 17:20:34 +01:00
Eelco Dolstra
26d92017d3
Add builtin function "partition"
...
The implementation of "partition" in Nixpkgs is O(n^2) (because of the
use of ++), and for some reason was causing stack overflows in
multi-threaded evaluation (not sure why).
This reduces "nix-env -qa --drv-path" runtime by 0.197s and memory
usage by 298 MiB (in non-Boehm mode).
2016-08-29 19:36:54 +02:00
Eelco Dolstra
e03d6e0998
Fix broken number parsing in fromJSON
...
The call to tmp_number.append had its arguments mixed up. Also, JSON
does not allow a trailing "," after array/object members.
2016-02-15 15:01:26 +01:00
Eelco Dolstra
eb62e23f14
Fix test broken by #762
2016-02-15 15:01:26 +01:00
Eelco Dolstra
b3e8d72770
Merge pull request #762 from ctheune/ctheune-floats
...
Implement floats
2016-02-12 12:49:59 +01:00
Eelco Dolstra
4f7824c58e
Remove tests/lexer.sh
...
"tests/lang.sh" can handle this.
2016-02-01 18:27:37 +01:00
Christian Theune
5cdcaf5e8e
Adapt tests to show that floats work properly.
2016-01-06 10:03:24 +01:00
Eelco Dolstra
6f1743b1a5
Support SHA-512 hashes
...
Fixes #679 .
Note: on x86_64, SHA-512 is considerably faster than SHA-256 (198 MB/s
versus 131 MB/s).
2015-11-04 16:37:49 +01:00
Eelco Dolstra
76cc8e97a2
Add sort primop
2015-07-28 18:39:39 +02:00
Eelco Dolstra
50807f3dd5
Add primop genList
...
This can be used to implement functions like ‘imap’ (or for that
matter, ‘map’) without the quadratic complexity incurred by calling
‘++’ repeatedly.
2015-07-28 17:28:35 +02:00
Eelco Dolstra
d6d5885c15
Add replaceStrings primop
...
This is a generalisation of replaceChars in Nixpkgs.
2015-07-24 15:32:24 +02:00
Eelco Dolstra
2e8fd4c5cd
Add concatStringsSep as a primop
...
This fixes the quadratic behaviour of concatStrings/concatStringsSep
in Nixpkgs.
2015-07-24 02:38:09 +02:00