Commit Graph
2316 Commits
Author SHA1 Message Date
Raito Bezarius f85c84db37 libstore/build: automatic clean up of unsuccessfully built scratch outputs
When a build fails, its scratch output paths are not cleaned up.

Until recently, this was deemed not a problem but as part of the effort
to harden the Nix builds and protect these paths against being part of a
staged attack (race conditions, etc.), we automatically cleanup after
failed builds.

Fixes CVE-2025-52992.

Change-Id: I58481b1cc83826298b9d80d37fecf81f117ccb09
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-24 10:50:03 +00:00
eldritch horrorsandRaito Bezarius 469cb4218d libstore: don't default build-dir to temp-dir
if a build directory is accessible to other users it is possible to
smuggle data in and out of build directories. usually this ins only
a build purity problem, but in combination with other issues it can
be used to break out of a build sandbox. to prevent this we default
to using a subdirectory of nixStateDir (which is more restrictive).

Fixes CVE-2025-52991.

Change-Id: Iacfc9b50534de158618c815f9fb99d7dae1be4d0
2025-06-24 10:50:03 +00:00
959f6cb084 libstore: use pasta for FODs if available
This allows using a userspace program, pasta, to handle comms between
the build sandbox, and the outside world; allowing for full isolation
including the network namespace, closing the "fixed-output derivation
talks to the host over an abstract domain socket" hole for good.

Fixes CVE-2025-46416.

Co-Authored-By: Puck Meerburg <puck@puckipedia.com>
Change-Id: Ifd499b7dbb3784600a6e842fede65fc031ff9f15
2025-06-24 10:50:03 +00:00
eldritch horrors 37a570bd40 deprecate CA, dynamic, and impure derivations
ca derivations are what we're really after, but dynamic derivations
must also go because they depend on ca derivations. we can't easily
implement dynamic derivations any other way, so we remove them too.
impure derivations build on the content-addressed infrastructure in
ways we cannot easily detangle, so they too must go for time being.

see #815

Change-Id: If61371736dfd89cc71a1b2ae5a005757c3cb9484
(cherry picked from commit d8e2f53d07)
2025-06-03 18:20:54 +00:00
Raito Bezarius 33eaaf02fd libstore/ssh: remove echo started check
The pre-flight `echo started` check over SSH was originally added in
577ebeaefb. As it is usual with these old
commits, understanding why is there a need for something is difficult.

The closest thing would be
> Fix a race starting the SSH master. We now wait synchronously for
> the SSH master to finish starting. This prevents the SSH clients
> from starting their own connections.

But, we removed SSH connection sharing, so this does not apply anymore.

Nonetheless, we believed this check was meant as a way to catch obvious
misconfigurations or SSH failures early, before handing off to
`nix-store`. However, this approach was not fruitful: it assumes the
remote has a `bash`-compatible shell, `echo` behaves in a standard way,
and no `ForceCommand` interferes—all of which are unreliable assumptions
in practice.

While the intent was to provide slightly better diagnostics (e.g. in
case of SSH hanging or returning an interactive shell), in practice it
does not meaningfully catch or improve real failure cases. The
underlying protocol or engine can and should handle those errors more
robustly anyway.

In contrast, this check *does* break several legitimate workflows,
including:

* remote builders using `ForceCommand` wrappers (e.g.
`nix-remote-build`-style setups), see
<https://discourse.nixos.org/t/wrapper-to-restrict-builder-access-through-ssh-worth-upstreaming/25834/15>,

* SSHing into minimal environments lacking `bash` (e.g. initrd,
busybox-based systems),

* configurations that don’t default to POSIX-like shells, e.g., nushell
enthusiasts.

As such, we’re removing this code. Protocol mismatch errors and SSH
failures can be rethought and handled more structurally elsewhere in the
engine.

