Commit Graph
18746 Commits
Author SHA1 Message Date
Qyriad 03dc13a314 rust support in libutil via rust-monocrate
Co-authored-by: Jade Lovelace <jadel@mercury.com>

Change-Id: I026f271b07c9e27012f9ee1c16a2a1f4ba7f6ba3
2026-01-06 16:35:49 +01:00
Qyriad 357ee01002 build: attempt to normalize Rust handling to support static linking
Co-authored-by: Jade Lovelance <jade@lix.systems>

Change-Id: Icfd3cabaa6abc0a39f501b4b6c6b73df4cb66e6a
2026-01-06 16:35:49 +01:00
Tom Hubrecht b482ebbbc8 treewide: Rename Base to HashFormat
Co-authored-by: Yueh-Shun Li <shamrocklee@posteo.net>

`base` is ambiguous, since it's not about the digital bases, but about
the format of hashes. Base16, Base32 and Base64 are all character maps
for binary encoding.

Documentation of the format is also added.

Cherry-pick of:
https://github.com/NixOS/nix/pull/7708/commits/838c70f62116328ce01cb41a01886e4f1b9a727f
https://github.com/NixOS/nix/pull/7708/commits/5043e6cf4ea537dfe599470797c5b310ab0e94b9

Change-Id: Ief5425f3c2056a4cca75838091e4dfa5cca88872
2026-01-06 11:22:06 +00:00
Raito Bezarius b730fab286 f2/testlib/env: build initial path via build_env
`build_env` is assumed to be a certain trivial environment, e.g. a
singleton search path.

An environment in general is either empty, contain one or more search
paths separated by a colon.

It seems that the intent was to set the `build_shell` first as a
prepended path in the managed environment then extend via the
`build_env` parts.

This fixes a usecase when the `BUILD_TEST_ENV` is non-trivial.

Change-Id: If5b8ab976d867a57ce0b8d29255f64695e30a8b2
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-06 10:13:01 +00:00
piegames 9588b1ad1b libexpr/eval: Split out expression evaluation
In an attempt to slowly split up and clean up `eval.cc`

The `Expr::eval` functions contain the most important logic when needing
to touch something on the evaluator, and having them spread across the
3kloc eval.cc file was really annoying. This should help, though more
cleanups are yet to come

Change-Id: I2c2d15a024ab1ec3fc5591f628d6768341a1c8ab
2026-01-05 23:54:34 +01:00
Tom Hubrecht 7b8947ea63 tests/evalNixpkgs: Split out into its own file and set NIX_CONFIG
This adds a way to control the deprecated features that need to be
enable while evaluating the specific nixpkgs version

Change-Id: Ia2b9a29f1966d4d5f32239a36ba8270330007da9
2026-01-04 23:00:24 +00:00
Tom Hubrecht cfedc951b6 tests/nixpkgsLib: Split out into its own file and set NIX_CONFIG
This avoids rebuilding Lix each time we need to modify the lib tests
(as flake.nix stays unchanged), and adds a way to control the deprecated
features that need to be enable while evaluating the nixpkgs lib
testsuite

Change-Id: I2baa1cf90effcaf9d53337c6a7a5b24d6297178c
2026-01-04 22:52:32 +00:00
Raito Bezarius f683332bb3 f2/testlib/fixtures/nix: support flags on nix.eval
Certain evaluation requires to pass impurity arguments, add `flags`
to add more arguments to the instantiation.

Change-Id: I538ca2ff12c07cc66e845b42f81baa87f11b8f0f
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 22:09:39 +00:00
Raito Bezarius f981162bf3 f2/testlib/fixtures/env: test_root cannot be None
`test_root` can never be `None`.

Change-Id: I9ed344b55a733ad92ffa79e6799e44d97285109f
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 22:09:33 +00:00
Raito Bezarius 8b5c085aca f2/testlib/fixtures/env: home cannot be None
Is there a situation where `home` can be None? This hinders the ability
to use it quickly without type gating in the test code itself.

