Commit Graph
18883 Commits
Author SHA1 Message Date
piegames 16bd27fb78 deprecated-features/rec-set-overrides: Upgrade to hard error
Change-Id: Ifec24ee905e821058a7259be00460bf2988429d8
2026-01-31 21:58:33 +01:00
piegames c76632e17d deprecated-features/ancient-let: Upgrade to hard error
Change-Id: Ib856a665a8175a880b3ff52dde9d34769f24713b
2026-01-31 21:58:33 +01:00
piegames adfbc836c0 libexpr: Expand shadow-internal-symbols deprecated features to code null, true and false
Change-Id: If20efb9afced8665ba5c3b45cd09542e398867aa
2026-01-31 21:58:33 +01:00
eldritch horrors 1042d26c31 libstore: remove impersonate-linux-26 setting
it's ancient, it does not do what it was added for (improving
determinism), and it probably hasn't been needed for anything
in a very long time. we can probably get away with killing it

Change-Id: I66f5c841964d9ad62726cb2dae8d6fc42095399f
2026-01-31 20:05:45 +00:00
eldritch horrors cf9735f82e libstore: don't modify pathsInSandbox while mounting stuff
mostly because this will make it easier to change the data source for
them, and especially to change to data source to something immutable.

Change-Id: Ic5f1a55d02d4c2cc928c3f8b308d07167efb467b
2026-01-31 20:05:45 +00:00
eldritch horrors f5a2251966 libstore: move rewriteResolvConf to LinuxLocalDerivationGoal
it's only used there.

Change-Id: I9e267ce8b178ef3996d55b5980475a7e914ba0aa
2026-01-31 20:05:45 +00:00
eldritch horrors b41af64d1e libstore: compile linux syscall filter in prepareSandbox
this is literally part of preparing the sandbox.

Change-Id: Ic1a574bdaa68b5f39326b91c10198b774f7b2f7e
2026-01-31 20:05:45 +00:00
eldritch horrors 0d4baa5528 libstore: don't keep tempdirs open after we need them
closing them as soon as we're done ensure that the fd table doesn't
balloon in size, which in turn lets us build larger graphs. it also
makes forking processes cheaper due to less fd table copy overhead.

Change-Id: I233d1b7358ffe1b05680f845cd99de38b179f449
2026-01-31 20:05:45 +00:00
piegamesandCommentator2.0 7e68f93ed7 libexpr: Require whitespace between certain tokens
Fixes #135, #136

Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: Ia1880633c1ee3b9242487fbc30b6d781d88987fb
2026-01-31 20:44:34 +01:00
Commentator2.0androotile 98d0215ca2 tests/functional2: migrate substitute-truncated-nar.sh
Change-Id: I7225930ed6ec999b38bde8bcd23e7203fd4be1b6
2026-01-31 18:09:24 +01:00
piegamesandCommentator2.0 17f1bcfd2c libexpr: Deprecate or in non-keyword positions
Test cases courtesy of rhenrdic

Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: Id8df684ddd00d07b49e1c9e68bf41ee6c0e6887c
2026-01-31 15:32:28 +01:00
piegamesandCommentator2.0 af166146ff nix::parser::State::addAttr: Forbid dynamic attrs in recursive attrsets
Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: I92656b3b27f551bf286abc0d680c4a1c542337d7
2026-01-31 15:32:27 +01:00
piegamesandCommentator2.0 51dcc6ac0d nix::parser::State::addAttr: Forbid mixed-rec merges
Fixes #350, https://github.com/NixOS/nix/issues/9020

Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: If78d144dc35839b7668c0e0ad796252fcfc42ea0
2026-01-31 15:32:27 +01:00
piegamesandCommentator2.0 cbaa172775 libexpr: Warn on floating point literals without leading or trailing zero
Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: I0b58531ad091b22dc59d5717f5d1c8c814b4d2ea
2026-01-31 15:32:27 +01:00
piegamesandCommentator2.0 56dee9186f libexpr: Warn on incorrect string escapes
In Nixpkgs, there are several strings like "\d\.\d" which attempt to be
a regex but are just literally "d.d". The escaping rules are silly and
we should warn our users about that.

Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: I779b0757358fc9adc34dc140e1670b83abc93b67
2026-01-31 15:32:27 +01:00
piegamesandCommentator2.0 f1fbd1d095 libexpr: Warn on incorrect string usage
The indentation stripping semantics of strings are fairly bad and have a
few gotchas where they behave unintuitively. But the good news is, that
these cases are easy to catch and can be avoided.
This commit adds a warning in the parser when such strings are detected.

