Commit Graph
18654 Commits
Author SHA1 Message Date
Raito Bezarius 24df5d98f9 lix/libstore/linux: rename cgroup with drvHash
Change-Id: I238d0568a3e4b1ff3057781c0639528d666b4d37
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-12-12 01:30:44 +01:00
eldritch horrors 286f540ce8 nix/daemon: socket-activate single connections
the cgroups experimental feature does not work properly without this
because we do not stop subdaemons when the main daemon is shut down.
systemd needs the assigned cgroups to be empty to restart the daemon
and thus cannot cleanly restart the daemon if any connections exist.
starting a fresh unit for each connection creates a new cgroup every
time instead of sharing any delegations and thus solves the problem.

fixes #1030

Change-Id: Id6c458aad30eaa08c3609ac8280a7dde8e8f3cf9
2025-12-06 19:44:28 +01:00
eldritch horrors acb85fb910 libcmd: add raw arg access to legacy commands
we'll need this to modify argv for socket-activated daemons. this is our
replacement for the old savedArgv mechanism that was unscoped and fucky.

Change-Id: Ie048eb8ea99f1c9cd627a051292c836c83197068
2025-12-06 19:44:28 +01:00
eldritch horrors 775832d7f0 libcmd: remove unused savedArgv
this was only used in the pre-exec daemon days.

Change-Id: I3bbb113f9940e6980f01af60e6614a9656b0fd03
2025-12-06 19:44:28 +01:00
eldritch horrors 6cec6929b2 nix/daemon: remove settings copy from parent
the parent daemon does not change any settings before starting a child,
so there's nothing we may want to change that is not already set by the
config file. this also doesn't prevent changed of the config file being
applied to daemons where we do not expect it since it'll only restore a
setting to the parents' value if the child also has an override for it.

Change-Id: Ic5a9ef13458c103ec9979cb187ba8d3ce5e1e719
2025-12-06 19:44:28 +01:00
Maximilian Bosch 74f5d66b39 perl: unset NDEBUG after loading Perl headers
Otherwise, loading Perl bindings fails early with[1]

    undefined symbol: Perl_pad_sv at /nix/store/h2jsb5i4yfblr2f3ac2c7zpmlmj7zjym-perl-5.40.0/lib/perl5/5.40.0/XSLoader.pm line 94

Apparently, it's expected behavior by Perl that this symbol only exists
with `DEBUGGING` being set, hence it's used by the headers. However,
`pkgs.perl` from nixpkgs is apparently not built with `-DDEBUGGING`
causing this error.

Now, `NDEBUG` is manually unset after loading the Perl
headers rather than setting `DEBUGGING` causing the error mentioned
above.

I confirmed that this not only fixes the problem described above, but
running the Hydra tests with

    diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
    index dfdd64d28..14788266c 100644
    --- a/perl/lib/Nix/Store.xs
    +++ b/perl/lib/Nix/Store.xs
    @@ -27,6 +27,7 @@ using namespace nix;

     static AsyncIoRoot & aio()
     {
    +assert(false);
	 static thread_local AsyncIoRoot root;
	 return root;
     }

still results in assertion errors.

Finally, added a small install-check that importing `Nix::Store` works
fine.

[1] https://git.lix.systems/lix-project/hydra/issues/69

Change-Id: I58521777eb0f94b766a9813aa4bbd06f9052bd35
2025-12-05 18:36:35 +01:00
Commentator2.0 07dccd67d6 treefmt/ruff: remove EM rules as they cause unnecessary work with no real upside
As discussed in the F2 matrix channel, not being able to put the error
message inside of the thrown exception just results in one assigning an
additional variable to immediatly throw it. The original reason for
these rules to exist are that the message isn't printed twice, though
the line above the thrown exception is printed anyways in the
stacktrace, so we still get the error message twice but now with
additional work.

Hence this commit removes the said rules

Change-Id: I0b37c0b0861334703a5772c36353d31441f19dcd
2025-12-05 13:45:59 +00:00
Commentator2.0 f65b83df3b treefmt/ruff: extract ruff config from f2 to global state
So far, our ruff config was confined to the f2 package. This meant, that
when one added additional paths to the ruff formatter, those wouldn't
get the same rules applied as f2, resulting in inconsistent styling
thoughout the project.