Change-Id: Idd739ddad67e10d6f7a6aad283c0e3b7cd08106a
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 20:40:18 +00:00
Raito Bezarius 5ae8f62146 lix/libutil/cgroup: remove trailing \n in cgroup.controllers
Otherwise, this result in debug traces with a \n cutting the list of
controllers.

Change-Id: I8aba6379d335c4edab9d9ddb3fb411813d8dc426
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 18:23:32 +00:00
Raito Bezarius 63871751ce linux/cgroups: rename cgroups to nix-build@$drvHash-$uid
The prior use of the UID is uninteresting in general for consumers who
wants to learn things about _what_ the build is, not what is the UID of
the build user running it.

Achieving this with a place where a mapping between cgroup names and
build requests are maintained is non trivial because there's no "global"
daemon that keeps track of this information and such a daemon would
require a persistent location to track this.

Rather than solving that, we will just encode the derivation hash inside
the cgroup name. Userspace can simply pull this apart and query Nix to
obtain the original corresponding derivation for more information.

This provides userspace with a way to map cgroup names to pnames for
example. Going further, if you have a map between attribute paths and
derivation hashes, you can power a database of cgroup metrics per
attribute paths by combining all of that.

In addition to this rename, we adopt a systemd-ish convention for
template units (`@`).

As a result, userspace tooling that will scrape cgroup metrics will
discover a consistent path as long as they filter out the UID part,
especially in context of Id6c458aad30eaa08c3609ac8280a7dde8e8f3cf9
change.

This problem is tracked under #1073.

Change-Id: I238d0568a3e4b1ff3057781c0639528d666b4d37
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 18:23:32 +00:00
eldritch horrors 56d6ac3114 *: wrap nlohmann exceptions at the source
nlohmann has customization points for exception throws. we can use these
instead and wrap json exceptions at the source instead of playing a game
of whack-a-mole with json errors all over the tree. since nlohmann needs
macros set to achieve this we can no longer precompile its headers *and*
must forbid including it anywhere without the proper defines or ordering
of include directives will break lix with ODR violations, if we see them
at all before we get another json-related bug report. a new lint will be
in charge of ensuring this doesn't happen. we also re-allow direct calls
to nlohmann json parsing since error handling is no longer a problem. we
will keep the wrapper for more convenient error context handling though.

fixes #1092

Change-Id: I54ecc14f5bec5e2177729b41c3703216e76cc6a3
2026-01-04 16:25:06 +00:00
Commentator2.0 8798cdcd30 tests/functional2: migrate compression-levels.sh
Change-Id: I4a0257f6c0dd7df9b0ec82d0164a3bae7e978c9c
2026-01-04 15:57:36 +01:00
Raito Bezarius e1f5a981ef libcmd/repl: rework command handler
It's 2026 and the command handler was entirely manual!

We introduce a basic command handler framework for the REPL that handles
all the previous (implicit) features reasonably well.

This also builds up the infrastructure for nicer features.

Most important feature is that now we can let external plugins adds
commands to the REPL.

There's slight REPL changes:

- errors for debugger commands are more explicit.
- short-hand have a long-hand version.
- help shows command sorted by std::map natural key sorting (based on aliases)
  while keeping the special syntaxes for the REPL language at the top.
- sections were introduced for Flakes commands.
- :st was merged into one command with an optional argument marker.

Change-Id: Ibd24f994491bf5d45d4b218fd84c0944ae5050fd
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-04 14:12:23 +01:00
piegames ee608784dd libexpr/eval: Refactor force* and eval*, introduce check*
Status quo: We have `force$Type` and `eval$Type`, both which first
produce a value and then do a type check. The type checking logic is not
consistently implemented, with lots of code duplication.
This change does:

- Introduce new `check*` functions which unify the logic (the error
handling unfortunately still needs some duplication for now)
- Make both `force*` and `eval*` use the `check*` function for the
actual type checking
- Inline and dismantle the `eval*` functions for being of little use and
little used. This makes the `ExprOp*::eval` implementations for binary
logic operators more verbose, but IMO that's a good thing: The
implementation now needs to be a lot more explicit about the
short-circuiting semantics, something which was previously hidden behind
the short-circuiting semantics of the C++ language, in a way that could
easily be overlooked and lead to confusion, which is something that
happened to me twice in a year.
- Changes `forceAttrs` and `forceList` to include the context in case
`forceValue` fails (compared to only when the type check fails). This
was done for code consistency, because I could not find any reason why
list and attrs had different semantics here than int, float and bool. So
far the visible change is minimal (see the diff on the err.exp), however
this needs vetting for potential performance regressions.

Change-Id: I33e5c706d46850c9e1126293ee01dab85ba07587
2026-01-03 22:37:20 +01:00
piegames d387c9113c libexpr: Replace StaticSymbols with NixSymbolTable
That struct has been annoying me since I've encountered it. There is no
reason for having to track all these symbols out of band in the state.

Change-Id: I5c2c0d8174af0a51f9b456cc3651d8203a406d09
2026-01-03 13:19:55 +01:00
piegames eac96ef6b5 libexpr/NixSymbolTable: Init
The names were prefixed with `sym_` to allow faithfully representing
names that start with __. (Previously the underscores were omitted, at
the cost of readability for people less familiar with the intricate
details of Nix. Is `toString` literally `toString` or is it
`__toString`? etc.) As a bonus, this allows to easily grep for any
symbol through the entire code base to find where it is used. I've done
exactly that and grouped and annotated the symbols based on their usage.

Change-Id: I230fecd9b0b18e0984ac8111c1e6381f45c5abf2
2026-01-03 13:19:55 +01:00
Rebecca Turner 80d88ce407 functional2/pyproject.toml: clarify pytest norecursedirs setting
I was pretty confused by this when I saw it, not realizing that `build`
meant `tests/functional2/build` and not the top-level Meson `build`
directory.

Change-Id: I4865f196e5bf029419c6b488e78cbfb46a6a6964
2026-01-02 10:57:43 -08:00
piegames 3917e6b63a clang-format: Raise column limit to 110
100 causes too much diff churn w.r.t. current code style

"120 cols would be nuisance for us because our two-column layout is
exactly 118 wide (not counting the line number margin)"
"Ours is exactly 118 too"

Change-Id: Ifc7f21003e1011a17a1d799afaee775aeb927fd5
2026-01-02 17:51:33 +00:00
piegames 406fde33eb clang-format: Don't compact ifs and loops onto a single line
Change-Id: I422c7ee2b9865f9354f327cd2f151a7ff6c612b1
2026-01-02 17:51:33 +00:00
piegames 9ab386880d clang-format: Reduce alignment
Change-Id: I8326dba369707bc2d736c7e44d256d037dad9614
2026-01-02 17:51:33 +00:00
eldritch horrors 7dff4efc4a testing: migrate build-remote-trustless-*
Change-Id: I3edc3fe5babc93833bfe1e7c4bdeb02dc6ac17cd
2026-01-02 15:37:09 +01:00
eldritch horrors cc5c62ad72 testing: migrate daemon-trust test
Change-Id: I65fcdbe8f9d2f5ca4654341ed4a8878ef67b841a
2026-01-02 15:37:09 +01:00
eldritch horrors 7cf17f56f4 tests/f2: add marker for tests requiring a full sandbox
Change-Id: Ia96651273510867524814c0ce10b08aa8d655181
2026-01-02 15:37:09 +01:00
eldritch horrors 8984fddeae tests/f2: add a daemon context manager to Nix
Change-Id: I9047ac8b2ab3d0ea03b245e86aab71ad0aa888a1
2026-01-02 15:37:09 +01:00
eldritch horrors f580444348 tests/f2: add async command execution
running commands in the background like this lets us test daemons.

