Commit Graph
64 Commits
Author SHA1 Message Date
eldritch horrors cac395ffbc nej: fix some clang-tidy lints
these are really annoying when running `just lint` with nej enabled.

Change-Id: I8d35e77fe9905fdd6c28f95361f7431459079b96
2025-10-15 20:27:28 +02:00
eldritch horrors 2f16cf6014 treewide: lint syscalls for c string safety
Change-Id: I3caf476e59dcb7899ac5a3d83dfa3fb7ceaaabf0
2025-10-10 16:13:54 +00:00
eldritch horrors 80654b84b6 libexpr: de-ptr-ize Value references
thunk values are shareable, and we can represent invalid/uninitialized
values with a special bit pattern that makes no sense otherwise. there
is no need to keep allocating values on the heap, instead we can treat
values like reference-counted smart pointers to heap objects, which in
turn lets us save a lot of allocations and, ultimately, gc heap space.

compared to our baseline (main of 2025-09-27) we save 15%+ memory on a
system rebuild and 17% on nix search. eval time regresses by ~3% for a
system rebuild, while nix search is 7% faster. further optimization is
probably possible (but for now this will just have to be good enough).

Change-Id: Ib6c47acdbe2fac4f76a83c2269f16f30ef66b2e1
2025-10-05 16:23:05 +02:00
eldritch horrors db35aa753b libexpr: de-ptr-ize many Value uses
with thunk state being shareable we no longer need to worry about value
uniqueness, only about value lifetime. this means we can liberally drop
indirections and allocations, passing references instead of pointers or
using stack memory instead of gc-managed memory for some intermediates.

Change-Id: I2d48a6fd57a376d544bd9bd2d05e5420611986d1
2025-10-05 16:22:35 +02:00
eldritch horrors c7cc7d6c31 libexpr: "hide" Value union members
on its own this is not very useful, but having accessors for every value
kind is a prerequisite for doing smart things with Value than the union.
the net effect for now is only to add a few parentheses across the tree.

Change-Id: I88688ac09eb08495dad1eb221034ca540f094950
2025-09-29 15:22:41 +02:00
Maximilian BoschandJörg Thalheim d6b0b8b382 nix-eval-jobs: add --no-instantiate flag
Closes #987

The patch adds a flag `--no-instantiate` which only performs evaluation
without instantiating any derivations. Hence, GC root creation is also
skipped. To achieve that, Lix is also put in read-only mode and all
operations that require reading a derivation (e.g. constituents or
listing input derivations) are disabled fallback values are set.

This is a port of an upstream PR[1]. Given the divergence of the
codebases (different restructurings on both ends, no more CA derivations)
I decided to redo large portions from scratch instead of
cherry-picking the patches. Hence, the authorship.

Additionally the clean up of casts down to a local store are removed or
guarded behind an if, as done in the upstream PR.

[1] https://github.com/nix-community/nix-eval-jobs/pull/379

Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
Change-Id: Ib84f44e7799bc5577fd2ee98912458f16ebeab81
2025-09-16 13:03:53 +02:00
Marie Ramlow 95448347ea meson: link against libatomic if required
Some platforms like 32-Bit PowerPC need linking against libatomic.
Try to compile and link a very simple snippet of code which uses atomics
and make libatomic required if it fails.
Because we're using `dependency('atomic')`, the required meson versions
gets bumped to 1.7.0. See https://mesonbuild.com/Dependencies.html#atomic-stdatomic

Change-Id: I6a6a696471e1d352fb161c537ba9023b97c2d31e
2025-09-11 17:58:25 +00:00
Alois Wohlschlager 91bf54d726 flake: update nixpkgs input
Without https://github.com/NixOS/nixpkgs/pull/434761 evaluation of the
`nixpkgsLibTests` will fail in CI with recent enough Lix, due to reliance on
the TOML integer saturation bug.

Reported-by: Sergei Zimmerman <sergei@zimmerman.foo>

Change-Id: I6a6a6964838009d2c525f67035f84072fdfad988
2025-09-07 16:50:37 +02:00
eldritch horrors ed9a78fccd treewide: colorize logs by default
printTaggedWarning already colorized its messages. we can do the same
for most other log messages.