Due to how configs are resolved, only the "closesed" pyproject toml is
considered. This means, we need to tell f2 to extend its configuration
with the base level one. Though no change is required for other parts of
the project, as long as they don't have their own pyproject.toml

Change-Id: I145c764e7b850194020b5560e1025f4aa80411ae
2025-12-05 13:45:47 +00:00
Commentator2.0andQyriad 85443e0fd8 tests/functional2: migrate completions.sh
Change-Id: I186a1ddd8d56386f9d1308430f517cdec483af14
2025-12-05 13:33:20 +01:00
Raito Bezarius 1e98c01912 libutil/users: support service cache directories
Nix daemon runs in a service context, usually with systemd.

If the Nix daemon unit adds `[Service] CacheDirectory=nix-daemon`, it should
successfully use `/var/cache/nix-daemon` automatically.

Instead, it uses `/root/.cache` right now, which is really bad.

By default, we add `[Service] CacheDirectory=nix` now which means that
caches are moved into `/var/cache/nix`.

Fixes #634.

Change-Id: I854b1045bfdce8f60110aea70bda1bf6657dfd7b
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-12-05 00:14:42 +01:00
Commentator2.0 8f5bf1e905 libstore/machines: add enable flag for toml machines
Provide a way to statically disable a machine.
This is fully static and not dynamic.

Change-Id: I394433ad533bca5dbf6a2f7fea22b8aa0f5aad3f
2025-12-04 12:11:23 +01:00
Commentator2.0andQyriad 3fcfedc216 libstore/machines: add toml parser
implements #854

Co-authored-by: Qyriad <qyriad@qyriad.me>
Change-Id: I958d082ccdf03179b35d5ab8a810ebafcff3b6c5
2025-12-03 21:36:53 +01:00
Commentator2.0 23c341d76d libstore/machines: move legacy parser to own namespace
Change-Id: I4ecf1e56e713cd32b6a443f9d195c1beb0cb2f7f
2025-12-03 20:10:35 +01:00
Commentator2.0 d0a655fc8a libstore/machines: refactor machine parsing
Change-Id: I216592e089328d68f9ca48203a19fd964356249b
2025-12-03 20:10:35 +01:00
Alois Wohlschlager 00dfcc81b4 doc: fix substitution with mdbook 0.4
Recently, in 54df89f601, support for mdbook 0.5
was introduced, including some logic to handle the `sections` -> `items`
rename. However, compatibility with 0.4's `sections` was only kept on the read
path, while writing 0.5's `items` unconditionally, which ends up in the bit
bucket on 0.4, effectively disabling substitution fully and leaving the include
directives in the final documentation. Restore writing into the `sections` when
they were there so that substitution works again.

Change-Id: Idd4d7653012660f3f7fc27f81f29b82d6a6a6964
2025-12-03 10:01:55 +00:00
Commentator2.0 8353b3cc6a tests/functional2: fix non-working failsafe and resulting warning
Silly me forgot to add the dependency responsible for handling
`@pytest.mark.timeout` failsafes to kill a test if it takes too long,
which results in a warning when running f2.
This commit adds the required dependency and hence removes the warning

Change-Id: I281cad05bb0cf50208f72080cb2bfd8cbfb09d0c
2025-12-02 19:52:38 +00:00
Zoe Zuser 06f987fb0c meson: fix libstore.pc
typo of aws-cpp-sdk-transfer as aws-cpp-std-transfer prevents linking
against lix

Change-Id: Id847eab2601698696030d31fcd51288aa5f3d274
2025-12-02 10:45:50 +00:00
K900 716a885def nix3: show logs by default
That's it, that's the change.

Change-Id: I00c55265ee0e9982b91626601236fe238edf480c
2025-12-02 01:02:44 +00:00
eldritch horrors 2ae74802c4 libexpr: AST-dump non-utf8 strings as byte arrays
our strings need not be utf8. json requires utf. -sigh-

fixes #1052

Change-Id: I50ecd9882252370bb81845b099b11a7190475d48
2025-12-01 21:11:25 +01:00
Justin ! 084a8c3711 libexpr: add a deprecation warning for builtins.importNative
First step for: https://git.lix.systems/lix-project/lix/issues/795