Change-Id: I8bf687d62f084344e59f7f5a94aedde069f7f66a
2026-01-02 15:20:39 +01:00
eldritch horrors 02a9c784d5 tests/f2: make all nix.conf setting settable
Change-Id: I5a2401c961b4328b681f6f8efb708017c756dab0
2026-01-02 13:01:14 +00:00
eldritch horrors a7bd1a8a80 tests/f2: allow string lists as config values
not all values are sets. the search path for example is definitely ordered.

Change-Id: Ice94fe324319731ae3a83c757768c48576ba8b36
2026-01-02 13:01:14 +00:00
Raito Bezarius bdd6bd5e38 libcmd/repl: factor out buildWithProgressBar
This logic is used in the various build-related REPL commands and is
factored out to make it easier to write the handlers for each
build-related REPL commands.

Change-Id: Iaa18df489db75495b12924e9a76b3fff1975eb64
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-01 22:02:50 +01:00
Raito Bezarius e798115c76 libcmd/repl: factor inDebugger
The completions for debug commands is purposefully left out because it
is going to go away in the next changes.

Change-Id: Ibc78b7587de3f15857bb09a3a0732334693ad550
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-01 22:02:50 +01:00
eldritch horrors 25d8495451 packaging: fix a bunch of old-nixos leftovers
remove compatibility junk we no longer need from our packaging.

Change-Id: I4642cb354ba6c4a4b64e4730c98c2c68b03040f7
2026-01-01 18:50:19 +00:00
Qyriad 163060f4df fix Wdefaulted-function-deleted in Pos/Origin
This warning was only showing up in newer Nixpkgs but presumably
technically applies either way.

Change-Id: I9606c8ebc599538789d502a8af3388346a6a6964
2026-01-01 18:21:13 +01:00
Rebecca Turner 22b33b9d08 package.nix: set $BUILD_TEST_ENV/$BUILD_TEST_SHELL more consistently
cl/4796 introduced a bug where running `just test-functional2` would
hang forever on macOS but `meson test -C build --suite installcheck
functional2` would succeed because of a mismatch between the
`$BUILD_TEST_SHELL` environment variable and the `-Dbuild-test-shell`
build option set in `mesonFlags`.

We can move these definitions to `finalAttrs.buildTestShell` and similar
and use those values in _both_ `mesonFlags` and `env` in order to make
them consistent in all cases.

See: https://gerrit.lix.systems/c/lix/+/4796/comments/50def5b4_fa5671f2
Change-Id: If300bbe46d6269ace29b44156fb4a5196a6a6964
2025-12-30 11:34:44 -08:00
eldritch horrors 570f5b8d1f libutil: always include sys/syscall.h
linux always need this as well for capabilites.

fixes #1087

Change-Id: I57aebca5c9a381c392a87cdf4b144f1efe140d5f
2025-12-30 13:03:19 +00:00
Rebecca Turner bad5a4dcc5 gitignore subprojects/.wraplock
I'm not sure what's creating this file. But something is, so let's
ignore it.

Change-Id: If05fb0851630d827ecb7b75cf2cf0b466a6a6964
2025-12-29 21:24:05 +00:00
Commentator2.0 1c42640347 tests/functional2: fix build-shell not working properly on darwin when running tests outside of meson
Change-Id: If5068ad5460d08de69f64f924c4e86e56ac0559c
2025-12-29 21:06:28 +01:00
Commentator2.0 ac1b8e91d6 maintainers: run ruff
additionally, the issue_import has been removed, as our mirror has been
disconued

Change-Id: I8cb4c807db6c415b0fd340ead58be341a05e6a34
2025-12-29 17:55:16 +00:00
Maximilian Bosch fae54ba5a8 tests/regression-reference-checks: move to functional2
Change-Id: Iccc58b4f2341606bedcaf7ad3eda0bb7ea9d8cd7
2025-12-29 11:13:07 +01:00
Maximilian Bosch 76254181c7 tests/check-refs: move to functional2
Change-Id: Ied5a50d324ee55939886795ca29896c732c45237
2025-12-27 11:11:55 +01:00
Maximilian Bosch 8d21057d49 tests/functional2: use bash as builder
...and add both a static bash and busybox into the sandbox for building:

    $ /nix/store/fz43jxs5qfg5vldzk38y2hmrcl58qk18-busybox-1.36.1/bin/sh -c 'declare -A foo'
    /nix/store/fz43jxs5qfg5vldzk38y2hmrcl58qk18-busybox-1.36.1/bin/sh: declare: not found