Unfortunately Nixpkgs uses this kind of a lot, so we won't be able to
actually enable this warning for a while to come.

Co-authored-by: Commentator2.0 <lix@crystal-cavern.systems>
Change-Id: I3b3b68c2eee4cd70959d3f4ca643cb6caf3a2217
2026-01-31 15:32:27 +01:00
piegames 4e1c216fd3 libexpr: Fix rec-set-overrides detection
Unfortunately, the previous code only detected superficial __overrides
and did not catch cases like `rec { __overrides.foo = 2; }`.

Change-Id: Ic38bdef1a6a3bdea91915aef44447f4ecc238259
2026-01-31 15:32:27 +01:00
piegames 9ad0ace8c0 deprecated-features: Rewrite feature descriptions
Changed the writing style of the descriptions, expanded with more
examples and rationale, and added the new timline metadata in the
frontmatter.

Change-Id: I218389e3504fc21f4eb45a927e77a41a1a70d4f5
2026-01-31 15:32:27 +01:00
piegames f289462c59 eval: Don't expose partially constructed sets
This turns several instances of unsoundness into runtime infinite
recursion errors

Fixes https://github.com/NixOS/nix/issues/7012,
https://github.com/NixOS/nix/issues/3241

Change-Id: Id8d352c5a78ef08d8913f07fe83f55c875684714
2026-01-31 15:32:27 +01:00
rootileandpiegames 7bd3202175 lix/code-generation: add timeline information to deprecated features
Change-Id: I5d5cf28c62cea116cb01bf433eb69a8c859809a8
2026-01-31 15:32:27 +01:00
Commentator2.0andpiegames 8c857790a3 lix/code-generation: clean up code properly
The code within the code-generation had tons of code-duplicates and was
overall quite meh to read, understand and expand.

This commit refactors the code-generation to make it more readable and
comprehensible, while also unifying its usage a bit more

Change-Id: I3a5df8b7d8d9b6c76e02ef47dfb151c7dab7d0ab
2026-01-31 15:32:27 +01:00
eldritch horrors 279926d215 meson: merge libs
lix, where modularity is made up and the patterns don't matter. merging
everything to match actual behavior of the system makes using rust much
easier because we'll have only *one* library to link, not half a dozen.

Change-Id: Ie3cb1db659798511128716402497697320bd0484
2026-01-30 17:29:51 +00:00
eldritch horrors 2e0cc67ec8 libstore: start pasta much earlier
starting pasta as soon as we have all namespaces it must be in available
lets it start up while we finish creating the sandbox. this may speed up
sandbox launches somewhat, but likely not enough to show up in practice.

Change-Id: Id6724cbdc48b99284cd7ba7b56c98829d74557c5
2026-01-30 00:29:27 +00:00
eldritch horrors a2500db977 libstore: remove unnecessary linux-specific RunOptions
Change-Id: I07303c2aea78cf9f17b89b5cea922271ce26f029
2026-01-30 00:29:27 +00:00
eldritch horrors d43c6dd100 libstore: use raw syscall for inVFork setgroups
Change-Id: Ia656d2697b883d2b058984787556915b34f44211
2026-01-30 00:29:27 +00:00
eldritch horrors ab4f8718f9 libstore: start pasta from a vfork child
mostly as a prototype for other process launching optimizations, but
also to move linux-only bits out of runProgram2. we want to stop the
fork+exec dance we do now and migrate to posix_spawn, but linux will
always need an amount special handling for launching build children.

Change-Id: Ied55dc0de95c05b52aaca923be2e3c1d101f47e0
2026-01-30 00:29:05 +00:00
eldritch horrors b6c8f412a2 libstore: generalize linux vfork infra to also allow exec'ing
we'll use this to run programs from a vforked child instead of using
runProgram. ideally we would like to have runProgram be as efficient
as possible, but our mount namespace handling makes this harder than
is worth dealing with right now. the linux derivation goal is a good
place to prototype functionality like this, especially since we need
fine control over credentials and file descriptor tables of children

Change-Id: Ibc356613ae10b06ea81de9575611948f5ee353b6
2026-01-29 19:00:56 +01:00
eldritch horrors 05fed0687d libstore: add processes to cgroups earlier
this was racy previously; a builder may have spawned processes before we
added it to a cgroup. these processes would not be registered correctly.

Change-Id: If60a64a798ee806d5701590a83d1015f55d7b867
2026-01-28 18:49:02 +01:00
eldritch horrors b23bbd5b19 libstore: fix personality setting for unsandboxed linux builds
oops. this was supposed to always happen on function exit.