Change-Id: If375723c6829f4fb9c7c1c5bff6be3c9e164c2be
2025-12-01 13:02:13 -05:00
K900 97dd9ba1e2 flake: minimal fix for lowdown override failing on nixpkgs master
All of this can be yeeted once 25.05 is gone.

Change-Id: Id8d9528cf5d09d7697203dc7dde4be1f0ac5f5d1
2025-12-01 16:29:04 +00:00
Alois Wohlschlager f3ed72f30b tests/functional: include mount and PID namespaces in the sandbox check
Running the sandbox (as unprivileged user) requires all of user, mount and PID
namespacing. Previously, only the user namespacing support was checked.
Unfortunately, newer Ubuntu kernels impose restrictions on capabilities within
unprivileged user namespaces [1]; as observed by experimentation, in particular
(re-)mounting filesystems or changing mount propagation is prohibited even
inside a mount namespace, making it impossible to use the Lix sandbox. So any
tests requiring sandboxing should check for this breakage and be skipped if
detected.

`unshare --mount` performs the same problematic operations, so that's what gets
used for the test. PID namespaces are included as well for completeness, even
though currently no instance of breakage due to them specifically is known.

This fixes [2] for the functional test suite only.

[1] https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
[2] https://git.lix.systems/lix-project/lix/issues/545

Change-Id: If95b527bf965ccb06371bbef7b6007666a6a6964
2025-12-01 14:25:47 +00:00
Alois Wohlschlager 31b6c823ae tests/functional: mark the remaining test requiring sandboxing
Diverted (chroot) store requires sandboxing, so the relevant test needs to be
marked as such.

Change-Id: I5c8ad5f90bb26f8e7088c7141066a18a6a6a6964
2025-12-01 14:25:47 +00:00
Alois Wohlschlager afd7faf385 libstore/build: disallow sandbox-fallback when using a diverted store
Builds using a diverted store strictly require sandboxing. Explicit disabling
by the user is already handled properly by force-enabling the sandbox anyway
(with a warning), but sandbox-fallback was still honored, predictably leading
to hilarious breakage (like the "confusing output" in [1]) when it actually
triggered. Cause a hard failure instead.

[1] https://git.lix.systems/lix-project/lix/issues/545

Change-Id: I61ea32c3bd8bca4e5ba278312b0a49326a6a6964
2025-12-01 14:25:47 +00:00
Alois Wohlschlager 7f176002c6 libstore/build: warn when the sandbox is force-enabled due to a diverted store
Builds using a diverted store strictly require sandboxing. It therefore makes
sense to automatically enable it even if otherwise explicitly disabled by the
user. However, they should still be informed that their choice is not being
respected.

Change-Id: Ia2cbdc24a4c55d8ecc49094e35e698e16a6a6964
2025-12-01 14:25:47 +00:00
Alois Wohlschlager b4e2abdf5c libstore/build: upgrade the sandbox-fallback message to a warning
Disabling build sandboxing is a significant change to build isolation. If this
is done automatically due to namespacing issues (and sandbox-fallback not being
disabled), show the user a loud warning without the need to opt into a lot of
other log spam.

Change-Id: I52daccdd6934873234223c798ca3dcff6a6a6964
2025-12-01 14:25:47 +00:00
Tom Hubrecht 1bfbbe2415 nix-shell: Add NIX_SHELL_LEVEL variable
This contains the depth of nix shells nesting.

Fixes #826

Co-authored-by: Qyriad <qyriad@qyriad.me>

Change-Id: If584c9d02730d6c857636dafdeab0c01f4ec8e0f
2025-12-01 12:02:45 +00:00
Tom Hubrecht 0c6d299e16 libexpr/eval: Deprecate shadowing <nix/fetchurl.nix>
If the NIX_PATH shadows internal files, this will often break things,
hence we forbid it.

Fixes #998

