Commit Graph
17986 Commits
Author SHA1 Message Date
eldritch horrors cf93814ca5 libutil: remove unused FdSource::read
Change-Id: Ie08c9a80dc029ae4e5eb91b09db81166c8a627a3
2025-06-06 18:09:46 +02:00
eldritch horrors 8c30a165e5 libutil: remove long-dead create_coro_gc_hook
Change-Id: Ia37c6a5401dbe6453bfdfa733da5237d2c2dc819
2025-06-06 18:09:46 +02:00
eldritch horrors dd31a23c31 libstore: add worker serializer for SubstitutablePathInfo
the test is for the map that usually wraps it though because it's the
bit we're interested in replacing, and it has custom serializer code.

Change-Id: If77a236dfca738b646ed2b7a5c65515dad6b7295
2025-06-06 18:09:46 +02:00
eldritch horrors fca0a30470 libstore: remove pre-2.18 protocols
the old protocols are largely untested, mostly unused, and have design
problems that make the RPC transition a lot harder, if not impossible.
in theory we could ship a transparent protocol-converting proxy that'd
isolate the daemon itself from old protocol versions, but that's a lot
of code to maintain for presumably little gain or even no gain at all.

Change-Id: I4c3f3bb34d39044f6aeb07c10caaf13b8340a220
2025-06-02 22:43:24 +00:00
piegames 019b17f4e9 tests/functional2/lang: Migrate trivial eval-okay tests
Change-Id: I07a2e70eacd3d7bca3fc4d7074b9892b9ea35346
2025-06-02 21:52:34 +02:00
piegames 9673c6480a tests/functional2/lang: Migrate trivial parse-okay tests
Change-Id: I11b6ea26b7dc6bcf8250c04d3c97ded452dd1eda
2025-06-02 21:52:34 +02:00
piegames 0219434ae9 tests/functional2/lang: Migrate trivial parse-fail tests
Change-Id: If6cd6a2432c081e4b918f480ce3be0da3e691d40
2025-06-02 21:52:34 +02:00
piegames 63edb9c678 tests/functional2/lang: Migrate trivial eval-fail tests
All changes are uniform and done with the same script, so checking only
some should suffice. For that reason, any tests involving multiple files
or custom CLI flags are not included in this commit.

Change-Id: Ib2d0e08937b56e241d99771a58aad34ed3ad308a
2025-06-02 21:52:34 +02:00
piegames a7e5ff0070 tests/functional2: Make symlink handling less confusing
The current `RelativeTo` design is both more complex and more confusing
than necessary. Its four variants are now reduced to only two. They are
now also represented as different classes, to better communicate the
difference in semantics and also intent.

Change-Id: Ia60fc7a2dfa0f62bdef90dde347fd8603fd3fbf9
2025-06-02 21:52:34 +02:00
Linus Heckemann e753fcb414 gc: delay throwing error until cleanup is complete
Previously, paths not being deleted by gcDeleteSpecific would result in
(a) hardlinks not being cleaned up, and
(b) statistics not being reported correctly.

By throwing the error later, we fix both of these problems.

Change-Id: I8019f3e10d9f22e81ea87bb26b77f04ebc888a19
2025-06-02 20:05:32 +02:00
Commentator2.0 530b40ac8e tests/functional2: fix overly broad xfail test passing
By default, xfail tests will always "pass" when the test fails,
disrecsarding any restrictions put on them via their parameters.

By enabling the `xfail_strict` option, xfails won't pass anymore when
the failstate is different from what is described in their parameters.

Change-Id: Ifea6e27d716d91f60210e6ba24175074fa39c304
2025-06-02 16:33:46 +02:00
Victor Fuentes ab1e58e948 feat(nix store ls): support reading nar listings from binary cache
Remote binary caches support `write-nar-listing` options where they create a `HASH.ls` file for quick indexing without having to download the nar.
This commit makes experimental `nix store ls` attempt to read these files instead of downloading the full nar.

