aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.hh
AgeCommit message (Collapse)Author
2022-04-21replace most Pos objects/ptrs with indexes into a position tablepennae
Pos objects are somewhat wasteful as they duplicate the origin file name and input type for each object. on files that produce more than one Pos when parsed this a sizeable waste of memory (one pointer per Pos). the same goes for ptr<Pos> on 64 bit machines: parsing enough source to require 8 bytes to locate a position would need at least 8GB of input and 64GB of expression memory. it's not likely that we'll hit that any time soon, so we can use a uint32_t index to locate positions instead.
2022-03-25Only provide builtin.{getFlake,fetchClosure} is the corresponding ↵Eelco Dolstra
experimental feature is enabled This allows writing fallback code like if builtins ? fetchClosure then builtins.fetchClose { ... } else builtins.storePath ...
2021-09-29libexpr: throw a more helpful eval-error if a builtin is not available due ↵Maximilian Bosch
to a missing feature-flag I found it somewhat confusing to have an error like error: attribute 'getFlake' missing if the required experimental-feature (`flakes`) is not enabled. Instead, I'd expect Nix to throw an error just like it's the case when using e.g. `nix flake` without `flakes` being enabled. With this change, the error looks like this: $ nix-instantiate -E 'builtins.getFlake "nixpkgs"' error: Cannot call 'builtins.getFlake' because experimental Nix feature 'flakes' is disabled. You can enable it via '--extra-experimental-features flakes'. at «string»:1:1: 1| builtins.getFlake "nixpkgs" | ^ I didn't use `settings.requireExperimentalFeature` here on purpose because this doesn't contain a position. Also, it doesn't seem as if we need to catch the error and check for the missing feature here since this already happens at evaluation time.
2020-10-06Add missing #pragma onceEelco Dolstra
2020-08-24Allow primops to have Markdown documentationEelco Dolstra
2020-06-18Don't provide 'getFlake' if the 'flakes' feature is not enabledEelco Dolstra
(cherry picked from commit 0a1d3c1dd311f94e9d1f56e1aa7fe1ab34314ec1)
2020-04-07Backport libfetchers from the flakes branchEelco Dolstra
This provides a pluggable mechanism for defining new fetchers. It adds a builtin function 'fetchTree' that generalizes existing fetchers like 'fetchGit', 'fetchMercurial' and 'fetchTarball'. 'fetchTree' takes a set of attributes, e.g. fetchTree { type = "git"; url = "https://example.org/repo.git"; ref = "some-branch"; rev = "abcdef..."; } The existing fetchers are just wrappers around this. Note that the input attributes to fetchTree are the same as flake input specifications and flake lock file entries. All fetchers share a common cache stored in ~/.cache/nix/fetcher-cache-v1.sqlite. This replaces the ad hoc caching mechanisms in fetchGit and download.cc (e.g. ~/.cache/nix/{tarballs,git-revs*}). This also adds support for Git worktrees (c169ea59049f861aaba429f48b828d0820b74d1d).
2018-04-09Make prim_exec and prim_importNative available to pluginsShea Levy
2018-02-08Allow using RegisterPrimop to define constants.Shea Levy
This enables plugins to add new constants, as well as new primops.
2016-04-14Make primop registration pluggableEelco Dolstra
This way we don't have to put all primops in one giant file.
2004-08-04* Allow primops with more that 1 arguments.Eelco Dolstra
2004-02-04* Use a map to lookup primops.Eelco Dolstra
* Various performance improvements in the evaluator. * Do not link against unused (and missing!) libraries (-lsglr, etc.).
2003-11-19* Refactoring: put the Nix expression evaluator in its own library soEelco Dolstra
that it can be used by multiple programs.