Change-Id: Idcd31bbf4f8d0d703395b0d2b7b9bc33264d969f
2025-08-25 21:00:15 +00:00
eldritch horrors 18285afa76 treewide: force log format strings to be literals
luckily none of these a format strings vulnerabilities because
boost::format is smart enough to throw an exception when given
fewer format string arguments than are requested by specifiers

Change-Id: I5fa78f0d1396263271f6e1dbcee9c0b2e9e18c34
2025-08-25 21:00:15 +00:00
eldritch horrors 466115c9c8 treewide: don't call Logger output functions directly
always use log macros, which also have the benefit of respecting the
verbosity setting without needing virtual function calls to read it.

Change-Id: I1c605562a53e54140724d5225e040abcf49ac996
2025-08-25 21:00:15 +00:00
eldritch horrors 3de996f521 libexpr: stringviewify some more APIs
notably this also includes the symbol table because it stores real
strings that are referenced by eval values, and an upcoming change
will make it impossible to share those strings with value strings.

Change-Id: I20a3644db8aa0850efe29630e0b73d424cb2aa56
2025-08-17 14:55:13 +02:00
eldritch horrors 8208c6ebb7 libexpr: don't read Value::string.s directly
Change-Id: I0f224459fcbff8bc53c3668bc6ea52881c453fd0
2025-08-17 12:11:19 +00:00
Linus Heckemann 52ef1181f0 build: fix cross-compilation
We need capnproto-lix to be provided by callPackage, otherwise it won't
be spliced and the same (built for the cross host platform) for both
buildInputs (correct) and nativeBuildInputs (incorrect). We thus move it
into the overlay.

A similar problem exists for the lowdown build. We thus use callPackage
to override it as well. This is horrible (especially because it means we
need to pass the enableDarwinSandbox package argument through
ourselves), but at least it builds...

Fixes: https://git.lix.systems/lix-project/lix/issues/939
Change-Id: I802152072d852903401ef701f526195aa99475f2
2025-08-08 09:48:42 +02:00
Maximilian BoschandMic92 cad6118e20 subprojects/nix-eval-jobs: don't set NIX_PATH
Corresponding upstream change: https://github.com/nix-community/nix-eval-jobs/commit/f584ae856ebab2d20115c5d1424f4d2fb9e0e6a6.patch

Co-authored-by: Mic92 <joerg@thalheim.io>
Change-Id: Id6085968f7f4ccdbc8035f608ff75420fbf962a5
2025-08-02 14:21:13 +02:00
Jade LovelaceandJade Lovelace f4a11d0336 Draft of OWNERS
Goals:
- Distribute reviews to people who can do the reviews
- Not prevent anything from getting done
- Allow giving away more commit access

Anti-goals:
- Silo people into particular areas
- Discourage contributing to any area

This was drafted by glancing at git logs. It is not likely to be very
accurate; the goal here is that we figure out a way to distribute
reviews to the right people.

Change-Id: I8be44bf7fdeca23da8099124eec7bc3a30e34627
2025-07-14 18:20:47 -07:00
K900 4bc0bdc20b nix-eval-jobs: run tests with -v
That way we get a line of output per test completed,
which makes it more obvious it's actually doing things.

Change-Id: Ifbbe8bdf64e7178d3c59349cf071eb5a9d0fcd32
2025-07-06 21:31:48 +03:00
Qyriad d8b1bb5862 build: fix Meson warning about lix-clang-tidy not having meson_version
This fixes Meson's "Project does not target a minimum version but uses
feature introduced in '1.1': meson.options file" warning.

Silly Meson.

I also added a note in the top-level meson.build to indicate
`meson_version` is specified in more than one place.

Change-Id: I2c04278bb46a562a1c96cd2e5e4d9ce59ce8e125
2025-06-09 14:10:44 +02:00
Raito BezariusandLix Systems Gerrit 4f433a6186 Merge changes I9f893374,Ief7a4756 into main
* changes:
  libexpr: rename `forceString` to `isInterpolation`
  libexpr: refactor string coercion modes
2025-05-20 20:45:21 +00:00
eldritch horrors d03be35c44 libstore: remove DrvHash::Kind
now that we have no deferred hashes (since floating ca derivations were
the only way to create them) we can safely remove this enumeration too.