Change-Id: I25465b4248c33389ca7e70b2a0b52dcc10d86a38
2026-01-28 18:49:02 +01:00
eldritch horrors 56988d8605 libstore: use vfork for linux sandbox launch wrappers
this halves sandbox launch overhead, reducing the build time for 3000
trivial runCommand derivations on our machine from 80 seconds to 44s.
as a nice side effect we also get better error message propagation in
some cases, most notably setgroups failing when run in lix sandboxes.

Change-Id: Ia7c50a844915d9b8a20475b90b2d0179fd2fff34
2026-01-28 15:01:13 +00:00
eldritch horrors bf3d4e8721 libstore: simplify user/net namespace setup
creating user namespaces early means we don't need pipes to signal that
a namespace has been created and set up. we'll also create the netns at
the same time because they're privilege-bound to the userns, and having
both available will let us launch pasta earlier to have it ready sooner

Change-Id: Ie66fe2ab7f50a520fb81dd90944384e168d94476
2026-01-28 15:00:55 +00:00
eldritch horrors c9fe3befc1 libstore: add vfork infra to linux platform bits
vfork can be a lot faster than fork on linux, and we want to use it.

Change-Id: If1665d3c49e525f2722b1e040cd7058f376bd20e
2026-01-28 15:00:43 +00:00
eldritch horrors 7e8f7d0e66 libstore: set up linux sandbox /etc earlier
permissions and ownership will be the same since the sandbox process
will not have changed uid/gid or umask by the time it gets around to
writing these files. all of these files contain some information the
host must provide, be it contents or configuration info of some kind

Change-Id: I0b57cb0699fd29e798ccf330dff99f571f3c0692
2026-01-28 12:41:26 +01:00
eldritch horrors 7d3dde851a libstore: make runPasta a function of LinuxLocalDerivationGoal
this way we can use it anywhere without fear of it being uninitialized.
only the linux platform bit uses this anyway, so we will move it there.

Change-Id: I35e207eec91daa8aa327c4f8b36c0dc8e703a7c4
2026-01-28 12:41:26 +01:00
eldritch horrors bd458f9f89 libstore: make privateNetwork a function of LinuxLocalDerivationGoal
it's only used there, and this avoids using it uninitialized.

Change-Id: I6bd84e3c441dc6750e8ab07822f896136586cd66
2026-01-28 12:41:26 +01:00
Raito Bezarius 57373cba6f nix/daemon: receive supplementary groups on macOS/FreeBSD
`xucred` already contain `cr_ngroups` and `cr_groups`, we just have to
use it properly.

Change-Id: Ic29b4c551f9d93e86e9ed2bef20889d27d5438f4
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-28 08:24:24 +00:00
Raito BezariusandTom Hubrecht c493fb668e nix/daemon: consider supplementary groups during authentication
Two things happens here:

- we consider supplementary groups that are known for authentication,
fixes #968.

- we check supplementary groups if they are our build users group and
throw an error if they are (new behavior).

Nonetheless, we did not remove the ability for `matchUser` to recurse
and check for groups that the user may have but the connection might not
have communicated as part of their groups, i.e. if a process reduces its
list of groups via a call to setgroups, it will still be authorized.
This will come in another commit.

The authorization NixOS test has been extended with a store ping test
running in systemd with DynamicUser=true *AND* a supplementary group in
allowed-users.

Co-authored-by: Tom Hubrecht <github@mail.hubrecht.ovh>
Change-Id: I25b2b8304d66a04651cea523b5585a5d15ceebe8
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-28 08:24:24 +00:00
Raito Bezarius 9e55dd6b8f nix/daemon: receive supplementary groups on Linux
On Linux, SO_PEERGROUPS is an option introduced in 2017, that is, in
Linux 4.13.

Thankfully, Lix targets 5.10+ kernels minimum.

It was chosen to allocate 128 gids by default and ramp up (2x) as needed
rather than allocate a full 65k of integers as it seems wasteful. I bet
the time to the 16 allocations should incur at most an additional
millisecond on a modern system, don't quote me on that though.

This is preparation to enable ability for the daemon to vet based on
supplementary groups.

Related to #968.

Suggested-by: alois31
Suggested-by: eldritch horrors
Change-Id: I26d698327db5d174bf70ca25b0afede132bd9169
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-28 08:24:09 +00:00
Raito Bezarius dbb3edcfea nix/daemon: clean up PeerInfo
Rather than a bunch of booleans, use optional<T> as a way to convey that
the identifier is known or not.

This is preparatory work for SO_PEERGROUP usage.