Change-Id: I187f6881375d42ef83987a13a350c97964bbdb30
Signed-off-by: Raito Bezarius <raito@lix.systems>
(cherry picked from commit 0dd8bf6c1c)
2025-05-18 19:51:41 +00:00
Rebecca Turner bb0cdf110e release: release notes for 2.93.0
Release created with releng/create_release.xsh

Change-Id: I5a793e632dae1b6fdd4f743c383aca937b048dfc
2025-05-09 14:47:55 -07:00
Tom HubrechtandLix Systems Gerrit 885dde9c3d Merge "libstore: Show illegal path references in fixed-outputs derivations" into main 2025-05-08 20:19:15 +00:00
a8da0df671 libstore: Show illegal path references in fixed-outputs derivations
This allows debugging the errors by pinpointing the offenders, instead
of trying to blindly guess what could have possibly gone wrong.

The wording has been improved to better explain the failure.

Closes #530

Co-authored-by: Ben Millwood <thebenmachine+git@gmail.com>
Change-Id: I84ba5d2d81e5d1867f53bd3bc80e615cab9fe274
2025-05-08 20:23:12 +02:00
Linus Heckemann 08d7ddd6ca release notes: name SSH options that are no longer used
When I read the note, I wasn't sure what was meant by connection
sharing. This adds a reference to SSH documentation for clarity.

Change-Id: I1d6e5c53fb6a6fac8380210967f56d86f0333e55
2025-05-07 10:53:12 +02:00
vringar dbdf7c76e6 fix(rl-2.92): fix fmt shim script
Change-Id: I38aed40b3f6916fa7a6991ee0bb056be98d98497
2025-05-05 14:10:57 +00:00
helleandLix Systems Gerrit 4e84fd9a00 Merge "Fix various links to anchors in documentation." into main 2025-05-02 11:45:29 +00:00
jadeandLix Systems Gerrit 9a489c5e78 Merge "fix: Terminate daemons properly on Ctrl-C on macOS" into main 2025-05-02 00:09:43 +00:00
helleandjade f659a1e638 Fix various links to anchors in documentation.
These are updates to several links in the documentation that are not
currently pointing to existing anchors in the documentation, these were
found using the unfinished version of the mdbook-linkchecker we are
working on.

Fixes include pointing them to the correct anchor, inserting anchors (in
updated html5 style, though debatable) and in the case of the historical
release notes, removing them, fixing #809.

Change-Id: If4ef89dc89506aa131a764312d97a86179ccd6f5
2025-05-01 21:35:52 +00:00
Jade Lovelace 69ba3c92db fix: Terminate daemons properly on Ctrl-C on macOS
This was an absolute nightmare to diagnose. It turns out there's a
kernel bug: poll with events = POLLHUP will receive an event for NOT
POLLHUP internally in the kernel, delete their event subscription, and
then not receive events for any HUP later. lol! lmao!!

We choose to use plain old EVFILT_READ because the watched fd can be
either a socket or a pipe and it's preferable to eat some spurious
wakeups than have separate paths for those. The alternative is using
EVFILT_SOCK, a private API that's existed for years and which netty
uses for its sockets, but that doesn't work on pipes.

Fixes: https://git.lix.systems/lix-project/lix/issues/729
Change-Id: If72b5d7a39f00320a9acccdbe81121cdb1a04c45
2025-05-01 12:22:27 -07:00
jadeandLix Systems Gerrit fde4121334 Merge "manual: link directly to gerrit for proposing changes" into main 2025-04-30 04:59:41 +00:00
eldritch horrors eb0280f715 libexpr: add set-to-string error frame
this is much more useful than a frame pointing to the set but claiming
it as a function being called. if the function is actually at fault we
will now point to its attribute, although the position may be slightly
wrong if __toString was defined from set updates or builtin functions.

Change-Id: Ib3eb237a276d94426d9c6fc0e26eea72382d34a2
2025-04-27 11:01:22 +00:00
Raito Bezarius 5ca168f6f2 chore: drop experimental feature recursive-nix
This was discussed as part of https://git.lix.systems/lix-project/lix/issues/767
with a one month long comment period.