The difference is very obvious with large packages like stellarium:

nix store ls --store "https://cache.nixos.org" /nix/store/ijpvwgs9zamqaax5dy2cd0kxgz7lr7an-stellarium-25.1 -R

Change-Id: I6a37e0788b3a91c319331a8de69c51daf3efa955
2025-06-01 22:47:11 -07:00
Commentator2.0 8c528529fc docs/functional2: overhaul documentation
Add Documentation for usage and development within functional2
including common fixtures and where to find them

This is done to make the migration from functional easier and give devs
a reference for how one writes tests

Change-Id: I6ee73e654d245fd4ad43e495d1172e406313cb23
2025-06-01 20:19:37 +02:00
Commentator2.0 c63ba3c485 tests/functional2/lang: migrated first tests
Change-Id: I4b5755a63d9454db20f63f751f5f33564a2ee5be
2025-06-01 20:19:37 +02:00
Commentator2.0 f7914e89e6 tests/functional2: add framework for lang tests
This creates a framework similar to the old lang.sh from functional.
Some notable changes:
- instead of having a .flags file, a test.toml can declare flags
- additionally the test.toml can also declare extra files and multiple
runners for the given input file.
- there won't be any old tests hanging around anymore which weren't
deleted properly in the installation
- all files for a single test are defined decleratively and there won't
be any residues

Tests can be placed within the functional2/lang folder
most migrations should be rather clean

Implements: #825

Change-Id: I5f9149903ec5b078008969a4ae77305417c11475
2025-06-01 20:19:37 +02:00
Commentator2.0 696efc58e7 tests/functional2: mark tests as skipped when snapshot updates golden files
Currently, tests are marked as "passed" when golden files are updated.
With this change, the tests are marked as skipped instead.

Additionally finally introduces tests to check if the snapshot behaves
as expected

Change-Id: I438eed70e0b94d561e99cc1e0363092809da827e
2025-06-01 20:19:37 +02:00
Commentator2.0 761a4f544c tests/functional2: add utils for files and paths; add pytest_command fixture
Add utils for general-use functions and paths

Additionally introduces a pytest_command fixture, which creates a
testing environment for pytest within the tmp_path. This allows for
encapsulated testing of our frameworks (i.e. snapshot, lang etc)

Change-Id: Ic0a5bc4bfc0b0bfbac15bc51dd4a94fae6ee6f26
2025-06-01 20:19:37 +02:00
Commentator2.0 80ea9c682a tests/functional2/files: allow absolute paths as origin
allow to pass absolute paths or similar Path entries to declaration of
files instead of just string paths relative to the requesting file

Change-Id: I616da6abbb73d1d63ead370e9ae37a401d85f42d
2025-06-01 20:19:37 +02:00
Commentator2.0 5a6bb0fb50 tests/functional2: add runner to justfile
Due to how meson works with the current justfile options, it is not
possible to pass additional arguments into the functional2 test
suit/pytest.
Due to that, it isn't possilbe to narrow down what tests to execute or
add output options or similar.

This commit adds an additional recipe, calling pytest directly ensuring
arguments are handed through

Change-Id: I3748d1cd5fddc16b11fff11c0f1a77195e37c837
2025-06-01 20:19:37 +02:00
Alois Wohlschlager 4505bfac8e libstore/gc: fix auto-GC blocking indefinitely during evaluation
The first auto-GC request would not be registered as a waiter due to a logic
error. As a result, if that request was synchronous (as happens during
evaluation) it would be stuck forever waiting on a promise that will never be
fulfilled.
Register also the first request properly so that it is notified and unblocked
again when the GC has finished. Also add a test verifying that auto-GC
triggering during evaluation will not get stuck.

