aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
AgeCommit message (Collapse)Author
2023-08-10Make the Derived Path family of types inductive for dynamic derivationsJohn Ericson
We want to be able to write down `foo.drv^bar.drv^baz`: `foo.drv^bar.drv` is the dynamic derivation (since it is itself a derivation output, `bar.drv` from `foo.drv`). To that end, we create `Single{Derivation,BuiltPath}` types, that are very similar except instead of having multiple outputs (in a set or map), they have a single one. This is for everything to the left of the rightmost `^`. `NixStringContextElem` has an analogous change, and now can reuse `SingleDerivedPath` at the top level. In fact, if we ever get rid of `DrvDeep`, `NixStringContextElem` could be replaced with `SingleDerivedPath` entirely! Important note: some JSON formats have changed. We already can *produce* dynamic derivations, but we can't refer to them directly. Today, we can merely express building or example at the top imperatively over time by building `foo.drv^bar.drv`, and then with a second nix invocation doing `<result-from-first>^baz`, but this is not declarative. The ethos of Nix of being able to write down the full plan everything you want to do, and then execute than plan with a single command, and for that we need the new inductive form of these types. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-08-07Merge pull request #8692 from obsidiansystems/add-another-xp-checkThéophane Hufschmitt
Feature gate `DownstreamPlaceholder::unknownCaOutput`
2023-07-31Move evaluator settings (type and global) to separate file/headerJohn Ericson
2023-07-21Merge pull request #8650 from obsidiansystems/content-address-simplerEelco Dolstra
Simplify `ContentAddress`
2023-07-13Feature gate `DownstreamPlaceholder::unknownCaOutput`John Ericson
This is a part of CA derivations that we forgot to put behind the experimental feature. This was caught by @fricklerhandwerk in https://github.com/NixOS/nix/pull/8369#discussion_r1258133719
2023-07-10Merge pull request #8579 from obsidiansystems/findPath-cleanup-2John Ericson
Further search path cleanups
2023-07-09Clean up `SearchPath`John Ericson
- Better types - Own header / C++ file pair - Test factored out methods - Pass parsed thing around more than strings Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-07-07Simplify `ContentAddress`John Ericson
Whereas `ContentAddressWithReferences` is a sum type complex because different varieties support different notions of reference, and `ContentAddressMethod` is a nested enum to support that, `ContentAddress` can be a simple pair of a method and hash. `ContentAddress` does not need to be a sum type on the outside because the choice of method doesn't effect what type of hashes we can use. Co-Authored-By: Cale Gibbard <cgibbard@gmail.com>
2023-06-30doc: Improve `fetchClosure` documentationRobert Hensing
2023-06-27Automatically document builtin constantsJohn Ericson
This is done in roughly the same way builtin functions are documented. Also auto-link experimental features for primops, subsuming PR #8371. Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-06-23Use a struct not `std::pair` for `SearchPathElem`John Ericson
I got very confused trying to keep all the `first` and `second` straight reading the code, *especially* as there is also another `(boolean, string)` pair type also being used. Named fields is much better. There are other cleanups that we can do (for example, the existing TODO), but we can do them later. Doing them now would just make this harder to review.
2023-06-14Remove RegisterPrimOp constructor without support for documentationMichal Sojka
The remaining constructor RegisterPrimOp::RegisterPrimOp(Info && info) allows specifying the documentation in .args and .doc members of the Info structure. Commit 8ec1ba02109e removed all uses of the removed constructor in the nix binary. Here, we remove the constructor completely as well as its use in a plugin test. According to #8515, we didn't promis to maintain compatibility with external plugins. Fixes #8515
2023-06-14Merge pull request #4282 from tweag/fix-ca-hash-rewritingJohn Ericson
fix the hash rewriting for ca-derivations
2023-05-31Merge pull request #8421 from fricklerhandwerk/doc-replaceStringsEelco Dolstra
update documentation according to release notes
2023-05-31Merge pull request #8318 from fricklerhandwerk/doc-currentTimeValentin Gagarin
document `builtins.currentTime`
2023-05-30update documentation according to release notesValentin Gagarin
2023-05-30Merge pull request #8398 from ↵Robert Hensing
polykernel/perf/lazy-eval-replacements-replacestrings primops: lazy evaluation of replaceStrings replacements
2023-05-27Restore Nix 2.3 behaviour for {__impure,__contentAddressed} = falseEelco Dolstra
Fixes #8405.
2023-05-25primops: lazy evaluation of replaceStrings replacementspolykernel
The primop `builtins.replaceStrings` currently always strictly evaluates the replacement strings, however time and space are wasted for their computation if the corresponding pattern do not occur in the input string. This commit makes the evaluation of the replacement strings lazy by deferring their evaluation to when the corresponding pattern are matched and memoize the result for efficient retrieval on subsequent matches. The testcases for replaceStrings was updated to check for lazy evaluation of the replacements. A note was also added in the release notes to document the behavior change.
2023-05-24Make `RewritingSink` accept a map of rewritesThéophane Hufschmitt
Giving it the same semantics as `rewriteStrings`. Also add some tests for it
2023-05-17Upgrade `downstreamPlaceholder` to a type with methodsJohn Ericson
This gets us ready for dynamic derivation dependencies (part of RFC 92).
2023-05-17add cross-references to pure evaluation modeValentin Gagarin
use consistent wording everywhere. add some details on the configuration option documentation.
2023-05-15Expose `mkOutputString` as method of `EvalState`John Ericson
2023-05-15Split `mkOutputString` in twoJohn Ericson
This well help us with some unit testing
2023-05-15Remove unneeded argument for `mkOutputString`John Ericson
2023-05-10Merge pull request #3959 from obsidiansystems/ca-drv-exoticJohn Ericson
Derivations can output "text-hashed" data
2023-04-26Doc: Improve builtins.genericClosureFrédéric Christ
2023-04-24Merge remote-tracking branch 'origin/master' into source-pathEelco Dolstra
2023-04-21Use `std::set<StringContextElem>` not `PathSet` for string contextsJohn Ericson
Motivation `PathSet` is not correct because string contexts have other forms (`Built` and `DrvDeep`) that are not rendered as plain store paths. Instead of wrongly using `PathSet`, or "stringly typed" using `StringSet`, use `std::std<StringContextElem>`. ----- In support of this change, `NixStringContext` is now defined as `std::std<StringContextElem>` not `std:vector<StringContextElem>`. The old definition was just used by a `getContext` method which was only used by the eval cache. It can be deleted altogether since the types are now unified and the preexisting `copyContext` function already suffices. Summarizing the previous paragraph: Old: - `value/context.hh`: `NixStringContext = std::vector<StringContextElem>` - `value.hh`: `NixStringContext Value::getContext(...)` - `value.hh`: `copyContext(...)` New: - `value/context.hh`: `NixStringContext = std::set<StringContextElem>` - `value.hh`: `copyContext(...)` ---- The string representation of string context elements no longer contains the store dir. The diff of `src/libexpr/tests/value/context.cc` should make clear what the new representation is, so we recommend reviewing that file first. This was done for two reasons: Less API churn: `Value::mkString` and friends did not take a `Store` before. But if `NixStringContextElem::{parse, to_string}` *do* take a store (as they did before), then we cannot have the `Value` functions use them (in order to work with the fully-structured `NixStringContext`) without adding that argument. That would have been a lot of churn of threading the store, and this diff is already large enough, so the easier and less invasive thing to do was simply make the element `parse` and `to_string` functions not take the `Store` reference, and the easiest way to do that was to simply drop the store dir. Space usage: Dropping the `/nix/store/` (or similar) from the internal representation will safe space in the heap of the Nix programming being interpreted. If the heap contains many strings with non-trivial contexts, the saving could add up to something significant. ---- The eval cache version is bumped. The eval cache serialization uses `NixStringContextElem::{parse, to_string}`, and since those functions are changed per the above, that means the on-disk representation is also changed. This is simply done by changing the name of the used for the eval cache from `eval-cache-v4` to eval-cache-v5`. ---- To avoid some duplication `EvalCache::mkPathString` is added to abstract over the simple case of turning a store path to a string with just that string in the context. Context This PR picks up where #7543 left off. That one introduced the fully structured `NixStringContextElem` data type, but kept `PathSet context` as an awkward middle ground between internal `char[][]` interpreter heap string contexts and `NixStringContext` fully parsed string contexts. The infelicity of `PathSet context` was specifically called out during Nix team group review, but it was agreeing that fixing it could be left as future work. This is that future work. A possible follow-up step would be to get rid of the `char[][]` evaluator heap representation, too, but it is not yet clear how to do that. To use `NixStringContextElem` there we would need to get the STL containers to GC pointers in the GC build, and I am not sure how to do that. ---- PR #7543 effectively is writing the inverse of a `mkPathString`, `mkOutputString`, and one more such function for the `DrvDeep` case. I would like that PR to have property tests ensuring it is actually the inverse as expected. This PR sets things up nicely so that reworking that PR to be in that more elegant and better tested way is possible. Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2023-04-19Remove references from fixed output derivation ab syntaxJohn Ericson
In other words, use a plain `ContentAddress` not `ContentAddressWithReferences` for `DerivationOutput::CAFixed`. Supporting fixed output derivations with (fixed) references would be a cool feature, but it is out of scope at this moment.
2023-04-17`TextHashMethod` -> `TextIngestionMethod`, gate with XP featureJohn Ericson
I suppose we can use `dynamic-derivations` for the few things we neeed.
2023-04-17Merge remote-tracking branch 'upstream/master' into ca-drv-exoticJohn Ericson
2023-04-17Merge remote-tracking branch 'upstream/master' into source-pathRobert Hensing
2023-04-07Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson
2023-04-06Origin: Use SourcePathEelco Dolstra
2023-04-06Backport SourcePath from the lazy-trees branchEelco Dolstra
This introduces the SourcePath type from lazy-trees as an abstraction for accessing files from inputs that may not be materialized in the real filesystem (e.g. Git repositories). Currently, however, it's just a wrapper around CanonPath, so it shouldn't change any behaviour. (On lazy-trees, SourcePath is a <InputAccessor, CanonPath> tuple.)
2023-04-03Allow open switch-enum in 5 placesRobert Hensing
2023-04-01Merge branch 'path-info' into ca-drv-exoticJohn Ericson
2023-04-01Merge commit 'aa99005004bccc9be506a2a2f162f78bad4bcb41' into ca-drv-exoticJohn Ericson
2023-03-30Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson
Also improve content-address.hh API docs.
2023-03-30TypoEelco Dolstra
2023-03-30More precise wordingJoachim Breitner
2023-03-29Update src/libexpr/primops.ccJoachim Breitner
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2023-03-28Update src/libexpr/primops.ccJoachim Breitner
Co-authored-by: asymmetric <lorenzo@mailbox.org>
2023-03-28Docs: Explain why `import nixpkgs` works in flakesJoachim Breitner
2023-03-20Move enabled experimental feature to libutil structJohn Ericson
This is needed in subsequent commits to allow the settings and CLI args infrastructure itself to read this setting.
2023-02-28Merge branch 'path-info' into ca-drv-exoticJohn Ericson
2023-02-28No inheritance for `TextInfo` and `FixedOutputInfo`John Ericson
2023-02-28Revert "Remove some designated initializers"John Ericson
This reverts commit ee9eb83a842eb97d0180fd9d349d30ff27fdb485.
2023-02-28Merge remote-tracking branch 'upstream/master' into path-infoJohn Ericson