Change-Id: I0e3ce69e4103f9df5a2161c695bfc650123c1549
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-28 09:20:57 +01:00
eldritch horrors 986191534e libstore: allow config loading without a home dir set
we can already handle this case (by forbidding any ~/... paths in option
values), and since builtin builders are now run via exec we may not have
a home dir set, or even available, for them to resolve. loading a config
file in this situation will fail with an error even if the config is ok.

fixes #1109

Change-Id: I3491b31558871faa34766462747e3c15d1eccc64
2026-01-27 17:13:07 +01:00
eldritch horrors ef8a6cc5f5 libutil: add tryGetHome that doesn't throw on errors
Change-Id: Ib5bcb277e39093b303fe4a66a8903a7c5692f305
2026-01-27 17:13:07 +01:00
Raito Bezarius e083a68a9f libstore/linux: forbid xattrs syscalls
xattrs are revealing some unfortunate brittleness in real world
derivations that are getting -EINVAL errors while executing their test
code.

The reason for this is that Linux checks [1] UID delegations for xattrs
writes.

In the Lix sandbox, except if you enabled a uid-range feature, you have
exactly 3 UIDs: root, nixbld and nobody.

If your test code makes use of UIDs which have not been delegated, you
will receive an EINVAL on your operation. Test code is not resilient
with respect to the number of available UIDs in their namespace.

To avoid further issues for end users who are running into spurious
derivation build failures, we forbid xattrs again for now.

For more information about the plans, please consult or chime in [2].

Fixes #1105. Reopens #838. Fixes #1103.

[1]: https://elixir.bootlin.com/linux/v6.18.6/source/fs/posix_acl.c#L257
[2]: https://zulip.lix.systems/#narrow/channel/9-Store/topic/disablement.20of.20xattrs/with/5295

Change-Id: I864066b34cd8319d2271fac1b179cb4f950d836e
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-01-26 18:54:51 +00:00
eldritch horrors cfabc37828 libstore: add unix:// uri protocol argument
Change-Id: I7fc27926aa1d89e2190b1deb0252ad33f2b364a5
2026-01-26 18:17:07 +00:00
eldritch horrors bdc220b8ec libstore: allow for multiple daemon sockets with preference
this will let us configure more than one socket to connect/bind to,
which in turn lets us use posix acls on sockets for access control.
we will also need something like this for the final rpc transition.

Change-Id: I9c39f14906e9bf809055ab5c94bf687745b4f69e
2026-01-26 18:17:07 +00:00
eldritch horrors f4458b8e46 libstore: simplify netrc, cafile loading for builtin builders
Change-Id: I8370a1434729c7ff2e44ddbaf173d7068e8ace9f
2026-01-25 19:47:24 +01:00
eldritch horrors 99d674b785 libstore: despecialize sandbox launching
now that builtin builders are regular executables we no longer need to
treat them specially during sandbox launch itself, only while we build
the command line and environment for the sandboxed process. we are not
far from being able to extract platform-dependent sandbox launch code,
ideally moving all of it into (much more replaceable) libexec helpers.

Change-Id: I9b7041314683c56cd70eec9b1b4eae6de228883f
2026-01-25 19:43:13 +01:00
eldritch horrors 049c7b3369 libstore: move the builtin builders to our new executable
this means that builtinFetchurl runs in a real process now, and thus we
no longer need its workarounds for running in a forked process. forking
dropped the signal handler thread and broke the curl state via sharing,
neither of which happens any more now. we can run fetchurl builtins and
their actions straight from the main thread of our builder now, and the
temporary files and settings overrides we did are now also unnecessary.

Change-Id: I738171bc120ffcd541b7ff1424fed7924c2cdc1d
2026-01-25 19:31:38 +01:00
eldritch horrors 58c3ee4c8e builtin-builder: remove unescapeNul that snuck back in
fuck

Change-Id: I5d203fc36c4a2eb2aefde9208d6cefd3619cdf03
2026-01-25 19:30:10 +01:00
eldritch horrors 5abf26a19f add a builtin-builder command for ... builtin builders
this will let us migrate the fork+do_stuff combo of builtin builders we
have today to fork+exec of this new command. we use a subcommand rather
than a simple libexec helper because we would like to avoid linking all
of lix into the simple libexec helpers if possible. this is only hookup
for the builders, none of the buiders are migrated here to ease review.

Change-Id: I9358f1f3fee6ca640c81a7bd865128ae0d0e35a5
2026-01-25 17:26:39 +00:00
eldritch horrors c50a3a426f libutil: add simple NUL escaping/unescaping functions
Change-Id: Ia4cc7b8f1058439f312066422eebfaff1c2c0c6c
2026-01-25 17:29:32 +01:00