Commit Graph
17329 Commits
Author SHA1 Message Date
Jade LovelaceandJade Lovelace 64e33a7e09 nix-eval-jobs: make available as a submodule for nice development usage
This is to make it much nicer to develop. We could also do this for
perl.

Change-Id: Id4cefff0c2a3658a0dacd987a9dd9ddda50765fe
2025-01-29 10:10:11 -08:00
Jade LovelaceandJade Lovelace f5fbf9bce0 perl: simplify packaging slightly
Change-Id: Ib9049642b4afd7aa529501672cfa50d983f85e4f
2025-01-29 10:10:11 -08:00
Jade LovelaceandJade Lovelace 80f814d2a1 nix-eval-jobs: integrate into lix build system and delete cruft
We don't want any of this github integration stuff since it won't do
anything, flakes don't support subdirs properly and maintaining a second
flake is pointless and annoying, and then the rest is lix formatting
standards hitting n-e-j.

Yeet!

Change-Id: Ibcd3b0182d90f727562a92c215b6061c16502554
2025-01-29 10:10:11 -08:00
Jade Lovelace 79aa6ce797 Add 'subprojects/nix-eval-jobs/' from commit 'e489d2190a9e7b6a369d3457b49ba80c93f80eae'
git-subtree-dir: subprojects/nix-eval-jobs
git-subtree-mainline: 3a41bf32a7
git-subtree-split: e489d2190a
2025-01-28 16:38:25 -08:00
Jade Lovelace 3a41bf32a7 packaging: stop including lix-clang-tidy inside main src fileset
This will avoid making lix depend on nix-eval-jobs when that is merged as well.

cc: https://git.lix.systems/lix-project/lix/issues/384
Change-Id: I4a4292948f3a225391aea2fc0d57b739d960d9e8
2025-01-28 12:44:07 -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
Jade Lovelace 750f6e327c build: add meson dep overrides for all internal libs
This allows for subprojects to depend on the internal Lix build and have
it work properly.

Change-Id: Iaf05725fb95ea8abb171c71a1b17b0062c89f548
2025-01-28 12:19:00 -08:00
Jade Lovelace e35fd30a30 build: config.h -> lix/config.h for consistency with installed headers
This is required for moving n-e-j into tree with good meson support: it
needs to be able to include `<lix/config.h>`.

Change-Id: I21f1cfa37dcdce992812c8b008df503c0fc9dea5
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 1b2e7e1ab7 repl: Improve error messages for debug commands outside of debug mode
Pretending that these commands are "unknown" when not in debug mode is
just silly.