Fixes: https://git.lix.systems/lix-project/lix/issues/844
Change-Id: I157afdc737415261e48d6d01d46c586a2927a1ad
2025-06-01 18:59:23 +02:00
Nikodem Rabuliński 3815dd5e64 tests/functional2/commands: fix failure with auto-allocate-uids
The custom subcommand test fixture used to replace the environment
with PATH prepended with the directory of the subcommand.
This caused the tests to fail on darwin with auto-allocate-uids
enabled, as the dynamic users aren't added to the user database
inside the sandbox, as opposed to linux.
Other environments were unaffected because the build user is a real user
with a database entry and HOME set.

Update the environment instead, also preserving hermetic env
created earlier by NixCommand constructor.

Change-Id: I7e59fd69ff13d1d395316d857b63a356e1648159
2025-05-30 09:07:41 +02:00
0c2ced0224 feat(nix-instantiate): add --raw flag
The experimental `nix eval` command already supports a `--raw` flag.
This commit implements the same flag for the stable nix-instantiate command.

Until now instructions and scripts that didn't want to rely on experimental
features had to use workarounds such as:

    nix-instantiate --eval <something> | tr -d \"

(which also undesirably also removes double quotation marks within the string), or

    nix-instantiate --eval <something> | jq -j

(which undesirably depends on another package).

Co-authored-by: Raito Bezarius <raito@lix.systems>
Co-authored-by: Silvan Mosberger <silvan.mosberger@tweag.io>
Change-Id: Iced9a80ee7edd60af2385c5193485f1774175339
2025-05-29 15:25:12 +02:00
Tom Hubrecht e468102508 fix: Consider fetchGit locked when narHash is present
`fetchGit` has been modified a long time ago to use fetchTree, however,
we don't care about `lastModified` because we are not in a flake
context, this hack introduces a `git-locked` type of input that only
cares about `narHash` being present. This is needed to avoid fetching
the remote repo each time `fetchGit` is evaluated whith the result
present in the store.

Change-Id: I521c6fcccf8cf12945594f205d7fd4c8c2cf89e9
2025-05-28 22:24:23 +00:00
Raito Bezarius b792279780 tests/functional/lang: update error path locations
The coerce integer feature was not rebased before merge and we do not
have a merge queue, hence, after merge, the HEAD was in a broken state.

We take a commitment to invest into a merge queue now and do a fixup
here.

Change-Id: Ied9410690b542359859ab5f597f22ebceb857305
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-05-28 22:29:04 +02:00
Tom HubrechtandLix Systems Gerrit 0d72109ada Merge "libfetchers: factorize inputFromAttrs" into main 2025-05-28 19:54:37 +00:00
Raito BezariusandLix Systems Gerrit 316aa591ac Merge "libexpr: coerce integers under the XP feature coerce-integers" into main 2025-05-28 19:39:59 +00:00
71rdandLix Systems Gerrit fda93021ca Merge "libutil/args: fix crash when NIX_GET_COMPLETIONS is not a number" into main 2025-05-27 23:31:40 +00:00
git@71rd.net 0e115a4828 libutil/args: fix crash when NIX_GET_COMPLETIONS is not a number
When assigning an a value to NIX_GET_COMPLETIONS that could not be
parsed as an integer lix would just crash, as the value was directly
passed to stoi, without handling the return value.
This change switches the parsing to use string2Int and throws an
exception if the return value is empty.

The behaviour of lix is slightly changed through, as the value of the
variable was previously parsed to an int and then assigned to a variable
of size_t.
This change in behaviour can only be observed in cases where the
value of NIX_GET_COMPLETIONS is chosen so when it overflows it would
be valid index of the provided arguments again.

Through this change the variable is parsed as a size_t and negative
values are rejected.

Change-Id: Idf7c5740274c6e07d5bb13d7e2ed32764bfc27f8
2025-05-27 22:20:22 +00:00
71rdandLix Systems Gerrit 8525345fd1 Merge "libutil/args: dont crash completion when receiving incorrect number of arguments" into main 2025-05-27 17:31:06 +00:00
git@71rd.net 20d50b049d libutil/args: dont crash completion when receiving incorrect number of arguments
When using completion, the number of the word for which the shell
requests completion is provided in the environment variable
`NIX_GET_COMPLETIONS`. When the number smaller than 1 is or larger
than the number of arguments nix coredumps as a assert is violated.

