Commit Graph
2266 Commits
Author SHA1 Message Date
eldritch horrors e47bff547a libutil: fix some thread pool bugs
4138fc7622 mistakenly removed an early
exit from non-main worker threads. this led to exceptions not ending
`process()` calls in a timely manner and instead draining the entire
work queue first, which for e.g. Interrupted errors would cause many
duplicated reports per worker thread instead of only one per thread.

it also did not properly rethrow a work item exception in all cases,
e.g. when all work had completed by the time `process()` was called.

due to a mistake in the thread starting check it was possible that a
system would require n² work items to start n worker threads if some
work items process quickly enough while other items block for a bit.

Change-Id: I7d59483580cda1c19980f9296074216a0fbf2c4e
2025-02-21 00:35:11 +01:00
Jade Lovelace c9b2e8b1d9 fix: pre-build-hook did not run when useChroot == false
It turns out there is actually some history here.
Eight years ago, in 7f5b750b40, the
pre-build-hook condition got changed to check that useChroot is true
(which we will put down as "eelco making a mistake" because it makes no
sense) and that this->drv was a Derivation (as opposed to a
BasicDerivation as would be the case if the derivation was not present
on disk). The intent of this change was that pre-build-hook would not
run when the derivation doesn't exist, so that some hydras would not
explode.

However, this broke later when both cases became Derivation such that
AFAICT it will always run it if useChroot is true, which is absolutely
not the intended behaviour, but it is a reasonable interpretation as
well, just inconvenient for certain pre-build-hook usages.

So, I think the safest and most compatible behaviour is to run the
pre-build-hook but not guarantee that the derivation actually exists on
disk, since it already didn't run in many cases. Maybe the more correct
way is to actually write out the derivation if we are running a
pre-build-hook, but post-build-hook has exactly the same situation and
it's expected, so idk.

Fixes: https://git.lix.systems/lix-project/lix/issues/674
Change-Id: I75b828ae2a07ab373f44083507eb243459bd081d
2025-02-17 16:05:06 -08:00
Robert HensingandLinus Heckemann 66da3fd63f libstore: more precise origin info for strange structured logs
Robert made these improvements on the PR that cherry-picked
e55cd3beea /
https://gerrit.lix.systems/c/lix/+/2057
from Lix into CppNix:
https://github.com/NixOS/nix/pull/11921

Push log source description out of libutil and report build hook @nix warning correctly

(cherry picked from commit 03d4bfd852dce9a050f984e887c887a43581796c)

test: Move unusual-logging to run only in logging test case

(cherry picked from commit 1421420e862434321c46511a3152016e443dd479)

Remove redundant warning: prefix from structured build log warning