Change-Id: Ic72ed90500fcee7aa5b3b5a302477fa515acf1be
2025-05-20 17:43:46 +00:00
eldritch horrors a7866d56b8 cli: remove ca support from commands
this mostly takes the form of removes feature checks and the associated
"ca derivations enabled" branches, but for the realisation info command
turns into a stub. we keep it around for compatibility, but from now on
it will always throws "ca derivations not implemented" errors when run.

Change-Id: I0abea5f76262013415330adcca2b498c6dca555b
2025-05-20 17:43:46 +00:00
Raito BezariusandPierre Bourdon dab871f129 libexpr: refactor string coercion modes
Inspired by cl/3191 and
https://git.lix.systems/delroth/lix/commit/ae0247cbb4fc739ab013dc87d02e5f3191cf25ab.

`coerceToString` takes now an enumeration that lives in `value.hh`, this
enumeration is meant to represent increasing subsets of behaviors, e.g.
any level above Strict should do what the previous levels do and extra
behavior until `ToString`, which transforms many Nix values into an
arbitrary string representation, e.g. `null` to `""`.

Change-Id: Ief7a4756e8c0660e197623efebeaf07710746ec7
Signed-off-by: Raito Bezarius <raito@lix.systems>
Co-authored-by: Pierre Bourdon <delroth@gmail.com>
2025-05-20 19:14:49 +02:00
eldritch horrors ccdd916226 libstore: de-ref {Derived,Built}Path::Built drvPath
they're no longer recursive, so this is perfectly fine.

Change-Id: If565a557f2c2074e2a96a7f89c51ff1c51146b36
2025-05-12 13:37:54 +02:00
eldritch horrors 84c1df46ea libstore: remove DerivedPathMap
single-level maps suffice now that dynamic derivations are gone.

Change-Id: If29998b104b31255292ab0c789622d7d27040f69
2025-05-12 13:37:54 +02:00
Yureka 5d0213ac55 lix-doc: remove meson pre-1.5 hacks
Change-Id: I9786d59fc849ae93643d6128ebd598d9de8637f6
Signed-off-by: Yureka <yureka@cyberchaos.dev>
2025-05-08 17:40:38 +02:00
eldritch horrors c068aeaf61 treewide: don't determinePos in autoCallFunction
add a position parameter to the autocaller instead, and pass it much
more accurate position information where we have it easily available

Change-Id: If2f1c3006ca3f2b413492842905d079a8b752542
2025-04-27 17:38:57 +00:00
eldritch horrors feebecd60b treewide: wrap std::regex_error
otherwise lix may crash when e.g. nix search receives invalid regex.
we now also give better error messages for regex errors during eval.

fixes #803

Change-Id: Icc7c578ff488ba520efac5d898572ccf4486e9a8
2025-04-24 13:48:15 +00:00
eldritch horrors 8d8bb60796 treewide: lint against non-lix exceptions
we generally do not want to catch or throw these. catching them to print
and discard is fine, tests are largely exempt, and cases in which we can
be certain where the exception came from are also fine to *catch*. we'll
try to never *throw* (or rethrow) these if possible though because doing
so will make it impossible to construct async traces for the exceptions.

Change-Id: I3b71c32ecd16afc2246c946472f5629a1fa31f2c
2025-04-06 12:14:38 +02:00
eldritch horrors dd8dbb56fc libutil: make ref casts safer
don't throw if a downcast fails, have that particular casting method
return an optional instead and check the result at the call site. we
also rename dynamic_pointer_cast to try_cast_shared for consistency.

Change-Id: I65ee0fb498b1b2b8b418935fce4358a654f984e5
2025-04-05 21:57:45 +02:00
eldritch horrors b918f1c307 tidy: add a lint to forbid nlohmann::json::parse
Change-Id: I165c7330d7ea7f17522ade8a0666d0d7d86b9d38
2025-03-27 08:56:14 +00:00
eldritch horrors 0d47773d76 treewide: handle JSON parse errors
or more accurately, wrap them in a nix::Error subclass so we can display
them properly without crashing, and add some error context if available.

fixes #642
fixes #753
fixes #759
fixes #769

