aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
AgeCommit message (Collapse)Author
2024-03-04Merge pull request #9582 from pennae/misc-optseldritch horrors
a packet of small optimizations (cherry picked from commit ee439734e924eb337a869ff2e48aff8b989198bc) Change-Id: I125d870710750a32a0dece48f39a3e9132b0d023
2024-03-04Merge pull request #9645 from tweag/undeprecate-isNulleldritch horrors
Undeprecate isNull (cherry picked from commit 8e64cd59b0fe1a4e1d3ba8d359ea0f9af2936f94) Change-Id: If36b85a3fc01ee700bcaf4d5d83a5884a4b5de92
2024-03-04Merge pull request #4093 from matthewbauer/eval-systemeldritch horrors
Add eval-system option (cherry picked from commit 071dbbee33af9f27338c3e53e4ea067dbfa14010) Change-Id: Ia81358c8cfb60241da07a4d0e84b9ee62a18a53f
2024-03-04Merge pull request #9555 from 9999years/positions-in-errorseldritch horrors
Pass positions when evaluating (cherry picked from commit c8458bd731eb1c74159bebe459ea00165e056b65) Change-Id: I1b4a5d58973be6264ffdb23b4492da200fdb71be
2024-03-04Merge pull request #9430 from hercules-ci/remove-vlaseldritch horrors
Fix stack overflow in `filter` (cherry picked from commit cb7f25869daa2491eeac5fee49ad8f31b2218c15) Change-Id: Ib90f97a9805bbb4d0e2741551d490f054fc0a675
2024-03-04Merge pull request #9465 from obsidiansystems/build-direldritch horrors
Use `buildprefix` in a few more places (cherry picked from commit b6a3fde6b7a416929553e6be36fc991680ddf9ef) Change-Id: I2790663fa9f8242ac2db6582b7e421d2fdf42942
2024-03-04Merge pull request #9462 from trofi/eval.o-dependencyeldritch horrors
libexpr: add missing dependency on 'flake/call-flake.nix.gen.hh' (cherry picked from commit f0180487a0e4c0091b46cb1469c44144f5400240) Change-Id: I27211872ad75034ae3f04e18b2987f9968073d00
2024-03-04Merge pull request #9398 from Qyriad/fixes/flake-not-foundeldritch horrors
flakes: bare minimum fix the error message for untracked flake.nix (cherry picked from commit 7f626dba332f320fafb9f9c749986ea523d20f42) Change-Id: I470ac56a670a8c11e4164c6b059184a02344d491
2024-03-04Merge pull request #9399 from edolstra/revert-vlaseldritch horrors
Revert use of boost::container::small_vector in the evaluator (cherry picked from commit 6832d18ac734f4b855f97c07b158491dd01cefcd) Change-Id: I7f10af0c8b8a8beb4b1e36424120995f4ed82738
2024-03-04Merge pull request #9395 from nbraud/buitlinseldritch horrors
builtins.concatMap: Fix typo in error message (cherry picked from commit 4292d997568eb30503e287f98e24821ff0bc2816) Change-Id: Ia33d1b02e41f699ef0c8c2d6487c9f70b2cc8cf4
2024-03-04Merge pull request #9374 from hercules-ci/fix-nogceldritch horrors
Fix buildNoGc (cherry picked from commit 7762335a9c4d56f7501825345728c3f94e88bc31) Change-Id: I3ad53c9c1dd9180a2abc3528e9437c28ac95b303
2024-03-04Merge pull request #7348 from thufschmitt/dont-use-vlaseldritch horrors
Remove the usage of VLAs in the code (cherry picked from commit ac4431e9d016e62fb5dc9ae36833bd0c6cdadeec) Change-Id: Ifbf5fbfc2e27122362a2aaea4b62c7cf3ca46b1a
2024-03-04Merge pull request #9364 from edolstra/fix-coverageeldritch horrors
Fix a broken generated header file dependency (cherry picked from commit 57de482e00221d781f916d49c315a8fa0816e956) Change-Id: I0580274bf51132fbeb34e8c0a91a7017071d2bb3
2024-03-04Fix `boost::bad_format_string` exception in `builtins.addErrorContext` (#9291)eldritch horrors
* Fix boost::bad_format_string exception in builtins.addErrorContext The message passed to addTrace was incorrectly being used as a format string and this this would cause an exception when the string contained a '%', which can be hit in places where arbitrary file paths are interpolated. * add test (cherry picked from commit 61d6fe059e959455e156c1d57bb91155d363e983) Change-Id: Idd671127a9c1ccc8b94e58e727632fcc064f3cbe
2024-03-04Merge pull request #9216 from obsidiansystems/addDrvOutputDependencies-preeldritch horrors
Add `builtins.addDrvOutputDependencies` (cherry picked from commit a58d7f143ec995a45745c2176bfebcc3e011db58) Change-Id: Ia5a1790bf29dfaf29287cc35cdae6b6d650e7a83
2024-03-04Merge pull request #9172 from tfc/bad-moveseldritch horrors
Fix/remove some bad std::moves (cherry picked from commit 8c049a9f044569ebda70231709f6f15d3073894a) Change-Id: I720273378d2506a13883acee28abd096d099b0d4
2024-03-04Merge pull request #8895 from hercules-ci/gc-before-statseldritch horrors
eval: Run a full GC before printing stats (cherry picked from commit aeea49609be014b1928c95b7ec28dbedeb4f032a) Change-Id: I47a23d3a7a47ea61d9a2b5727b638f879f3aaf1e
2024-03-04Merge pull request #9029 from inclyc/users/lyc/pass-value-2Eelco Dolstra
libexpr: const rvalue reference -> value for nix::Expr nodes (cherry picked from commit de99647b9c66219b2e7bc698a62377cc4f6148f6) Change-Id: I96baf96b0a17e401548a926a7015f85e11d7c459
2024-02-15Fix the buildThéophane Hufschmitt
bef68e53b9d08c99873a5bc60568b7351934ad51 (backport of 31ebc6028b3682969d86a7b39ae87131c41cc604) accidentally broke the build because of a change in the constructor of `SourcePath` between 2.18 and master. Fix that.
2024-01-21Fix symlink handlingEelco Dolstra
This restores the symlink handling behaviour prior to 94812cca98fbb157e5f64a15a85a2b852d289feb. Fixes #9298. (cherry picked from commit 31ebc6028b3682969d86a7b39ae87131c41cc604)
2024-01-11Merge branch '2.18-maintenance' into ifd-buildStore-2.18Shea Levy
2024-01-11Build IFD in the build store when using eval-store.Shea Levy
Previously, IFDs would be built within the eval store, even though one is typically using `--eval-store` precisely to *avoid* local builds. Because the resulting Nix expression must be copied back to the eval store in order to be imported, this requires the eval store to trust the build store's signatures. (cherry picked from commit c3942ef85ffbd83391410fbf012f1de366d2463c)
2023-12-01Move tests to separate directories, and documentJohn Ericson
Today, with the tests inside a `tests` intermingled with the corresponding library's source code, we have a few problems: - We have to be careful that wildcards don't end up with tests being built as part of Nix proper, or test headers being installed as part of Nix proper. - Tests in libraries but not executables is not right: - It means each executable runs the previous unit tests again, because it needs the libraries. - It doesn't work right on Windows, which doesn't want you to load a DLL just for the side global variable . It could be made to work with the dlopen equivalent, but that's gross! This reorg solves these problems. There is a remaining problem which is that sibbling headers (like `hash.hh` the test header vs `hash.hh` the main `libnixutil` header) end up shadowing each other. This PR doesn't solve that. That is left as future work for a future PR. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> (cherry picked from commit 91b6833686a6a6d9eac7f3f66393ec89ef1d3b57) (cherry picked from commit a61e42adb528b3d40ce43e07c79368d779a8b624)
2023-11-22Add missing `-lrapidcheck` fixing build with shared libJohn Ericson
https://github.com/NixOS/nixpkgs/pull/269064 makes rapidcheck be build as a shared lib, but that broke Nix because the `-lrapidcheck` was missing. This fixes that (and doesn't break Nix what the library is a static archive as today). (cherry picked from commit 46131567da96ffac298b9ec54016b37114b0dfd5)
2023-11-20fetchTree: clarify docs for shallow flagDavHau
(cherry picked from commit 796a7eb92d2b0caf75685126adc7460a4c39cfec)
2023-10-01pathExists: isDir when endswith /.Robert Hensing
(cherry picked from commit f8a3893e8d77ce4a6e23719a0b2d88464cb84b9c)
2023-09-19Disable rapidcheck tests in the coverage runEelco Dolstra
https://hydra.nixos.org/build/233688539
2023-09-10Drop dead codeMatthew Kenigsberg
localPath is unused
2023-09-07Merge pull request #8944 from fricklerhandwerk/fix-anchorRobert Hensing
fix invalid anchor link
2023-09-07Allow dynamic derivation deps in `inputDrvs`John Ericson
We use the same nested map representation we used for goals, again in order to save space. We might someday want to combine with `inputDrvs`, by doing `V = bool` instead of `V = std::set<OutputName>`, but we are not doing that yet for sake of a smaller diff. The ATerm format for Derivations also needs to be extended, in addition to the in-memory format. To accomodate this, we added a new basic versioning scheme, so old versions of Nix will get nice errors. (And going forward, if the ATerm format changes again the errors will be even better.) `parsedStrings`, an internal function used as part of parsing derivations in A-Term format, used to consume the final `]` but expect the initial `[` to already be consumed. This made for what looked like unbalanced brackets at callsites, which was confusing. Now it consumes both which is hopefully less confusing. As part of testing, we also created a unit test for the A-Term format for regular non-experimental derivations too. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Apply suggestions from code review Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-09-07fix invalid anchor linkValentin Gagarin
2023-09-01Merge pull request #8869 from hercules-ci/fix-issue-8838-pathExists-isDirEelco Dolstra
Fix #8838, pathExists: isDir when ends with `/ `
2023-08-25pathExists: isDir when endswith /Robert Hensing
Fixes https://github.com/NixOS/nix/issues/8838
2023-08-25Merge pull request #8829 from obsidiansystems/build-dynamic-derivationsJohn Ericson
Adapt scheduler to work with dynamic derivations
2023-08-25Merge pull request #8819 from VertexA115/fix/deep-follow-pathstomberek
Fix follow path checking at depths greater than 2
2023-08-25Introduce `OutputName` and `OutputNameView` type aliasesJohn Ericson
Hopefully they make the code easier to understand!
2023-08-18Delete `EvalState::addToSearchPath`John Ericson
This function is now trivial enough that it doesn't need to exist. `EvalState` can still be initialized with a custom search path, but we don't have a need to mutate the search path after it has been constructed, and I don't see why we would need to in the future. Fixes #8229
2023-08-18Merge pull request #8839 from obsidiansystems/string-context-7479John Ericson
Refactor Raw pattern, part of #7479
2023-08-18Fixing #7479John Ericson
Types converted: - `NixStringContextElem` - `OutputsSpec` - `ExtendedOutputsSpec` - `DerivationOutput` - `DerivationType` Existing ones mostly conforming the pattern cleaned up: - `ContentAddressMethod` - `ContentAddressWithReferences` The `DerivationGoal::derivationType` field had a bogus initialization, now caught, so I made it `std::optional`. I think #8829 can make it non-optional again because it will ensure we always have the derivation when we construct a `DerivationGoal`. See that issue (#7479) for details on the general goal. `git grep 'Raw::Raw'` indicates the two types I didn't yet convert `DerivedPath` and `BuiltPath` (and their `Single` variants) . This is because @roberth and I (can't find issue right now...) plan on reworking them somewhat, so I didn't want to churn them more just yet. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2023-08-17libexpr/tests: test that parseFlakeRef doesn't percent-encode twiceCole Helbling
2023-08-14src/libexpr/search-path.cc: avoid out-of-bounds read on string_viewSergei Trofimovich
Without the change build with `-D_GLIBCXX_ASSERTIONS` exposes testsuite assertion: $ gdb src/libexpr/tests/libnixexpr-tests Reading symbols from src/libexpr/tests/libnixexpr-tests... (gdb) break __glibcxx_assert_fail (gdb) run (gdb) bt in std::__glibcxx_assert_fail(char const*, int, char const*, char const*)@plt () from /mnt/archive/big/git/nix/src/libexpr/libnixexpr.so in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffff56c0, __pos=4) at /nix/store/r74fw2j8rx5idb0w8s1s6ynwwgs0qmh9-gcc-14.0.0/include/c++/14.0.0/string_view:258 in nix::SearchPath::Prefix::suffixIfPotentialMatch (this=0x7fffffff5780, path=...) at src/libexpr/search-path.cc:15 in nix::SearchPathElem_suffixIfPotentialMatch_partialPrefix_Test::TestBody (this=0x555555a17540) at src/libexpr/tests/search-path.cc:62 As string sizes are usigned types `(a - b) > 0` effectively means `a != b`. While the intention should be `a > b`. The change fixes test suite pass.
2023-08-14Fix follow path checking at depths greater than 2Alex Zero
We need to recurse into the input tree to handle follows paths that trarverse multiple inputs that may or may not be follow paths themselves.
2023-08-14Create `outputOf` primop.John Ericson
In the Nix language, given a drv path, we should be able to construct another string referencing to one of its output. We can do this today with `(import drvPath).output`, but this only works for derivations we already have. With dynamic derivations, however, that doesn't work well because the `drvPath` isn't yet built: importing it like would need to trigger IFD, when the whole point of this feature is to do "dynamic build graph" without IFD! Instead, what we want to do is create a placeholder value with the right string context to refer to the output of the as-yet unbuilt derivation. A new primop in the language, analogous to `builtins.placeholder` can be used to create one. This will achieve all the right properties. The placeholder machinery also will match out the `outPath` attribute for CA derivations works. In 60b7121d2c6d4322b7c2e8e7acfec7b701b2d3a1 we added that type of placeholder, and the derived path and string holder changes necessary to support it. Then in the previous commit we cleaned up the code (inspiration finally hit me!) to deduplicate the code and expose exactly what we need. Now, we can wire up the primop trivally! Part of RFC 92: dynamic derivations (tracking issue #6316) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-14Rework evaluator `SingleDerivedPath` infraJohn Ericson
`EvalState::mkSingleDerivedPathString` previously contained its own inverse (printing, rather than parsing) in order to validate what was parsed. Now that is pulled out into its own separate function: `EvalState::coerceToSingleDerivedPath`. In additional that pulled out logic is deduplicated with `EvalState::mkOutputString` via `EvalState::mkOutputStringRaw`, which is itself deduplicated (and generalized) with `DownstreamPlaceholder::mkOutputStringRaw`. All these changes make the unit tests simpler. (We would ideally write more unit tests for `mkSingleDerivedPathString` `coerceToSingleDerivedPath` directly, but we cannot yet do that because the IO in reading the store path won't work when the dummy store cannot hold anything. Someday we'll have a proper in-memory store which will work for this.) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-14Rename `optOutputPath` to `optStaticOutputPath`John Ericson
This choice of variable name makes it more clear what is going on. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-11Merge pull request #8735 from obsidiansystems/defexprRobert Hensing
Factor out `nix-defexpr` path computation
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 #8769 from edolstra/generalize-tarball-urlsEelco Dolstra
Don't require .tar/.zip extension for tarball flakerefs
2023-08-07Merge pull request #8692 from obsidiansystems/add-another-xp-checkThéophane Hufschmitt
Feature gate `DownstreamPlaceholder::unknownCaOutput`
2023-08-02Factor out `nix-defexpr` path computationJohn Ericson
Avoid duplicated code, and also avoid "on the fly" path construction (which makes it harder to keep track of which paths we use). The factored out code doesn't create the Nix state dir anymore, but this is fine because other in nix-env and nix-channel does: - nix-channel: Line 158 in this commit - nix-env: Line 1407 in this commit