(cherry picked from commit f3c722cab24f7a0de8c3573d25e91749f4f16234)
Change-Id: I7da99046f2a41b3c58e62351119bc89bcc25a703
2025-02-16 14:15:36 +01:00
eldritch horrors ecfda8abe2 libstore: asyncify openStore
Change-Id: Ia152bfd2014851590328e732f434dff6695304bd
2025-02-08 12:45:15 +00:00
alois31andGerrit Code Review 8553adbb41 Merge "libfetchers/mercurial: handle "evil refs" gracefully" into main 2025-02-04 17:40:32 +00:00
Rebecca Turner c263070d37 Fix crash in debugger mode using with
Fixes this crash (#592):

    $ nix repl --debugger
    Lix 2.92.0-dev-pre20241120-66f6dbd debugger
    Type :? for help.
    nix-repl> let x = 4; in __seq x (with x; (x: builtins.break x) 1)
    info: breakpoint reached

    [1]    949722 segmentation fault (core dumped)  nix repl --debugger

Change-Id: I13c72941dc325ff984dcce2a84c01c89b1c552af
2025-02-03 15:22:50 -08:00
eldritch horrors 48519448e2 libcmd: asyncify lookupFileArg
Change-Id: Ied47f5f96eeb8324c500335fa8f5388d10bed54c
2025-02-01 21:48:48 +00:00
jadeandGerrit Code Review e529074cb2 Merge "functional2: add missing __init__.py" into main 2025-01-31 03:48:36 +00:00
Dusk Banks 6a583136b7 libexpr: fix --debugger --ignore-try
a65e9e5828 did not inform `tryEval` that
(as far as it's concerned) `state.debug` moved to `state.errors.debug`
and changed types. this resulted in the REPL erroneously coming up, that
REPL having a non-debug state, and segfaulting after that REPL exited.

it's probably good that `state.debug` isn't mutated by `--ignore-try`
anymore.

Change-Id: I1918e93edacd626452aa423fc2eb825080738835
Fixes: a65e9e5828 ("libexpr: extract eval error creation into new type")
Signed-off-by: Dusk Banks <me@bb010g.com>
2025-01-30 18:46:14 -08:00
Jade Lovelace 1eafc7dbf4 build: automate some boehm/kj dependencies internally
We will link to boehm inside of the test suite if it depends on libexpr
but we don't need it for other tests.

For anything linking to libexpr internally, just like externally, it
needs to link to boehm.

Likewise with kj and libutil (or really any lix), so we should just make
it automatic.

Change-Id: I2bb9ec4668e6ff741b4139fdce167f278eb71c7e
2025-01-28 12:19:00 -08:00
piegames f8a592713d repl: Allow :env outside of debug mode
Printing the current variables plus staticBaseEnv is useful

Change-Id: Ide8bc26c1c6b4ec0b1d68767994ddac8891a649f
2025-01-28 09:37:01 +01:00
piegames f324574265 libexpr: Track position information in all expressions
Change-Id: Ied79381a917a715cdd8816d6f9df527289217dfb
2025-01-27 20:49:25 +01:00
piegames d0361e9467 libexpr: Unify literal expressions as ExprLiteral
Change-Id: Ifc0f1e27b46803fa2175801ed7d3d108896c8259
2025-01-27 20:49:25 +01:00
Alois Wohlschlager a2daf4e774 libfetchers/mercurial: handle "evil refs" gracefully
If a revision is specified in a way that looks like a commit hash, Lix expects
that it actually is a commit hash. Unlike Git, Mercurial will fall back to
bookmarks, tags and branches with the specified name when a commit with the
specified hash does not exist. Previously, an assertion failure would be thrown
due to the resulting commit hash mismatch. Tell Mercurial to only take commit
hashes into account, whose non-existence is then handled gracefully.

Change-Id: I98bf020187575f3cf8176831da85872d066c4d95
2025-01-26 11:22:03 +01:00
jadeandGerrit Code Review 0262879b0d Merge changes Iaa096f7d,I48b7c1be into main
* changes:
  functional2: tidy up some of the NAR handling
  functional2: add http server fixture
2025-01-26 02:05:38 +00:00
eldritch horrors 0ad79775b6 libstore: asyncify Store worker entry points
Change-Id: Iafa0c4093064095d196c738cc7e9ba1d8e906b8c
2025-01-25 13:01:21 +00:00
Jade Lovelace aa1aacb3e0 functional2: tidy up some of the NAR handling
Change-Id: Iaa096f7daefa71cad7ac787bce78d91fa4176541
2025-01-24 17:10:44 -08:00
Jade Lovelace c57a99e9c3 functional2: add http server fixture
This doesn't use http.server because it is really quite janky and has a
quite bad API.

cc: https://git.lix.systems/lix-project/lix/issues/600
Change-Id: I48b7c1beb89fac21fa32f1e09f595063b795d70a
2025-01-24 15:45:20 -08:00
eldritch horrors d6a203b795 treewide: add async io roots to evaluation
ifd requires building which uses async code today, fetching requires
network io which really should use async code but does not yet. eval
itself cannot be made async for performance reasons. offloading work
to other threads is possible but questionable as currently there are
no uses in which evaluation must take place from within asynchronous
operations, which are currently confined entirely to store behavior.

Change-Id: I1e3c86fca19b042d79332e9a5ef9546f90a6448b
2025-01-24 13:48:44 +00:00
eldritch horrors 5dd4154869 treewide: add async io roots to entry points
it begins.

Change-Id: I4b762d48180a763d2724fc635ca025f0333026b0
2025-01-24 13:48:44 +00:00
jadeandGerrit Code Review 402aca87c0 Merge "Revert "libstore: always load localstore public keys"" into main 2025-01-24 02:25:11 +00:00
jade 4b6dbc96c1 Revert "libstore: always load localstore public keys"
Though this is a revert, it also involves fixing the code with new code
and a regression test. The problematic locking that was there before has
been removed, in any case.

This reverts commit ba728e46be.

Reason for revert: regression.
Fixes: https://git.lix.systems/lix-project/lix/issues/647

Change-Id: I326b1a10042ff69afbab38426e042e0dc2224a13
2025-01-23 17:57:52 -08:00
Jade Lovelace 5f3adb4b1f functional2: add missing __init__.py
Technically these aren't required these days, but they make some tooling
work a little better.

Change-Id: I04dadb40ffb89066c26ad0611a78787215b56cb5
2025-01-23 14:24:08 -08:00
giliceandGerrit Code Review 91fe1e0217 Merge "libexpr/flake: user friendly error if parsing flake.lock fails" into main 2025-01-23 16:45:22 +00:00
gilice 68373f8664 libexpr/flake: user friendly error if parsing flake.lock fails
Fix: https://git.lix.systems/lix-project/lix/issues/559
Change-Id: I75f56c801d7f16a2e1ef8e702f16f1ef91f7b01f
2025-01-23 15:17:14 +01:00
Maximilian BoschandGerrit Code Review caafc3f84b Merge changes I36e3e951,I38e9174d into main
* changes:
  local-derivation-goal: improve "illegal reference" error
  nix-util: Add concatMapStrings
2025-01-23 06:44:16 +00:00
jadeandGerrit Code Review 1fe6064ced Merge "FileTransfer: fix race condition on awaitData" into main 2025-01-22 21:06:31 +00:00
eldritch horrorsand de58cd6e80 FileTransfer: fix race condition on awaitData
There's a race condition where awaitData could early-return for data
coming from a 404 response or similar and thus not rethrow the exception
that is forthcoming, and a related race during transfer setup (which
could retry a transfer *twice* per retry round).

This would then cause substitution failures like below since the exception
isn't caught in HttpBinaryCacheStore::getFile as intended, but instead
by an exception handler downstream of `drain()` which would error out
the entire operation.

Symptom:

 » nix-build ./docs-service.nix -o "docs-service-result"
error: unable to download 'https://cache.nixos.org/7mr3fy8w66gi5inmf0jkkkl90lxy4jyg.narinfo': HTTP e
rror 404 ()

       response body:

This is kind of a hack in how it is implemented: it assumes that you
can't intentionally be receiving a large unsuccessful response since in
such a case, `awaitData` will wait for finish() to be called to throw an
exception and will never escape until the download finishes, while
continuing to buffer the entire response into memory, which could be bad
if an error response had a large payload.

That said, nobody is sending Lix 1GiB of 404, so meh I guess, and this
is how it is seemingly intended to work. That was a design flaw of the
thing before any of the Lix team got our paws on it.

I tested this by adding _exit(0) inside the expected exception catch and
then running the offending command repeatedly to see if the symptom ever
appeared again, and it did not.

Needs cherry-pick to 2.92 and a 2.92.1 release once reviewed.

Fixes: https://git.lix.systems/lix-project/lix/issues/635
Co-Authored-By: lix@jade.fyi
Change-Id: If54f6eeaad60b5ca9d5b77d4d9232da1d295e7d1
2025-01-22 20:32:46 +01:00
piegamesandGerrit Code Review 9b29008114 Merge changes I995f0bdc,Icdbaad17 into main
* changes:
  libexpr: Refactor ExprState::pushExpr
  libexpr: Remove `Expr::show`, add JSON expression serialization
2025-01-21 14:04:28 +00:00
piegames cf57b5c14c libexpr: Remove Expr::show, add JSON expression serialization
The code for serialization Expr nodes back into (pseudo-)Nix has been
removed for being subtly error-prone and tedious to maintain. Instead,
`nix-instantiate --parse` now prints a JSON representation of the AST.

Usage patterns of the --parse flag I've found in the wild:

1. Check if a file is well-formed, i.e. discard output and test exit code
2. Get parser errors from a file, i.e. discard stdout and use stderr
3. Nixfmt uses --parse to test equivalence pre/post format, and that property is (should be?) preserved

None of these should break with the current change

Closes #487

Change-Id: Icdbaad17790f2ad8765fa08e02e6597ee4c7a909
2025-01-21 11:35:51 +01:00
eldritch horrors d5dc8361f5 libstore: create statement object from SQLite instance
it's just cleaner this way, same as with transactions.

Change-Id: Ibe8fe0bb3d5846f7b7b51e3454bd2fde44d4a5bb
2025-01-20 23:07:44 +01:00
Sergei TrofimovichandMaximilian Bosch 108c051fd8 local-derivation-goal: improve "illegal reference" error
Before the change "illegal reference" was hard to interpret as it did
not mention what derivation actually hits it.

Today's `nixpkgs` example:

Before the change:

    $ nix build --no-link -f. postgresql_14
    ...
    error: derivation contains an illegal reference specifier 'man'

After the change:

    $ nix build --no-link -f. postgresql_14
    ...
    error: derivation '/nix/store/bxp6g57limvwiga61vdlyvhy7i8rp6wd-postgresql-14.15.drv' output check for 'lib' contains an illegal reference specifier 'man', expected store path or output name (one of [debug, dev, doc, lib, out])

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Maximilian Bosch <maximilian@mbosch.me>

(cherry picked from commit ec46a7e4dea8c568677d3d98588810bcd178f048)
Change-Id: I36e3e951c282123e780a920d5bef59de74de9fe0
2025-01-20 15:05:50 +01:00
eldritch horrors 10104b8ac1 libtuil: allow non-default-constructible types in generators
references remain forbidden because std::optional does not want to
contain them, and specializing generators to use pointers where we
can't use optionals is simply too much work for a feature we don't
even need. reference wrappers and bindings still work well enough.

Change-Id: I2e6ca74719584ce16e2357c452fdd5c5a9e23d5a
2025-01-19 16:40:26 +01:00
alois31andGerrit Code Review 98d9fd0584 Merge changes Id6d58f95,Idb1e66ae into main
* changes:
  libfetchers/mercurial: default to current revision on local repos
  libfetchers/mercurial: count revisions properly
2025-01-19 09:21:22 +00:00
Robert HensingandMaximilian Bosch 35e4f5f455 nix-util: Add concatMapStrings
(cherry picked from commit 583a852c8a6b7461dad3635337a7d2fe6f205fd3)
Change-Id: I38e9174d800339cae26bcdbebb0e27008a96839e
2025-01-19 09:55:10 +01:00
Jade Lovelace acbb3cff2d Merge remote-tracking branch 'pennae/path-access' into HEAD
This fixes a bug where flakes do not actually do purity path checks
correctly.

Tested-By: Jade Lovelace <lix@jade.fyi>
Change-Id: If7d131a8e73a5874fb15cfaa0dea3b8811ba35d2
2025-01-13 17:19:54 -08:00
Maximilian BoschandGerrit Code Review 38dd196b03 Merge "libstore: fix "illegal reference specifier 'man'"-error in postgresql_14" into main 2025-01-12 11:12:12 +00:00
Jade Lovelaceandeldritch horrors d46adb45eb tests: validate that flakes do path traversal checking
Apparently we had zero test coverage of this, let's fix that.

Change-Id: I00c906daf5acfc01913562036ca88abbf63dd3d9
2025-01-11 20:42:30 +01:00
eldritch horrorsandJade Lovelace f93af1db1f libutil: make SourcePath::path private
use canonical() to get the disk path, to_string() to get the string form.

Change-Id: I95bb6df53356f30290b487d1cca0aa2fb37249ed
2025-01-10 15:20:27 -08:00
Jade Lovelace 37e8904ba7 fix: macOS build broken on nixos-unstable
This is definitely a bug in rapidcheck but also rapidcheck is
unmaintained (author vanished) so we can't really do anything about it
on that side.

lix> FAILED: tests/unit/liblixutil-test-support.dylib.p/libutil-support_tests_hash.cc.o
lix> clang++ -Itests/unit/liblixutil-test-support.dylib.p -Itests/unit -I../tests/unit -I../tests/unit/libutil-support -I. -I.. -Ilix/libutil -Ilix/libexpr -fdiagnostics-color=always -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST -Wall -Winvalid-pch -Wextra -std=c++23 -O2 -g -fpch-instantiate-templates -include config.h -Wno-unused-parameter -Wno-deprecated-declarations -Wno-missing-field-initializers -Wimplicit-fallthrough -Werror=switch -Werror=switch-enum -Werror=unused-result -Wdeprecated-copy -Wignored-qualifiers -Werror=suggest-override -fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error -ffile-prefix-map=../lix=lix -MD -MQ tests/unit/liblixutil-test-support.dylib.p/libutil-support_tests_hash.cc.o -MF tests/unit/liblixutil-test-support.dylib.p/libutil-support_tests_hash.cc.o.d -o tests/unit/liblixutil-test-support.dylib.p/libutil-support_tests_hash.cc.o -c ../tests/unit/libutil-support/tests/hash.cc
lix> In file included from ../tests/unit/libutil-support/tests/hash.cc:3:
lix> In file included from /nix/store/k8b7wc0lkr3lqxybzv458ijddpqnzlgw-rapidcheck-0-unstable-2023-12-14-dev/include/rapidcheck.h:18:
lix> In file included from /nix/store/k8b7wc0lkr3lqxybzv458ijddpqnzlgw-rapidcheck-0-unstable-2023-12-14-dev/include/rapidcheck/Gen.h:74:
lix> /nix/store/k8b7wc0lkr3lqxybzv458ijddpqnzlgw-rapidcheck-0-unstable-2023-12-14-dev/include/rapidcheck/Gen.hpp:72:22: error: calling 'current_exception' with incomplete return type 'exception_ptr'
lix>    72 |     auto exception = std::current_exception();
lix>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
lix> /nix/store/0nhi47d5ip48wprxnava6vv973zzzndf-libcxx-19.1.5-dev/include/c++/v1/__exception/operations.h:37:41: note: 'current_exception' declared here
lix>    37 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
lix>       |                                         ^
lix> /nix/store/0nhi47d5ip48wprxnava6vv973zzzndf-libcxx-19.1.5-dev/include/c++/v1/__exception/operations.h:35:33: note: forward declaration of 'std::exception_ptr'
lix>    35 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
lix>       |                                 ^
lix> 1 error generated.

Change-Id: Id5d0c4aa8143f2469c5a636d6773a2f5a25a0268
2025-01-07 17:11:04 -08:00
piegamesandGerrit Code Review 3413ab5629 Merge "libexpr: Undeprecate overriding __findFile" into main 2025-01-07 18:39:48 +00:00
Maximilian Bosch a1c09bed7b libstore: fix "illegal reference specifier 'man'"-error in postgresql_14
Nixpkgs issues / PRs:
* https://github.com/NixOS/nixpkgs/pull/368091
* https://github.com/NixOS/nixpkgs/issues/369366

This can be triggered with the postgresql_14 derivation from nixpkgs rev
19305d94dacca226ca048b78e6de00f599c65858
(/nix/store/bxp6g57limvwiga61vdlyvhy7i8rp6wd-postgresql-14.15.drv on
x86_64-linux): for reasons unknown to me, only the `man` and `lib` outputs
are cached on cache.nixos.org:

    $ nix derivation show  /nix/store/bxp6g57limvwiga61vdlyvhy7i8rp6wd-postgresql-14.15.drv | jq '.[].outputs.[].path' -r | xargs nix path-info --store https://cache.nixos.org
    warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/bxp6g57limvwiga61vdlyvhy7i8rp6wd-postgresql-14.15.drv^*'
    don't know how to build these paths:
      /nix/store/m9vb40xxr6gckjzpfxnqcmjqsks2gx03-postgresql-14.15
      /nix/store/nm1415wa53iawar9axwxy0an6ximhayn-postgresql-14.15-dev
      /nix/store/v9vrvfhiw9gk8hj9895sb15fxvxnyylj-postgresql-14.15-debug
      /nix/store/zi12g1p99g2173i8093ixbqkfh9ng87b-postgresql-14.15-doc
    /nix/store/3i3fpz0xss9inampf51gp3pkx24ypxpj-postgresql-14.15-man
    /nix/store/db8797h2cp4rm1cnsqrf87apkkxwwdff-postgresql-14.15-lib
    error: path '/nix/store/m9vb40xxr6gckjzpfxnqcmjqsks2gx03-postgresql-14.15' does not exist in the store

Also, the derivation uses the `outputChecks` feature (and thus `__structuredAttrs`)
to make sure that e.g. the `out` output doesn't reference the `man`
output:

    __structuredAttrs = true;
    outputs = [ "out" "dev" "doc" "lib" "man" ];
    outputChecks.out.disallowedReferences = [ "dev" "doc" "man" ];

With all that in place, the following error was hit on all CppNix / Lix
versions currently supported when trying to build the derivation above:

    error: derivation contains an illegal reference specifier 'man'

The following happened here:

* The `man` & `lib` outputs were substituted at some point.
* When register outputs, the reference checks are made.
* `LocalDerivationGoal::checkOutputs` gets a map of all outputs that
  were built and are NOT already registered in the store. In the example
  above this means `out`, `dev`, `debug` and `doc`.
* `checkOutputs` tries to resolve the `man` output and fails to do so
  because it's a store-path that's already registered and thus not part
  of the map passed to `checkOutputs`.

Since the map passed to `checkOutputs` is used in various other places
that appear to assume that the paths aren't registered already, I didn't
write the already registered paths into it. Instead, I created a second
map that contains all already registered outputs and pass it as third
argument to `checkOutputs`. If the other lookups fail, this map will be
now checked before the "illegal reference specifier"-error is thrown.

This fixes the problem with `postgresql_14` for me.

Also wrote a small regression test that fails locally without the patch
in place.

Change-Id: Ieacca80c001fcfbebf6f5fe97e25c49d2724c3ff
2025-01-05 14:50:45 +01:00
eldritch horrors 8c1ece93cc libstore: fix download deadlock on interruption
in a daemon all calls to the logger can throw an Interrupted exception,
which so far has silently stopped the curl thread without notifying its
transfers and leaving them stuck as a result. ensuring that the loggers
can never throw Interrupted will have very unpleasant side-effects, and
throwing depending on context requires large amount of bookkeeping. for
now it is easiest to abort all transfers on Interrupted during cleanup.

the test for this is extremely sketchy because we want to hit a single,
very specifically chosen, loger call in TransferItem::finish(). the bug
was triggered by the `act.progress` further down from what we're aiming
for, but that one is much harder to select for than the debug log here.

fixes #613

Change-Id: Id72efa64dd30cbbf256d2ab2a328457a0b095c6a
2025-01-05 01:19:12 +01:00
piegames 539c340c66 libexpr: Undeprecate overriding __findFile
After gathering more community feedback, more non-trivial use cases for
overriding `__findFile` emerged. Unlike the use case of Tvix mentioned
in #599, these can't easily be worked around by overriding `nixPath`
instead.

This is the second fixup/partial revert for
81d5f0a7d9.
See also #599.

Change-Id: I7ca75e1a2b196c0da341969c61f4c168b5f657f9
2025-01-04 19:07:35 +01:00
Alois Wohlschlager e557f8575c libfetchers/mercurial: default to current revision on local repos
When using the Mercurial fetcher on a local repository without explicitly
specifying a branch or revision, previously always the tip of the default
branch would be fetched. This is likely unexpected by the user, and
inconsistent with the Git fetcher as well as the dirty case. To reduce
surprises and restore consistency, fetch the currently checked out revision
instead.

Change-Id: Id6d58f958b710f7a9661dc66ad4ddcb8d06a0cdd
2024-12-29 10:28:44 +01:00
Alois Wohlschlager 54fac65fca libfetchers/mercurial: count revisions properly
The Mercurial fetcher previously used the revision number supplied by Mercurial
as its revision count. This is inappropriate, as the revision number is
incremented each time a change is added to the local repository, so also
changes only reachable from other heads will be counted. For the same reason,
it will also depend on whether such changes have been fetched before from the
same repository, introducing an impurity. Instead the revisions have to be
counted explicitly, similar to the Git fetcher.

Change-Id: Idb1e66ae2fb8b05101116c815f453efd6e95b09e
2024-12-29 10:28:43 +01:00
jadeandGerrit Code Review cb44fe7c15 Merge changes Ic890f781,I77b2de10,I3202aba0,I6ddc4296,I18776984, ... into main
* changes:
  doc: fix broken table in operators list
  terminal code eaters: implement OSC
  libexpr: significantly improve error messages for bad attr paths
  tests/functional2: add terminal code eater
  tests/functional2: fix occasional pytest haunting
  attr path parser: fix bug in not rejecting empty attr paths, add unparser
2024-12-11 02:28:11 +00:00
Jade Lovelace 5530de4673 terminal code eaters: implement OSC
This is a useful piece of functionality to being able to eat URL
hyperlinks, for instance, which is a bug that Lix has while dealing with
terminal output today.

Change-Id: I77b2de107b2525cad7ea5dea28bfba2cc78b9e6d
2024-12-10 15:43:31 -08:00
Jade Lovelace faf00ad022 libexpr: significantly improve error messages for bad attr paths
This commit makes Lix include the summarized content of the value being
indexed when it is bad.

lix/lix2 » nix eval --expr '{x.y = 2;}' 'x.y.z'
error: the value being indexed in the selection path 'x.y.z' at 'x.y' should be a set but is an integer: 2

lix/lix2 » nix eval --expr '{x.y = { a = 3; };}' 'x.y.z'
error: attribute 'z' in selection path 'x.y.z' not found inside path 'x.y', whose contents are: { a = 3; }
       Did you mean a?

lix/lix2 » nix eval --expr '{x.y = { a = 3; };}' 'x.y.1'
error: the expression selected by the selection path 'x.y.1' should be a list but is a set: { a = 3; }

Change-Id: I3202aba0e437e00b4c6d3ee287a2d9a7c6892dbf
2024-12-10 15:43:31 -08:00
Jade Lovelace c0808bd855 tests/functional2: add terminal code eater
I want this for being able to write reasonable expect-test style tests
for oneliners. We will still probably want something like insta for more
complicated test cases where you actually *want* the output in a
different file, but for now this will do.

cc: https://git.lix.systems/lix-project/lix/issues/595
Change-Id: I6ddc42963cc49177762cfca206fe9a9efe1ae65d
2024-12-10 15:43:31 -08:00