about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
AgeCommit message (Collapse)AuthorFilesLines
2019-07-30 Allow builtins.pathExists to check the existence of /nix/store pathsBas van Dijk1-2/+8
This makes it consitent with builtins.readDir.
2019-06-24 Refactor downloadCached() interfaceEelco Dolstra1-11/+11
(cherry picked from commit df3f5a78d5ab0a1f2dc9d288b271b38a9b8b33b5)
2019-06-24 downloadCached: Return ETagEelco Dolstra1-1/+1
(cherry picked from commit 529add316c5356a8060c35f987643b7bf5c796dc)
2019-05-03 Add builtins.hashFileDaniel Schaefer1-0/+15
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-03-24 Add isPath primopzimbatm1-0/+7
this is added for completeness' sake since all the other possible `builtins.typeOf` results have a corresponding `builtins.is<Type>`
2019-03-14 experimental/optional -> optionalEelco Dolstra1-1/+1
2019-01-14 Add builtins.getContext.Shea Levy1-38/+0
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-13 Treat plain derivation paths in context as normal paths.Shea Levy1-17/+3
Previously, plain derivation paths in the string context (e.g. those that arose from builtins.storePath on a drv file, not those that arose from accessing .drvPath of a derivation) were treated somewhat like derivaiton paths derived from .drvPath, except their dependencies weren't recursively added to the input set. With this change, such plain derivation paths are simply treated as paths and added to the source inputs set accordingly, simplifying context handling code and removing the inconsistency. If drvPath-like behavior is desired, the .drv file can be imported and then .drvPath can be accessed. This is a backwards-incompatibility, but storePath is never used on drv files within nixpkgs and almost never used elsewhere.
2018-12-13 Support SRI hashesEelco Dolstra1-6/+4
SRI hashes (https://www.w3.org/TR/SRI/) combine the hash algorithm and a base-64 hash. This allows more concise and standard hash specifications. For example, instead of import <nix/fetchurl.nl> { url = https://nixos.org/releases/nix/nix-2.1.3/nix-2.1.3.tar.xz; sha256 = "5d22dad058d5c800d65a115f919da22938c50dd6ba98c5e3a183172d149840a4"; }; you can write import <nix/fetchurl.nl> { url = https://nixos.org/releases/nix/nix-2.1.3/nix-2.1.3.tar.xz; hash = "sha256-XSLa0FjVyADWWhFfkZ2iKTjFDda6mMXjoYMXLRSYQKQ="; }; In fixed-output derivations, the outputHashAlgo is no longer mandatory if outputHash specifies the hash (either as an SRI or in the old "<type>:<hash>" format). 'nix hash-{file,path}' now print hashes in SRI format by default. I also reverted them to use SHA-256 by default because that's what we're using most of the time in Nixpkgs. Suggested by @zimbatm.
2018-09-13 Merge branch 'dirOf-relative' of https://github.com/lheckemann/nixEelco Dolstra1-1/+1
2018-08-19 FIx floating point evaluationEelco Dolstra1-0/+9
Fixes #2361.
2018-08-13 dirOf: allow use on non-absolute pathsLinus Heckemann1-1/+1
2018-07-31 Merge branch 'prim_mapAttr-fix' of https://github.com/volth/nixEelco Dolstra1-4/+1
2018-07-21 prim_foldlStrict: call forceValue() before value is copiedvolth1-6/+7
forceValue() were called after a value is copied effectively forcing only one of the copies keeping another copy not evaluated. This resulted in its evaluation of the same lazy value more than once (the number of hits is not big though)
2018-07-07 prim_map, prim_genList: no need to force function argument which will be ↵volth1-2/+0
stored in mkApp
2018-07-06 prim_mapAttrs: `f' must be evaluated lazily to avoid infinite recursionvolth1-2/+1
2018-07-05 prim_concatMap: no need to force valuevolth1-1/+0
2018-07-05 prim_mapAttrs: must be lazy to avoid infinite recursionvolth1-4/+5
2018-07-05 prim_concatMap: allocate intermediate list on stackvolth1-7/+15
2018-07-05 primops.cc: fix commentvolth1-1/+1
2018-07-05 lib.concatMap and lib.mapAttrs to be builtinsvolth1-0/+42
2018-05-30 Move evaluator-specific settings out of libstoreEelco Dolstra1-8/+8
2018-05-16 add `mod' and bitwise builtins: camel-case function namesvolth1-6/+6
2018-05-16 add `mod' and bitwise builtins: remove `mod' and shiftsvolth1-36/+0
2018-05-12 add `mod' and bitwise builtinsvolth1-0/+53
2018-04-17 isFunction: True on primops.Shea Levy1-1/+12
Fixes #2073
2018-04-09 Make prim_exec and prim_importNative available to pluginsShea Levy1-2/+2
2018-03-14 Catch more possible instances of passing NULL to memcpy.Shea Levy1-4/+8
Actually fixes #1976.
2018-02-28 Actually fix nixDataDir in non-canonical pathShea Levy1-1/+1
2018-02-26 libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen1-3/+14
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-21 Revert "libexpr: Fix prim_replaceStrings() to work on an empty source string"Eelco Dolstra1-8/+3
This reverts commit 4ea9707591beceacf9988b3c185faf50da238403. It causes an infinite loop in Nixpkgs evaluation, e.g. "nix-instantiate -A hello" hung. PR #1886.
2018-02-19 libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen1-3/+8
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-17 libexpr: Avoid an unnecessary string copy in prim_derivationStrictTuomas Tynkkynen1-1/+1
2018-02-17 libexpr: Remove unnecessary drvName assignment in prim_derivationStrictTuomas Tynkkynen1-6/+0
drvName is already assigned to the same value right at the start of the function.
2018-02-17 libexpr: Optimize prim_derivationStrict by using more symbol comparisonsTuomas Tynkkynen1-9/+9
2018-02-17 libexpr: Optimize prim_attrNames a bitTuomas Tynkkynen1-2/+5
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-14 Add splitVersion primop.Shea Levy1-0/+21
Fixes #1868.
2018-02-07 Merge pull request #1816 from shlevy/add-pathEelco Dolstra1-18/+75
Add path primop.
2018-02-06 Add path primop.Shea Levy1-18/+75
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 realiseContext(): Add derivation outputs to the allowed pathsEelco Dolstra1-10/+24
This makes import-from-derivation work in restricted mode again.
2018-01-18 Don't define builtins.{currentSystem,currentTime} in pure modeEelco Dolstra1-6/+2
This makes it easier to provide a default, e.g. system = builtins.currentSystem or "x86_64-linux";
2018-01-17 TypoEelco Dolstra1-1/+1
2018-01-16 Add pure evaluation modeEelco Dolstra1-9/+35
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-12 import, builtins.readFile: Handle diverted storesEelco Dolstra1-6/+6
Fixes #1791
2018-01-02 Add hasContext primopShea Levy1-0/+9
2017-10-31 Fix filterSourceEelco Dolstra1-32/+14
2017-10-30 Add option allowed-urisEelco Dolstra1-2/+1
This allows network access in restricted eval mode.
2017-10-30 enable-http2 -> http2Eelco Dolstra1-1/+1
2017-10-30 fetchTarball: Use "source" as the default nameEelco Dolstra1-4/+4
This ensures that it produces the same output as fetchgit: $ nix eval --raw '(builtins.fetchgit https://github.com/NixOS/patchelf.git)' /nix/store/ghigrkw02l440g8vfxa9wj4c3zpfmw99-source $ nix eval --raw '(fetchTarball https://github.com/NixOS/patchelf/archive/master.tar.gz)' /nix/store/ghigrkw02l440g8vfxa9wj4c3zpfmw99-source
2017-10-30 fetchurl/fetchTarball: Respect name changesEelco Dolstra1-1/+1
The computation of urlHash didn't take the name into account, so subsequent fetchurl calls with the same URL but a different name would resolve to the same cached store path.