aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
AgeCommit message (Collapse)Author
2018-03-19Shut up signedness warningEelco Dolstra
2018-03-16Merge pull request #1939 from dezgeg/lexer-fixEelco Dolstra
libexpr: Recognize newline in more places in lexer
2018-03-14Catch more possible instances of passing NULL to memcpy.Shea Levy
Actually fixes #1976.
2018-03-14concatLists: Don't pass NULL pointers to memcpy.Shea Levy
This is UB, even if the size is 0. See #1976. Fixes #1976.
2018-03-14Fix compatibility with latest boost::formatEelco Dolstra
2018-03-13fetchGit: Fix debug messageGuillaume Maudoux
2018-03-09Modified MakeBinOp to no longer produce its name using concatenation and "##".Tim Engler
Doing so prevents emacs tags from working, as well as makes the code extremely confusing for a newbie. In the prior state, if someone wants to find the definition of "ExprApp" for example, a grep through the code reveals nothing. Since the definition could be hiding in numerous ".h" files, it's really difficult to find. This personally took me several hours to figure out.
2018-03-02libexpr: Recognize newline in more places in lexerTuomas Tynkkynen
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-02-28fetchGit: use "HEAD" as default refWill Dietz
2018-02-28Actually fix nixDataDir in non-canonical pathShea Levy
2018-02-26libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen
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 e2d71bd1862cdda because it caused another infinite loop, which is fixed now and a test added.
2018-02-22Merge branch 'data-dir-non-canon' of https://github.com/shlevy/nixEelco Dolstra
2018-02-22Fix restricted mode when installing in non-canonical data dirShea Levy
2018-02-21Revert "libexpr: Fix prim_replaceStrings() to work on an empty source string"Eelco Dolstra
This reverts commit 4ea9707591beceacf9988b3c185faf50da238403. It causes an infinite loop in Nixpkgs evaluation, e.g. "nix-instantiate -A hello" hung. PR #1886.
2018-02-19libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen
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-19libexpr: Don't create lots of temporary strings in Bindings::lexicographicOrderTuomas Tynkkynen
Avoids ~180,000 string temporaries created when evaluating a headless NixOS system.
2018-02-17libexpr: Avoid an unnecessary string copy in prim_derivationStrictTuomas Tynkkynen
2018-02-17libexpr: Remove unnecessary drvName assignment in prim_derivationStrictTuomas Tynkkynen
drvName is already assigned to the same value right at the start of the function.
2018-02-17libexpr: Optimize prim_derivationStrict by using more symbol comparisonsTuomas Tynkkynen
2018-02-17libexpr: Rely on Boehm returning zeroed memory in EvalState::allocEnv()Tuomas Tynkkynen
Boehm guarantees that memory returned by GC_malloc() is zeroed, so take advantage of that.
2018-02-17libexpr: Optimize prim_attrNames a bitTuomas Tynkkynen
Instead of having lexicographicOrder() create a temporary sorted array of Attr*:s and copying attr names from that, copy the attr names first and then sort that.
2018-02-16libexpr: Pre-reserve space in string in unescapeStr()Tuomas Tynkkynen
Avoids some malloc() traffic.
2018-02-14Add splitVersion primop.Shea Levy
Fixes #1868.
2018-02-13Merge branch 'register-constant' of https://github.com/shlevy/nixEelco Dolstra
2018-02-11Nix stats: flatten statisticsFrederik Rietdijk
Flattens the list of statistics as suggested in https://github.com/NixOS/ofborg/issues/67. This makes it easier to work with.
2018-02-08Allow using RegisterPrimop to define constants.Shea Levy
This enables plugins to add new constants, as well as new primops.
2018-02-07Merge pull request #1816 from shlevy/add-pathEelco Dolstra
Add path primop.
2018-02-06Add path primop.Shea Levy
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-06realiseContext(): Add derivation outputs to the allowed pathsEelco Dolstra
This makes import-from-derivation work in restricted mode again.
2018-02-06checkURI(): Check file URIs against allowedPathsEelco Dolstra
This makes e.g. 'fetchGit ./.' work (assuming that ./. is an allowed path).
2018-01-19Don't use [[noreturn]]Eelco Dolstra
2018-01-18Don't define builtins.{currentSystem,currentTime} in pure modeEelco Dolstra
This makes it easier to provide a default, e.g. system = builtins.currentSystem or "x86_64-linux";
2018-01-17TypoEelco Dolstra
2018-01-16Add pure evaluation modeEelco Dolstra
In this mode, the following restrictions apply: * The builtins currentTime, currentSystem and storePath throw an error. * $NIX_PATH and -I are ignored. * fetchGit and fetchMercurial require a revision hash. * fetchurl and fetchTarball require a sha256 attribute. * No file system access is allowed outside of the paths returned by fetch{Git,Mercurial,url,Tarball}. Thus 'nix build -f ./foo.nix' is not allowed. Thus, the evaluation result is completely reproducible from the command line arguments. E.g. nix build --pure-eval '( let nix = fetchGit { url = https://github.com/NixOS/nixpkgs.git; rev = "9c927de4b179a6dd210dd88d34bda8af4b575680"; }; nixpkgs = fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-17.09"; rev = "66b4de79e3841530e6d9c6baf98702aa1f7124e4"; }; in (import (nix + "/release.nix") { inherit nix nixpkgs; }).build.x86_64-linux )' The goal is to enable completely reproducible and traceable evaluation. For example, a NixOS configuration could be fully described by a single Git commit hash. 'nixos-rebuild' would do something like nix build --pure-eval '( (import (fetchGit { url = file:///my-nixos-config; rev = "..."; })).system ') where the Git repository /my-nixos-config would use further fetchGit calls or Git externals to fetch Nixpkgs and whatever other dependencies it has. Either way, the commit hash would uniquely identify the NixOS configuration and allow it to reproduced.
2018-01-12import, builtins.readFile: Handle diverted storesEelco Dolstra
Fixes #1791
2018-01-09fetchGit: fix creation of uninitialized cache dir, let git create itWill Dietz
fetchGit test (as modified in previous commit) now passes.
2018-01-02Add hasContext primopShea Levy
2017-12-22fetchGit: Fix handling of local repo when not using 'master' branchWill Dietz
Add tests checking this behavior.
2017-12-14json-to-value: Throw sensible error message on invalid numbersBen Gamari
2017-12-05Merge branch 'fetchGit-fast-revision-update'Shea Levy
2017-11-24nix-shell/nix-build: Support .drv files againEelco Dolstra
Fixes #1663. Also handle '!<output-name>' (#1694).
2017-11-24fetchGit: Ignore tarballTtl if rev is set and not in the repo.Shea Levy
Fixes #1697.
2017-11-21fetchGit/fetchMercurial: Fix directory inclusion checkEelco Dolstra
E.g. the existence of .gitignore would cause .git to be included.
2017-11-14Revert "Don't parse "x:x" as a URI"Eelco Dolstra
This reverts commit f90f660b243866b8860eeb24cc4a345d32cc7ce7. This broke Hydra's release.nix, which contained preCheck = ''export LOGNAME=${LOGNAME:-foo}'';
2017-11-03fetchgit.cc -> fetchGit.ccEelco Dolstra
2017-11-03Remove git:// support in NIX_PATHEelco Dolstra
This didn't support specifying a revision/branch, and was restricted to git:// URIs (since https:// or ssh:// would be ambiguous).
2017-11-03fetchGit/fetchMercurial: Filter out directories with untracked filesEelco Dolstra
2017-11-03fetchGit: Add a testEelco Dolstra
2017-11-03fetchGit: Don't do a remote fetch if we already have the revEelco Dolstra
2017-11-02fetchMercurial: fix error messagetv