Change-Id: I70e5d389532ada1c9f910c60281abe565e3ce6bb
2025-11-30 12:28:54 +00:00
Alois Wohlschlager 3981458d8c nix-eval-jobs: make the tests independent of the evaluation order
Some of the tests depended on the evaluation order chosen internally by
nix-eval-jobs, which will break when that order changes. In practice the order
is not guaranteed, and already not deterministic with multiple workers.

Change-Id: I2e85d096f4439a8075a6f4a08d31c0f16a6a6964
2025-11-29 12:01:20 +01:00
Alois Wohlschlager ecf0d4c5a4 nix-eval-jobs: compile with Clang
GCC still ICEs on coroutines, while Clang works properly. Use the latter, just
like for Lix itself.

Change-Id: I802d6df7279550a5f5355e6c1ea0533c6a6a6964
2025-11-29 12:01:20 +01:00
Alois Wohlschlager 7440c4ef75 nix-eval-jobs: split the collector loop
Previously the collector-side implementation of the worker interaction protocol
was a bunch of spaghetti code. Split it apart at places where it makes sense to
be easier to follow.

Change-Id: If3cc6b6fbf289dd778856b40b55316c76a6a6964
2025-11-29 12:01:20 +01:00
Alois Wohlschlager 24497d08bc nix-eval-jobs: use std::thread
As the worker processes are now properly spawned using fork-exec, they no
longer inherit the stack size from the non-main coordinator thread, but get a
main thread with reasonable stack size on their own. For this reason the
coordinator threads can use the default stack size, and turn std::thread can be
used as the only reason for the custom wrapper was to enlarge the stack.

Change-Id: I1192474885abe9b0625ac483840b6e1a6a6a6964
2025-11-29 11:25:19 +01:00
Alois Wohlschlager 258c5b76eb nix-eval-jobs: fork and exec the workers
Similar to how 7b37d5ea6a switched the subdaemons
from fork-only to fork-exec, do the same for the nix-eval-jobs workers. This is
the promised change that causes the signal handler thread to appear.

Change-Id: I590a5eb6bddfb546a331a01191fd788b6a6a6964
2025-11-29 11:25:19 +01:00
Alois Wohlschlager 9baa4b5b74 nix-eval-jobs: wait for the crashed worker synchronously
The retry added in 4c5efd4548 has never worked
properly, as releasing the pid the first time causes it to be -1 and thus
waiting for a random child on retry. While there is a good chance that this
really catches the crashed worker, this is by no means guaranteed, and it could
just as well have caught different restarting worker. Wait synchronously
instead. The worst possible outcome is a hang instead of an error message if
the worker manages to close its pipe but then fail to exit, which is not
supposed to happen in the first place.

Change-Id: I4e4c3f532ec15c3118f6f77821ab820a6a6a6964
2025-11-29 11:25:19 +01:00
Qyriad d5d03cd8de undefined behavior: -Wembedded-directive
warning: embedding a directive within macro arguments has undefined behavior

????? CLANG? why does this take -pedantic to show??

Change-Id: I6f4a9f3db1b89448f9f5d00d82b551e46a6a6964
2025-11-28 21:29:44 +01:00
Jade Lovelace 0423f0ef38 docs typo: ssh-keyscan takes a hostname not user@host
Change-Id: Ib823165bcababed2808a602368d6ab57762a49b3
2025-11-28 12:06:20 +00:00
Qyriad 94c9b43b4a docs/hacking: fix typo from LLD commit
Thank you horrors

Change-Id: Id792cfd19efd3f99b55809cdaae420c06a6a6964
2025-11-27 12:58:07 +00:00
Qyriad b92c85848f functional2: fix on macOS if user has PATH elems that don't exist
This change brought to you by my uninstalling go but forgetting to
remove ~/.local/opt/go/bin from my PATH.

Change-Id: I937675bab11ac7e0678c896cba78204b6a6a6964
2025-11-27 10:51:08 +00:00
helle 54df89f601 docs build system: Fixed manual to be compatible with mdbook 0.5.x
Maintains compatibility with mdbook 0.4.x.

Includes comments for what to remove once 0.5.x is the only we care
about. Some other changes technically could be changed at that point,
but currently serve to enable universal support of 0.4.x and 0.5.x

Fixes #1051.