This commit removes the recursive-nix feature from Lix. It has seen
limited usage and is difficult to stabilize, especially on non-Linux
systems where its behavior is underspecified.

Maintaining this feature complicates core work on the store, as we must
account for the potential presence of the daemon in the sandbox, adding
unnecessary complexity. Additionally, its inclusion in the
platform-independent local store creates risks for non-Linux platforms.

For more details on this removal, refer to the release note entry or the
issue entry.

Change-Id: I9137202f563c0a317f9c5da79cd9fd07d801427a
Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-04-25 17:09:01 +02:00
Qyriad 7dbdd5bd0c build: set XDG_CONFIG_HOME to /dummy too
This prevents the user's nix.conf from being mistakenly used during docs
generation.

Fixes #802

Change-Id: I23336b49a8aa2ddf92e803e573321383ea2e5e81
2025-04-22 16:45:44 +00:00
piegames abb8ad29c0 repl: Always use parser, allow trailing ; in assignments
We now properly shell out to the parser instead of hacking stuff
together with a regex. Stuff we get for free by doing this:

- Optional trailing semicolon
- Declaring nested attribute sets
- String identifiers, and future proofing for eventual grammar
improvements to identifiers
- Dynamic attributes

Change-Id: Ibf1ad815e5e27caf162df05ea5ba5b1b4955d9c9
2025-04-21 20:19:25 +02:00
eldritch horrors f92235e1d2 libstore: stop using ssh connection sharing
our implementation is mostly unused, completely untested, and simply
breaks when users configure connection sharing independently. we can
safely delete this "feature" and inherit user configuration instead.

also have the remote build test check that connection sharing works.

fixes #304, fixes #644

Change-Id: Iea44cc0f8e51a1d231ad186a95c7e310bbfeb303
2025-04-21 13:43:44 +00:00
jadeandLix Systems Gerrit 9c2dba4ee2 Merge "Revert "libstore: don't use curl decompression support"" into main 2025-04-09 16:01:37 +00:00
eldritch horrorsandLix Systems Gerrit 350bf7e42d Revert "libstore: don't use curl decompression support"
This reverts commit bba678e5c5.

Reason for revert: didn't fix the bug and created new ones (fj#794)

Change-Id: I0450205d3041b6c876737151a4051081c1366f1d
2025-04-09 11:28:50 +00:00
Jade Lovelace cbaf1bb446 manual: link directly to gerrit for proposing changes
This is, well, interesting. It's the same "edit" button you see on
Gitiles, and upon clicking it, without confirmation, it makes a new CL
and dumps you directly into the editor for the file in question.

I guess if you click it by accident you can just abandon or delete the
CL so it's like, fine. A bit of fascinating UX design here.

Change-Id: I765a1f1fc6d94b171878dde7b01fc621adc00180
2025-04-01 20:28:06 -07:00
Maximilian BoschandLix Systems Gerrit d169c092fc Merge "fetchers: don't consider a path locked if a rev is specified" into main 2025-03-29 18:51:45 +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
jadeandLix Systems Gerrit f270d3ebe0 Merge changes Ib81a5db1,Ib6d68594,Id91e1fd4 into main
* changes:
  docs: document the cursed file syntax for new CLI
  docs: document the cursed file syntax for old cli
  doc preprocessor: support indent directives
2025-03-26 16:05:26 +00:00
Stanislav AlekseevandLix Systems Gerrit 21dac7513c Merge "Revert "fix: allow access to ca-certs in FODs on darwin"" into main 2025-03-26 13:00:59 +00:00
Stanislav AlekseevandLix Systems Gerrit 5a4da16094 Revert "fix: allow access to ca-certs in FODs on darwin"
This reverts commit 692de16113.

Reason for revert: it's wrong at it doesn't actually work