This change removes the assert and instead throws an exception informing
the user that their autocomplete is most likely misconfigured.

Change-Id: I821719e470e576b6f63c06beb097338b53d183e0
2025-05-27 14:36:51 +00:00
Raito Bezarius 1e40171ea4 libexpr: coerce integers under the XP feature coerce-integers
This introduces a new (demanded?) feature for coercing integers in
interpolation arguments under the experimental feature
`coerce-integers`.

This feature is being introduced behind an *experimental feature flag*
due to the cautious approach we're taking. The codebase has a track
record of revealing unexpected behaviors, often in subtle ways, so we
want to give this sufficient time and exposure before making it stable.

To remove the experimental flag, we want to see **at least two releases
or six months of real-world usage -- whichever is longer** -- that
demonstrate strong confidence the feature doesn't introduce regressions
or unintended side effects. If that level of confidence is reached,
we'll proceed to stabilize it.

Change-Id: I825904719eeba8f0e2a93cd6b93cfe6cebd7d827
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-05-27 11:42:53 +02:00
71rdandLix Systems Gerrit e27c86ad12 Merge "main: avoid crashing when aborting completions" into main 2025-05-26 21:34:24 +00:00
71rdandLix Systems Gerrit be138a555f Merge "main: fix complete outputting doc page" into main 2025-05-26 21:33:41 +00:00
71rdandLix Systems Gerrit fb084e30c5 Merge "docs: add missing setup step for building in shell" into main 2025-05-26 18:15:50 +00:00
git@71rd.net e360cf3a28 main: avoid crashing when aborting completions
To print completions lix created a Finally object containing the actual function,
so the function was executed by the destructor of the class.
Unfortunately  aborting autocomplete by sending a SIGINT signal
(i.E. by pressing C-c) leads to an exception, that finally cant return or eat,
when throwing its own exception.

To avoid crashing when using auto complete let the function "mainWrapped" execute
the autocomplete code directly before returning.
This avoids creating the "Finally" object and instead moves the codeblock next to
the check to return when "arg.completions" is called.

Change-Id: Id333a60ad43c6095e8866f6953af78d51fd43b64
2025-05-26 16:44:44 +00:00
git@71rd.net 826cfbc41b main: fix complete outputting doc page
When calling completion on a nix command containing the word
"--help" nix would first return the entire help page for the
command and then the result of the completion resulting in unusable
output.

By moving the check whether to return when completions were requested
before the check whether help was requested wrappedMain returns
without wrongly printing documentation.

Change-Id: Iedb37434a3ff101f15985319a9a3bcb3f8195796
2025-05-26 16:30:15 +00:00
Linus HeckemannandLix Systems Gerrit 6c773375c2 Merge "doc: explain runtime and indirect roots, merge roots section into GC section" into main 2025-05-26 15:34:25 +00:00
git@71rd.net aa8e07d8b6 docs: add missing setup step for building in shell
Change-Id: Ia02e4c994b13defbefb46b0cf21e1254d13166d9
2025-05-25 20:49:24 +00:00
Commentator2.0 dbff52bfbc tests/functional2: improve commands ux
with_env now overrides the environment, similar to with_stdin
an additional function update_env was created to mirror the prior
functionality of with_env, updating the env

This was changed as previously it was impossible to delete variables
from the env

replaced the code of .ok() with a call to .expect, to remove the code
duplication

Change-Id: I83933893c7f2ccfdc7bd4933b7592b475c435e76
2025-05-25 16:21:28 +02:00
Commentator2.0 438cb4cb31 tests/functional2: move commands to own lib file
Currently the Command and CommandResult classes are mixed into the nix
fixture file.
This commit moves them out into their own lib file, to make it more
obvious that they can be used standalone for other applications too

Additionally improved documentation of said classes
and bumped log level of stdout and err on unexpected exitcodes, as it is
within an error context