Change-Id: I1aad0c0501fea83f9de3a1335eaa6adc20721616
2025-03-27 08:56:14 +00:00
eldritch horrors fc58e7b217 libexpr: mark eval error handling NeverAsync
technically it doesn't *have* to be NeverAsync, but not marking it as
such unconditionally requires templating DebugState over asyncness of
its callback (which then requires templating EvalState, which, *NO*.)

Change-Id: I4980d45b541c2e40328beac139b18c6c1ba0957c
2025-03-25 21:26:47 +01:00
eldritch horrors 8a90195cdb libexpr: don't debugThrow from async code
running a debugger is never-async since it holds an EvalState reference.

fixes #761

Change-Id: Ie1b4df6f81bb5614f11ea183eb9d1058fde73121
2025-03-25 21:23:05 +01:00
eldritch horrors 6bf8c8a4f2 nix-eval-jobs: fix a clang-tidy lint
we don't run clang-tidy on nej in ci, but it's annoying locally.

Change-Id: I6f0ae3220425ac9e9f20adaf492873f8b27a630f
2025-03-25 20:14:45 +01:00
eldritch horrors 19d7c8352e treewide: add nix::JSON
this will become a proper specialization of `nlohmann::basic_json` soon.
specialing basic_json will let us get rid of our `adl_serializer` hacks,
and it'll open the door to better enum serializing behavior without also
forcing all those who use lix as a library to set certain defines (which
may not even be possible depending on how those users use json already).

Change-Id: I5228d2b9df581a189552c993363207cfbd20f445
2025-03-23 20:42:39 +00:00
eldritch horrors a186bc5021 treewide: add json forwarder headers
this doesn't do much, just wrap a few nlohmann headers in headers of our
own (and delete includes we don't need because they're transitively seen
by other includes). doing this now will make the next change much nicer.

Change-Id: I166933102ea86bb5322ebbf9ba9411f96032a53b
2025-03-23 20:42:39 +00:00
Mario RodasandLix Systems Gerrit dc69d64bff Merge "Fix typos in documentation" into main 2025-03-18 17:32:53 +00:00
eldritch horrors 3ed99ad26e n-e-j: use full lix warning config
this would've caught the missing aio await. also disable some rather
annoying deprecation and missing initializer warnings in dev builds.

Change-Id: Ibbb9dfc67eada0e7843081b669b7c8726a02ec29
2025-03-18 09:13:11 +00:00
eldritch horrors 274933c729 n-e-j: add missing aio block on Store::queryMissing
Change-Id: I7c2350d2bf0d729d26f67a2b2181b2ebc7efb4f8
2025-03-18 09:13:11 +00:00
Mario Rodas 992866bc91 Fix typos in documentation
Change-Id: I93c3801290d03244ea8db96679d002589ae90b74
2025-03-18 04:20:00 +00:00
Maximilian Bosch 4c5efd4548 nix-eval-jobs: reenable tests, rework waitpid handling
Closes #703

The problem boils down to:

* A testcase with a segfaulting worker due to a stack overflow from the
  evaluation.

* When the controller encounters that the pipes are down, the worker's
  state is checked and a potential infrec is reported if it stopped with
  SIGSEGV.

* However, in a few cases, the worker didn't exit yet, but only had closed
  pipes (which is how the error is detected). In that case, a different
  error message is printed breaking the test.

This bug handling only affects error cases, so this race doesn't happen
on normal shutdown. To mitigate the problem a bit, the controller will
wait for a second and re-check the state of the worker process then.

While this should make the error reporting for end-users a little more
reliable, it's still no guarantee for a non-racy test. Hence, the test
asserts against both cases now and it passes if either the infrec error
or the "worker still running, but pipes are closed" error is returned.

Change-Id: Ifdc7a05bc86b6aecd5d03118d3e3ffc9affe1c5e
2025-03-14 19:50:07 +01:00
eldritch horrors 19b8502ced libstore: asyncify Store::read{,Invalid}Derivation
Change-Id: Id1af47e5f35ea81ede9c47dba8f50045a2b9bde2
2025-03-05 18:49:45 +01:00
eldritch horrors f6ce58ac72 libstore: asyncify hashDerivationModulo
Change-Id: I15285a5b833799c3e23e44229a28a7af1bcb3e8a
2025-03-05 18:49:45 +01:00
Maximilian Bosch 8cb2306138 subprojects/nix-eval-jobs: bring back constituents
Hydra used to support aggregate jobs that only succeeded when their
constituents succeed. This is still used by e.g. nixpkgs[1].