Change-Id: I495eed65bb7547ceffe98f979633c080e83ac154
2025-03-26 10:27:58 +00:00
QyriadandJade Lovelace 11225f435d docs: document the cursed file syntax for old cli
This documents the fact that nix-build, nix-env, nix-instantiate, and
nix-shell accept an extended syntax for their file arguments, including
some well-known (but not well documented) aspects, like being able to
specify `<nixpkgs>`, but also https:// tarball URLs, `flake:` prefixed
flakerefs, and the cursed `channel:` prefixed hardcoded URLs

Same thing for the new CLI incoming :)

Change-Id: Ib6d68594a16132805ba5d97526e16f7b3633117e
2025-03-25 17:06:53 -07:00
Jade Lovelace 989498407b doc preprocessor: support indent directives
Janky Python makes the world go around. In repentance I removed some
jank from it.

Change-Id: Id91e1fd40cb73049cb64deab6f81a7193132fa82
2025-03-25 17:06:53 -07:00
eldritch horrors c3929c78f3 libutil: disallow enum serialization by default
allow opting in to serialization as integers via a trait type instead,
and add string-list serializers for the feature flag set enumerations.

fixes #738

Change-Id: I2746eb5ef1f15c01b4e681f9ba1615b6c6e64f44
2025-03-25 10:44:52 +01:00
jadeandLix Systems Gerrit 4181796ed2 Merge changes I0f5d9912,I442f16c7 into main
* changes:
  observability: add the first USDT probe
  tree-wide: put in more keep-sorted
2025-03-24 16:37:28 +00:00
Stanislav AlekseevandLix Systems Gerrit f0fd789f68 Merge "fix: allow access to ca-certs in FODs on darwin" into main 2025-03-24 07:32:12 +00:00
WeetHetandJade Lovelace 692de16113 fix: allow access to ca-certs in FODs on darwin
Change-Id: Id955be88eb5d419d57262d5983841a1e6accee9f
2025-03-23 19:13:44 -07:00
Jade Lovelace cad275307e observability: add the first USDT probe
USDT probes are statically defined trace points that have nearly zero
disabled-probe effect, i.e. we can put them in hot paths.

The use case for these is both similar and dissimilar to Rust tracing:
We still need better logging and a better structured rust-tracing
looking thing, but probes allow for quite easy programmable interactive
tracing in production, which we also care a lot about.

This CL comes with a perfunctory trace point in
libstore/file-transfer.cc for reading data out of the curl buffer. This
was mostly thrown in there so that I could see what the buffer sizes of
this were, and maybe be able to instrument the perf of the curl usages
in Lix in the future.

Fixes: https://git.lix.systems/lix-project/lix/issues/727
Change-Id: I0f5d9912d76bf3d6923bf53ebfd9b8d6c6e70aea
2025-03-23 18:37:47 -07:00
jadeandLix Systems Gerrit 53b41a7f9b Merge "UX: Show users SRI hashes everywhere instead of base32" into main 2025-03-23 17:46:11 +00:00
jadeandLix Systems Gerrit 3f45d5e020 Merge "fix!: file type flake inputs are always recursive hashed" into main 2025-03-23 17:45:41 +00:00
Jade Lovelace f695aa2bd2 UX: Show users SRI hashes everywhere instead of base32
This is *just* in output messages that look relatively like the FOD
failure message. It's not great that we inconsistently use the old
format in random places.

Change-Id: I4b9ce73a98a3a50c924cfe1d7cded42f3756df6b
2025-03-21 13:30:41 -07:00
Jade Lovelace b22bee91f5 fix!: file type flake inputs are always recursive hashed
Well that is a mess. I don't like breaking derivation compatibility,
but I like non-deterministic evaluation much less.

We can break compat if we own up to it, which this does.

Fixes: https://git.lix.systems/lix-project/lix/issues/750