Change-Id: If2d554acde86fd54f2445fc46453f06923af5fe9
2025-05-24 14:38:56 +02:00
piegamesandLix Systems Gerrit 9cbffbbbb9 Merge "tests/functional/lang: Clean up lib.nix" into main 2025-05-24 10:57:02 +00:00
piegames 1071643259 tests/functional/lang: Clean up lib.nix
That file was written once in 2008 and never updated since, and let's
just say that a lot of things have changed since

Change-Id: I66b0c87ecbba6ca653470966c9514edb21882ca3
2025-05-24 08:49:09 +02:00
Linus HeckemannandLix Systems Gerrit bbc9aaf8a6 Merge "build: disable LTO on Darwin" into main 2025-05-23 12:27:04 +00:00
Tom Hubrecht 76524b92ee libfetchers: factorize inputFromAttrs
Each `inputFromAttrs` is roughly the same function in each class, we
check that the attributes given are correct (in term of keys and other
types) then we coppy the attributes. Instead of having the same code
copied in 10 places, set it in the parent class and specify what is
specific per child class.

Change-Id: If9aecb76cff1e28a1ef6668d83d825686cce8353
2025-05-22 14:00:19 +02:00
Commentator2.0 5daddad39a tests/functional2: Fix pytest garbage collection
Due to nix-store making its paths read-only, pytest was unable to remove
the test files and hence the entire temporary directory, screaming all
over the place in stderr about that, getting worse for each test run.

By making the nix fixture first yield nix and then, after the test
finished running, changing the file permissions to include read on all
files and directories within the temp folder, pytest is able to properly
remove old test runs again

Additionally added more clear instructions for file deletion to the
pytest configuration

Change-Id: Ia7e3d195665968ac80a57d0e525691b28be7f503
2025-05-22 13:51:23 +02:00
Linus Heckemann da94e860dd build: disable LTO on Darwin
Due to https://git.lix.systems/lix-project/lix/issues/832 , Lix 2.93.0
fails to build on Darwin without overrides. Until the root cause has
been determined and fixed, build without LTO.

Change-Id: I4db5eb294d8f19e5a366b1e19efa5a327b3e2e78
2025-05-22 13:34:30 +02:00
piegames 5d49e26f71 tests/functional/lang: Remove disabled tail-call test
It was introduced back in 2013, was disabled in 2014 again for dubious
reasons and according to horrors is unsound anyways and can never really
work.

It was the only disabled test, so I removed the "infrastructure" for
that in the test runner as well. functional2/lang will have much better
ways for skipping tests anyways

Change-Id: Icb8697fb85221e3206fb64cb917c03607ef278a7
2025-05-22 01:48:34 +02:00
piegames 76d6b51f5c tests/functional/lang: Don't pipe input into stdin
Back in the days, this used to be the modus operandi, but then, still
many but less years ago, Eelco came along and changed it to passing in
the actual file. Of course, no motivation was provided, and it was only
done on half of the test runners for some reason, leaving us to wonder
what the true intentions of this code are …

Anyways, with this commit now everything standardises on passing in the
file by path instead of via stdin. Motivation:

- We need to `sed` out the path anyways for various other reasons,
including import tests and path value tests
- Given that, the presumed primary motivation for using stdin in the
first place becomes moot
- Bonus points for giving better error messages, especially in tests
that involve multiple input files

Change-Id: Ic6de1ec24f4c4d3c05e33d1ee053614784677513
2025-05-22 01:48:34 +02:00
piegamesandLix Systems Gerrit f92199d651 Merge changes I186b0edb,Ie394691b into main
* changes:
  tests/functional/lang: Don't use tabs for indentation
  tests/functional/lang: Change base path to the lang directory
2025-05-21 22:17:42 +00:00
Commentator2.0andLix Systems Gerrit dbfb85ab18 Merge "tests/functional2: add snapshot fixture" into main 2025-05-21 19:29:31 +00:00