Change-Id: Ic5b405038d180bcd357bbd9e5716879e0c26e5f5
2025-11-26 23:50:28 +01:00
Tom Hubrecht cb0f9b9590 libstore/transfer: Warn by default instead of throw for destination changes
Fixes #1004

Change-Id: I2d583fbad40b3c95e37b70167a81c8fb492d5668
2025-11-26 14:42:52 +01:00
Tom Hubrecht 0c70cc6259 libutil: Reintroduce compile assertion that was mistakenly dropped
https://git.lix.systems/lix-project/lix/commit/74513483bc5572d988a059b8e964662d66f1667f
removed this check which is actually load-bearing for Lix (c.f.
https://git.lix.systems/lix-project/lix/commit/96a36833084f66b79ba778e719862b8219557773
).

Fixes #677

Change-Id: I3cc9a16c64c5189f788c510609afcf8bad997741
2025-11-26 01:56:00 +00:00
Qyriad 9f12981b30 parser: improve error message for missing } in attrset
Change-Id: I2846dbd8d0c1beb23c885a2d6d388a4f6a6a6964
2025-11-25 19:50:24 +00:00
Qyriad 6bb532ed03 parser: improve error message for missing semicolon in let/{}
In the same vein as be18b7dc2¹.

Before:
  error: syntax error, expecting ';'

After:
  error: syntax error, expecting ';' to end binding

[1]: be18b7dc25

Change-Id: Iffbcb113d2b892a50c646c9875e970376a6a6964
2025-11-25 19:50:24 +00:00
Commentator2.0 3661f34aba tests/functional2: fix --accept-tests not propagating to infra tests correctly
gotta make sure to do things in the correct order next time -_-

Change-Id: I84ba6495100e658aa35fac0a0917fae9363fe4dd
2025-11-25 13:43:01 +01:00
Alois Wohlschlager df607dd39e nix-eval-jobs: print evaluation results using writeToStdout
Lix blocks SIGPIPE, and std::cout ignores EPIPE (actually it probably stashes
an error code in some flag that no one ever reads, with the same end result).
Consequently, nix-eval-jobs would waste resources by continuing to evaluate
even when the reader interested in the results has long gone away. Instead, use
writeToStdout, which throws an error on EPIPE, leading to the process
terminating as desired.

Reported-by: Winter <winter@winter.cafe>

Change-Id: I962c09bab582a8ed27dd41c01b1519876a6a6964
2025-11-25 11:50:59 +00:00
Alois Wohlschlager 441f7db5f1 nix-eval-jobs: handle worker interruption properly
Right now, the worker will not receive interrupts, as it has no signal handler
thread due to the way it forks, but this will change soon. Prepare to handle
worker interruption properly, by letting the worker exit successfully in this
case and adjusting the coordinator to handle this exit gracefully.

Change-Id: I9f79670b0d2004e7e2d8bf36cf67108e6a6a6964
2025-11-25 11:50:59 +00:00
Qyriad 9d01255046 build: use lld in devShell on Linux
Change-Id: If270e824cab74337c6c71fe92fd376c76a6a6964
2025-11-25 11:02:32 +01:00
piegames 27a94369a9 nix::parser::State::addAttr: Deep attribute merging
Closes #845

Change-Id: Ie14d0e5a7a9fb778325c4ad30d1e1bd73c60b4f9
2025-11-24 19:16:27 +00:00
piegames 8765266dae nix::parser::State::addAttr: Improve error message
For some reason that eludes me, it used to only print the last attribute
instead of the full chain.

Change-Id: I2f5f6e85e2b1ab3ab20a9c99bf06d1e45a4d09bb
2025-11-24 19:16:27 +00:00
piegames 5484351523 nix::parser::State::addAttr: Sanitize
`e`, `ae`, `j`, `jAttrs` … holy fuck this function was so much worse
than it needed to be. This refactoring includes:

- Descriptive variable names where possible
- More code comments indicating what even is happening
- Shuffled the control flow around to be more linear (move early return
conditions up, etc.) and have less rightwards-drift, to increase
readability
- Extracted `mergeAttrs` function for future changes and readability

Change-Id: I7253b47ce4910fdc67aa7d6edff2f3c0bb8fa55b
2025-11-24 19:16:27 +00:00