Change-Id: Ic9e2407393f1d42c2be604f80b4aa11bc872bc23
2025-03-21 13:19:15 -07:00
5339ffb234 fix: split macos sandbox profile to avoid size errors
Fixes: https://git.lix.systems/lix-project/lix/issues/752
Fixes: https://git.lix.systems/lix-project/lix/issues/718

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
Change-Id: Icfa95ffd40f5a60f67e14148924bc77b42232e19
2025-03-21 18:52:43 +00:00
Maximilian Bosch 62fb98ae55 fetchers: don't consider a path locked if a rev is specified
It's possible to put a path into the store in pure mode by pretending
it's locked like this:

    $ echo 'lalala' > testfile
    $ nix eval --expr '(builtins.fetchTree { path = "/home/ma27/testfile"; rev = "0000000000000000000000000000000000000000"; type = "path"; })'
    { lastModified = 1723656303; lastModifiedDate = "20240814172503"; narHash = "sha256-hOMY06A0ohaaCLwnhpZIMoAqi/8kG2vk30NRiqi0dfc="; outPath = "/nix/store/lhfz259iipmv9ky995rml8018jvriynh-source"; rev = "0000000000000000000000000000000000000000"; shortRev = "0000000"; }
    $ cat /nix/store/lhfz259iipmv9ky995rml8018jvriynh-source
    lalala

There was a fix in CppNix[1], but Puck noted that it's breaking
backwards-compatibility because

> [...] a github fetch with a fully specified rev is no longer considered "locked"
> this is for "purity" reasons, but it breaks any existing flake.nix files

I tried a way smaller correctness fix here:

* Each scheme can denote whether a `rev` is enough to consider itself
  locked.
* If a `rev` is given and the scheme is OK with just a `rev` to be
  locked, the input is marked as locked.

For `path` this is not the case anymore, i.e. it requires a NAR hash to
be locked down.

[1] https://github.com/nixos/nix/commit/071dd2b3a4e6c0b2106f1b6f14ec26e153d97446

Change-Id: Ibbbf4733c82bcfa1c24dfe099a896d8aaecd81cc
2025-03-20 13:17:34 +00:00
jadeandLix Systems Gerrit 430bcc482c Merge "release-notes: add some for gc gremlins" into main 2025-03-18 20:02:25 +00:00
jadeandLix Systems Gerrit be4ab653eb Merge "fetchTree: make invisible when not available, sorta document" into main 2025-03-18 19:32:12 +00:00
Jade LovelaceandJade Lovelace fcea7379d3 fetchTree: make invisible when not available, sorta document
Documenting fetchTree is an exercise in frustration because of the sheer
amount of stringly typed everything in it. I do not know which fields
exist without reading the entirety of libfetchers. However, we can write
something slightly perfunctory but at least perhaps somewhat helpful
documentation-wise.

Fixes: https://git.lix.systems/lix-project/lix/issues/609
Change-Id: I991391b53fcd69172dbc7efb9d384e62bc847b91
2025-03-18 11:34:28 -07:00
Jade Lovelace 24e413c147 release-notes: add some for gc gremlins
Originally was in cl/2687 but that CL got canned.

Change-Id: Ib504e263d72669f2418ef02d624bcba26b169622
2025-03-18 10:50:23 -07:00
Mario RodasandLix Systems Gerrit 42541e030c Merge "Fix broken links in documentation" into main 2025-03-18 17:33:31 +00:00
Mario RodasandLix Systems Gerrit dc69d64bff Merge "Fix typos in documentation" into main 2025-03-18 17:32:53 +00:00
jadeandLix Systems Gerrit 6e6ff58272 Merge "feat!: remove experimental repl-flakes" into main 2025-03-18 16:02:55 +00:00
Mario Rodas 1da97ab24e Fix broken links in documentation
Change-Id: I582341a001d9541db82794eb64ddfc32c6582b83
2025-03-18 04:20:00 +00:00
Mario Rodas 992866bc91 Fix typos in documentation
Change-Id: I93c3801290d03244ea8db96679d002589ae90b74
2025-03-18 04:20:00 +00:00