The reason is that busybox's `sh` doesn't know about `declare` which
means it cannot build derivations with `__structuredAttrs = true;`.

Change-Id: Ie3ca431f862fd3e59dc649582704ae739ee5834a
2025-12-27 11:11:55 +01:00
Alois Wohlschlager fa62109164 tests/functional2: stop littering TMPDIR so much
Nearly each tests gets a fresh store (in the test root residing under TMPDIR),
which with default settings means 8 MiB of reserved space to be deleted by the
user in case of space shortages, which of course for a test suite is just
wasted. Stop doing that to considerably reduce the litter (experimentally, from
3.7 GiB to 67 MiB per run). The old functional test suite already did the same.

Change-Id: I912cdda6e796ea37cfee0b8fe0478e976a6a6964
2025-12-27 07:05:15 +01:00
eldritch horrors 1546ea0d5f tests/f2: make ManagedPath searchable
Change-Id: Idccf83a4471d76362153535125a269abbbb03c62
2025-12-26 20:56:51 +00:00
eldritch horrors 9ebe5acf39 tests/f2: don't set NIX_STORE_DIR unconditionally
this is only needed on macos, and only for tests that build anything. on
linux it can actually *break* stuff due to unfortunate interactions with
store url parsing, which is required to work for any remote build tests.

Change-Id: Ic6f7e090f15e129fc365d7edc56cdbc1a5686047
2025-12-26 20:14:39 +00:00
Steve WalkerandXYenon 4d67200b80 flake: Fix follow symlinks
Contributes towards #106.

(cherry picked from commit 24d11d22c31dd7773cbcef6ea077e62ea114e2a3)
Upstream-PR: https://github.com/NixOS/nix/pull/12286
Change-Id: I523c76e31f27fac5d73eff76b22894adcd6ee135
2025-12-26 13:01:28 +08:00
Jade LovelaceandRebecca Turner b2feecf7e7 libexpr: use MaintainCount for call depth
This was duplicate code.

Change-Id: I40697da80c3b8123c9cc3f10e5be5cc49c35629d
2025-12-23 14:18:11 -08:00
Commentator2.0 c0f177081b fix: tests/functional2/lang: remove empty file
apparently this file slipped through the code review (the actual test
does exist, no worries) but this empty file and init py exist, sitting
here empty. This commit drops them as they serve no purpose

see commit 1b7ad3a7ad

Change-Id: I64c4e03cd3ceedf9e430ae014127966bd8e4269d
2025-12-23 14:38:23 +01:00
K900 8f27c09a08 nix-eval-jobs: set meta.mainProgram
Change-Id: I77c645a4ddec4e90884942f1919a41e1e3cd66aa
2025-12-22 09:43:02 +03:00
Fiona Behrens 2b1c6b6e5e lix-doc: test: add rust tests to check suite
Add the rust tests defined in lix-doc to the check test suite.

Change-Id: I2677679d89fccef0f73fb93abf87334706492739
2025-12-21 14:11:30 +00:00
Seth FlynnandSergei Zimmerman 8eb57801a5 nix3: use pure/restricted eval for help pages
This avoids any complications that can arise from the environment
affecting evaluation of the help pages (which don't need to be calling
out to anything external anyways)

I don't think this is actively causing problems now - though it did in
Nix! - so this is largely preventative, but I don't really see a reason
why this was ever running in impure mode in the first place either

Based-on: https://github.com/NixOS/nix/pull/14086
Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
Change-Id: Ice0c760562d70c09934249edc3b767473516d372
2025-12-21 13:56:58 +00:00