Prior art:
* https://git.lix.systems/lix-project/nix-eval-jobs/pulls/17: got ported
  into the CppNix implementation[2]
* https://github.com/nix-community/nix-eval-jobs/pull/349: implements
  glob expressions for constituents - something we needed at work. This
  also restructures the code a bit which is what I re-used here. The
  globbing is not part of this patch.

Essentially, the following things happen here (assuming `--constituents`
is set):

* Derivations with `_hydraAggregate = true;` are considered aggregates.
  These are not written to stdout when received by a worker, but stored
  until the end.

* Constituents can be drv paths or strings (that must be the `attr` of
  another job). In that case, the derivation of the aggregate job is
  rewritten so that it depends on the drv of the constituent job.

* At the very end the aggregate jobs are also written to stdout.

Additionally, this fixes one bug, the old `hydra-eval-jobs`
implementation had (and we actually hit at work):

Given the leaf jobs `packages.foo` & `packages.bar`, an aggregate job
`aggregate0` with

    _hydraAggregate = true;
    constituents = [ "packages.bar" "packages.foo" ];

and an aggregate job `aggregate1` with

    constituents = [ "aggregate0" ];

then it may happen depending on the order of evaluation that `aggregate1`
depends on the old derivation of `aggregate0` (i.e. the one without
rewritten constituents) and doesn't depend on `packages.foo` and
`packages.bar` because it was rewritten before `aggregate0` was
rewritten.

This is done in here correctly, but topologically sorting the aggregate
jobs before rewriting those.

[1] https://github.com/NixOS/nixpkgs/blob/bba6b37c9d0898867a7d9c38a1b5b77efcfb07b9/nixos/release-combined.nix#L69
[2] https://github.com/nix-community/nix-eval-jobs/pull/340

Change-Id: I5baad5e57336b4985ef8595e903814de83eb01c1
2025-02-28 20:20:42 +01:00
Maximilian Bosch 110b5ebd04 subprojects/nix-eval-jobs: clean up package metadata
* Point `meta.homepage` to the correct location
* Remove `meta.maintainers` field: the folks listed in there maintain
  the upstream package. I decided to remove it since we don't use
  `meta.maintainers` in this repository to indicate maintainership of a
  component.

Change-Id: Iec7b0eb463bc8f41907909e87ec9280c19dc86f5
2025-02-27 09:57:48 +01:00
Maximilian Bosch 5002a4a2b9 subprojects/nix-eval-jobs: fix gcroots
There's an `aio.blockOn` missing to resolve the promise. Also added a
test to verify that the GC roots are created as expected.

Change-Id: I88816cc1161372674ded15374b13323f41846453
2025-02-21 22:45:19 +01:00
Maximilian Bosch dd25c7224b subprojects/nix-eval-jobs: build tests in Hydra jobs
This exposes the `pytest` suite as a Nix build. Previously, this didn't
exist and upstream just runs this in GHA. As a result, the test was
actually broken since the assumptions about the directory structure have
changed.

To not require network access, the nixpkgs used by the Lix flake is
injected into the test. The evaluation will be done in a chroot store
since the `openStore` call would otherwise need write access to
/nix/store.

Change-Id: Ib4ff5f0319ce3aabb3b7243a076ea169e27e3533
2025-02-21 22:41:40 +01:00
jadeandGerrit Code Review e7aa55ca34 Merge "nix-eval-jobs: passthru nix" into main 2025-02-21 02:35:53 +00:00
Linus Heckemann 6eda9a95a4 nix-eval-jobs: passthru nix
Change-Id: Ied6d4abb8a67dcbe221271e6be1a14b71f9543d1
2025-02-20 22:36:53 +01:00
eldritch horrors e12deec9fb clang-tidy: add lint to forbid blocking code
Change-Id: I3df6f67f363b0a5ac014bf817e0b35fde398827f
2025-02-16 14:16:15 +00:00