Change-Id: I7036ae792656ef540bbad00649be4f7309944a07
2025-01-28 09:37:00 +01:00
jade e489d2190a Merge pull request 'fix for asyncized lix' (#20) from jade/async-lix into main
Reviewed-on: https://git.lix.systems/lix-project/nix-eval-jobs/pulls/20
2025-01-27 20:16:25 +00:00
Jade Lovelaceandeldritch horrors 53ce7ebc33 fix for asyncized lix 2025-01-27 20:54:38 +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
eldritch horrorsandGerrit Code Review 4af6b5ed9f Merge "libstore: remove withFramedSink exception print" into main 2025-01-26 02:08:14 +00: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 36c81668a9 libstore: remove withFramedSink exception print
it's entirely not necessary. any time we'd print this exception we're
already being called as part of stack unwinding, and printing the way
it's done here causes crashes when the error is a user pressing ^C to
abort the current operation. printing all errors (including ones that
aren't interruptions) only causes unnecessary noise in terminal logs.

fixes fj#646

Change-Id: I965ff57bc9ecf7dff35963d7056aa3a5d8a83e39
2025-01-25 18:37:16 +01:00
eldritch horrors 0ad79775b6 libstore: asyncify Store worker entry points
Change-Id: Iafa0c4093064095d196c738cc7e9ba1d8e906b8c
2025-01-25 13:01:21 +00:00
jadeandGerrit Code Review 5a41803f74 Merge "libfetchers: fix trivial switcheroo of FileInputScheme and TarballInputScheme" into main 2025-01-25 02:06:46 +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
Jade Lovelace 0acca48b83 fix: spell the perl bindings names correctly
I was wondering why there were only 59 succeeding jobs. We really need
to fix the buildbot at some point ;;

Change-Id: I81a22e32ac0dd0e105677f1b7bc064568009890d
2025-01-24 14:19:04 -08:00
jadeandGerrit Code Review 8975a49bec Merge "packaging: add pkg-config dep on kj" into main 2025-01-24 21:02:17 +00:00
Jade Lovelace 478699829a libfetchers: fix trivial switcheroo of FileInputScheme and TarballInputScheme
These are only called when registering the schemes, so reordering them
to the previous order should ensure identical behaviour.

Change-Id: I12ea0e18e6dc897a91ad20cea3a765c0b96ae85e
2025-01-24 19:18:18 +00:00
Jade Lovelace 203a48eb83 packaging: add pkg-config dep on kj
Since we include kj from a header, we need to add a dependency to force
downstreams to also have it as a declared dependency or at least put it
in their include dir paths.

Given kj is what it is, this is basically unavoidable that this
dependency is visible.

Change-Id: Ia89a90f10ad8b821260db0d7fdc47aebda44e66a
2025-01-24 11:17:40 -08:00
eldritch horrors 523bd9dce8 libexpr: asyncify EvalPaths::realiseContext
Change-Id: Ic2cf2ded1ef2a75f11112b18431df4ccfd04180f
2025-01-24 18:20:44 +01:00
eldritch horrors cb0fc85645 cli: asyncify some internal functions for later
Change-Id: I288a5179694735b23675044f319924d638617109
2025-01-24 18:20:44 +01:00
eldritch horrors ca68979174 libutil: add interruptible promise wrapping
the worker already wants to make a promise explicitly control-C-able,
and some other things in the future will want this as well. we do not
yet have the option to use the signal interfaces kj offers, but if we
can manage to remove all uses of the old-style notifiers we might get
there. until then we can at least wrap the old interfaces to be a bit
nicer to use, and eventually easier to replace with kj-provided code.

Change-Id: I079fdfe7720485820a9862c3615335d4e1df13e7
2025-01-24 13:48:44 +00: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
eldritch horrors 0275b9a92f async: open the floodgates.
this will let us add AsyncIoRoots to the toplevel objects and functions.
eventually we'll get rid of all offloading again byt covering the entire
space between main() and the worker entry points with promises. it won't
be a quick and easy journey; we have somewhere around 200 functions that
must be converted to async code, and some building blocks that are fully
incompatible with event loops on their own. this ranges from simple bits
like thread pools (which we can wrap in promise-fulfiller pairs), bigger
bits like the curl wrapper (which we can make async, but not easily), or
even impossible bits (like the libarchive wrapper, which can't be turned
into async code at all. not to worry though, we have *plans* for those.)

Change-Id: I95b91b0545659ece4ec1b85214df1ce2f1bc0164
2025-01-24 13:48:44 +00:00
eldritch horrors b03195ab00 libutil: add async blocking and offloading to other threads
evaluating promise-based things requires an event loop. we can't thread
the event loop through the code as is because that'd touch almost every
function signature. we can't declare local loops because loops must not
nest. we can't use thread-local loops because non-continuation waits on
promises are not allowed within a promise evaluation. spawning a thread
every time is the only real option besides a shared runner thread pool.

Change-Id: I763c1b2d655cee01f991a8675f3a643b6fe91363
2025-01-24 13:48:44 +00:00
eldritch horrors bd93b2750a libutil: add Async{Context,IoRoot} to hide kj::AsyncIoContext
mostly we want to hide the wait scope since using a wait scope inside a
promise is not allowed. we'll use this to push the AsyncIoContext up to
the main() function as time passes, and presumably turn a lot of things
that are regular synchronous code right now into promises as we proceed

Change-Id: Ib972568a306b540b573e946492830ed5a15c485e
2025-01-24 13:48:44 +00:00
Linus HeckemannandGerrit Code Review ae81f44b86 Merge "nar-info: use string views for construction" into main 2025-01-24 08:11:28 +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
eldritch horrors 963b687443 libstore: asyncize remainders of worker code
these don't have to be async yet, but eventually they will.

Change-Id: I475ae02172ff53e826e09b63eb47e3dd0f8e78b7
2025-01-23 18:01:23 +00:00
eldritch horrors 020ea8c8fc libutil: add async base header
currently this header only contains TRY_AWAIT, and it's public version
LIX_TRY_AWAIT. the former is for use in our cpp files only, the latter
may be used anywhere. we don't expose TRY_AWAIT unconditionally due to
it not being namespaced according to usual rules of macro naming, i.e.
exposing it may litter user macro namespaces unnecessarily. hiding our
internal version is achieved using a new define that's not set through
pkg-config or other means. (we could also add a private header that we
simply do not install, but that gets rather messy rather very quickly)

Change-Id: I372b1a414487dd03cfbfc620b3148a6c6e56ca3f
2025-01-23 17:21:23 +00: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
eldritch horrors 25fe101102 libutil: add result::current_exception()
c++ does not support result types very well. kj promises do not support
exceptions very well, but result types are fine. since we need to treat
errors like values to be compatible with kj we are forced to use result
types. creating a failure result from the current exception is our most
common error return right now, so let's have a shorthand for this. it'd
be nice to also drop the try-catch wrapper somehow, but since macros do
not work with clang-format (macro-wrapped bodies confuse the formatter,
trashing the entire file) and clang plugins tie us even harder to clang
we'll probably have to keep the wrappers (until we can rewrite in rust)

Change-Id: I463dd0a4ebedb79a5335c92251c4d12b9d64b401
2025-01-23 15:53:50 +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
Linus Heckemann 8cf4c2c9e0 nar-info: use string views for construction
This doesn't break any usages within lix, and allows avoiding copying
in some calls. The constructor already copies bits and pieces of the
data passed in.

Change-Id: Iea39906ca430195da4c509dd8a0a54d49b46ca4f
2025-01-23 11:21:24 +00: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 cb19e24a1d Merge "fix(gc): log sudden "path in use" exceptions and recover during GC gracefully" into main 2025-01-23 06:03:33 +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 9efa32d651 libexpr: Refactor ExprState::pushExpr
It has been renamed to `emplaceExpr` to be more consistent with the fact
that it actually creates the expression pointer. Moreover, `pushExpr`
has been added which directly takes a `unique_ptr<Expr>`.

All manual calls to `exprs.emplace_back` have been removed and replaced
with `pushExpr`, and `exprs` is now a protected field. This allows for
enforcing invariants and modifying state within `pushExpr`.

Change-Id: I995f0bdc1c090cf78080c9f0b7737e2be359b3e4
2025-01-21 11:35:51 +01: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 5f1782a938 libstore: remove HttpBinaryCacheStore::getFileContents
the default implementation using getFile does exactly the same thing,
unless the thing being downloaded goes away immediately before we try
to resume a partial download. that's best treated as a different kind
of error though because the target did exist the first time we asked.

Change-Id: Ic0c046bdcd9d9751c6ba78167c68a38d0d2739e9
2025-01-20 23:07:44 +01:00