Commit Graph
19196 Commits
Author SHA1 Message Date
skye be34bc0481 testing: migrate and expand import-derivation.sh and warn-import-from-derivation.sh
This started by noticing that the coverage report generated by cl/5489
showed that the error message for when allow-import-from-derivation is
disabled appeared to be not covered by any tests. Since the existing
tests for IFD were in functional, which is deprecated, I migrated those
into functional2 and added a test for erroring when IFD is disabled.

Change-Id: I565674de3dd693e023ec99d501adc4706a6a6964
2026-04-22 10:26:15 -04:00
skye eeac529d5e libexpr/primops: Suppress deprecation warning in prim_importNative
as of cl/5456 prim_importNative default constructs a `Value` in order to
pass as an out parameter to a ValueInitializer function. Default
construction is deprecated, but there isn't a meaningful value to
initialize it to instead. After cl/5357 this will give a deprecation
warning (which in an asanBuild will be an error), so this commit
suppresses that warning for that `Value` construction.

Change-Id: Ie567a6e81b5753672001320e9fc816c56a6a6964
2026-04-22 08:39:55 -04:00
skye 47c9f73d36 doc/manual: Update signature of primop fn in hacking.md
This should have been part of cl/5456, but I didn't notice it at the time.

Change-Id: I3afe75c5862ecd3ce2f616a2ae30aff96a6a6964
2026-04-22 08:39:49 -04:00
skye 84347f94da libexec/kill-user: suppress syscall deprecation warning on darwin
The existing function is used with good reason as explained by its
comment. This suppresses the warning it creates.

Change-Id: I58b0de3f5854266fa77b6a06b7821a636a6a6964
2026-04-22 08:37:17 -04:00
skye cda9e01053 nix-eval-jobs: Remove Value default construction from releaseExprTopLevelValue
Change-Id: I7461323771a50729c66d9e3160c4768f6a6a6964
2026-04-22 08:37:17 -04:00
skye c40afdea73 libexpr/eval-expr: extract makeThunk function that constructs and increments counters
Motivated by needing to remove a Value default construction from
`ExprVar::maybeThunk`, so part of #744

Change-Id: Ia12b5b019e49055ebd7ffa0cc39a59c06a6a6964
2026-04-22 08:37:17 -04:00
vczf dda519baff gitignore: ignore top-level build and outputs directories
Change-Id: Id51439c15c0216e7353ba48ae1940d3906473d4f
2026-04-22 11:47:09 +00:00
Jade Lovelace af99ede1fd fix: UB casts to unspecified width enums in proto
Found by edef's fuzzing. We::jade don't think this is security-relevant
or likely to be mistreated by a compiler, but UB is bad.

https://eel.is/c++draft/expr.static.cast#8

> If the enumeration type does not have a fixed underlying type, the value is unchanged if the original value is within the range of the enumeration values ([dcl.enum]), and otherwise, the behavior is undefined

Notably, the range is defined as the smallest bitfield type that could hold all the values, not any real type which exists: https://eel.is/c++draft/dcl.enum#8.

This is basically a footgun, and I'm writing a clang-tidy check to forbid casting to such types. But first I needed to write clang-tidy testing infrastructure: https://gerrit.lix.systems/c/lix/+/5493.

Change-Id: Ieaaa0fe2a92fd9f24f60761e312741186a6a6964
2026-04-22 10:52:04 +00:00
eldritch horrors 0a09782cc8 testing: migrate store-ping.sh
notably the bad-store test previously tested *bash*, not lix. we also
need to extend the list of non-fatal errors, but that's probably fine

Change-Id: I983f4adc8047fe800323099de4037711869ee547
2026-04-20 16:08:22 +00:00
Felix Uhl e3ee75633e Fix broken user override of NIX_SSL_CERT_FILE in fish shell
Change-Id: If15fac01104cc413102e417805c2e92aa9007eba
2026-04-20 13:02:17 +00:00
eldritch horrors d505a477a4 libstore: asyncify RemoteStore::openConnection
Change-Id: Icc7e705314b9a099687c37859700959139840631
2026-04-20 09:28:24 +00:00
eldritch horrors f006b41a3c libutil: transfer bind/connect errors from libexec helper
this should improve error messages when connecting to long socket paths,
and make it at all possible to detect ENOTDIR from connect helpers. this
will be needed to handle daemon sockets that live in directories we have
not previously considered like the protocol name directories we need for
rpc purposes, all of which would have resulted in hard errors previously

Change-Id: I4e16cf09fedd07c93cfdf7b0f151106984507315
2026-04-20 08:19:17 +00:00
Michael Daniels a5205265c0 manual: correct broken link to Gerrit wiki
Change-Id: Ida19e872da316c7d3170f0ef2bc60712c31b2ae1
2026-04-20 03:30:28 +00:00
Michael Daniels 23b2797321 lix/code-generation: correct link to changes for deprecated features
The link should be to Gerrit, not Forgejo.

Issue introduced in: https://gerrit.lix.systems/c/lix/+/5005

Change-Id: Ibf93f114303f59959621a265196e6eda29b315f9
2026-04-19 22:47:10 +00:00
skye 0e971cddee libexpr: Delete EvalState::mkSingleDerivedPathString dead function with Value& out param
Part of #1136, I believe this cleans up the final instance of `Value&`
used as an out parameter.

Change-Id: I40153b1f11d5ca9af06cd427f22896d06a6a6964
2026-04-19 12:45:56 -04:00
piegames 5afda956a7 tests/functional2/lang: Some refactorings
I did a pass through all files, fixing bits that have annoyed me here
and there based on vibes. Roughly:

- Replaced some out values like bools or strings with lists where
appropriate. Those tests were likely older than the value printer
- Added some parser tests where it makes sense
- Gently touched some formatting woes, while trying to not cause too
much diff noise
- Removed some dead `with (import ./lib.nix);` code

Change-Id: I8c40b2110f0b7799f68ae38ba61f049c5f1f6ee8
2026-04-19 16:07:54 +02:00
rootile ae4b3d585d f2/nix: provide a high-level wrapper for calling builtins
Change-Id: I357bd7630b96e55d000fbff1032efcf8c98dfb7b
2026-04-19 10:10:37 +00:00
rootile 62b728e766 f2/nix: provide a function to serialise python objects to nix code
Change-Id: I863029263edbc701a18b18da4b58fcb35f575614
2026-04-19 10:10:22 +00:00
skye 1e986c81ab Add test for duplicate JSON keys for builtins.fromJSON
Related to #1162
Currently if JSON with duplicate object keys is passed into `builtins.toJSON`,
it will silently drop all but the last value, keeping only the last.
This may be surprising, but as this has been consistent reliable behavior that
users might depend on, we should test for it.

Change-Id: Icc2adefabb161530e7cbfa7330919bab6a6a6964
2026-04-18 17:04:48 -04:00
eldritch horrors 36e784470c f2: turn Nix.daemon into a fixture
that way we can parametrize it over the list of protocols we have

Change-Id: Ie3fc267ade9c2ca74c163347f4fa58f09a317f40
2026-04-18 12:16:28 +00:00
Felix Uhl 32f48682de Fix test_doctor_shows_trust on macOS outside sandbox
Change-Id: I1fd456a8c5563ba63f795bc4e41811ebeaec9c73
2026-04-17 21:36:17 +02:00
rootile 15c95b95d6 tests/f2/nix: remove obsolete param documentation
Change-Id: I103d529ad0dd4ad482f9facb7e44baf61ab700d1
2026-04-16 15:05:05 +00:00
piegames c1f75860d6 builtins.flakeRefToString: Force the arguments
Without this, the primop chokes on any thunks on attributes passed in
the attrset. It even is the reason why the test contained `builtins.seq`
to work around this. Supposedly, this might have been an intentional
restriction and changing this might break things in ways I cannot forsee
due to not knowing much about Flakes, however the status quo is equally
broken:

- The error message looks like an internal error and not like some
explicitly forbidden invariant violation.
- Seemingly simple syntax literals like "-1" compile to "__sub 0 1" and
thus create a thunk which then fails, which is utterly confusing ("why
does 1 work but not -1?")
- This is a stark violation of the principle of least surprise.
- Thunking relies on maybeThunk and thunk inlining optimizations, thus
not forcing thunks turns operational details of the evaluator into
language-observable behavior. That's bad.

I am changing this now regardless of the risk of breakage, because the
bytecode evaluator will have different thunk inlining optimizations and
thus inevitably cause mismatches in behavior anyways.

Change-Id: Ifc45c4d2900e40822383670b28e4e50ab8af317a
2026-04-16 15:53:38 +02:00
blokyk 526bcac44a docs: clarify which characters are allowed in a derivation name
Although the fact that some characters are illegal in derivation names
was referenced in some parts of the docs, the actual list was not
documented anywhere, and the only source of truth seems to be the
[store source code](lix/libstore/path.cc).

This adds an admonition in the `derivation` docs that specifies which
characters and strings are actually allowed (especially since some
of them can be somewhat surprising, like the string "..-foo" not
being a valid name because of `..`).

Change-Id: Ibc4b4a141e262c21306ce9c0392f92cf0abe610a
2026-04-14 14:52:08 +00:00
blokyk 08d1e0c140 doc: fix incorrect docs for repl-overlays argument values
the docs say that the arguments for an overlay is info/prev/final, but
it's actually info/final/prev. this fixes the docs both in the nix.conf
manual as well as in the `nix repl` help text

Change-Id: I3de5c122e7e77cc3f4e4550e3741d6a6e906ea20
2026-04-14 11:07:52 +02:00
Maximilian Bosch ebf48c14f0 flake: static build in CI
That way we can automatically push the static build (compressed as
tarball) into the AFNix S3 bucket and have it updated on each update to
main.

Change-Id: I1002727ab12c0ab6b95c8d37ae4620996607d7b7
2026-04-13 22:46:30 +01:00
skye 01f2fabe14 doc: Update Nix Resources link in Quick Start chapter of manual (#1179)
This applies the suggested change in #1179, replacing a dead link with a
link to the content's new location. Closes #1179.

Change-Id: I543e3308516218e224e495b8cf14a7c06a6a6964
2026-04-13 14:18:09 -04:00
Yureka 9899ed29cc flake: fix condition for using lowdown 3.0
Change-Id: I6832c249da77a80b4e1e79015976156ce1eb1b0b
2026-04-11 22:42:14 +02:00
skye e79278b4fc Check for throw while evaluating throw message
This is a small tweak to the logic added in cl/1511 to detect explicit
throws when printing stack traces. Now when deciding whether to print
"caused by explicit throw", it checks not only that the error is a
ThrowError and that we are in a throw, but also that the ThrowError was
thrown by *this* throw, and not by another while in the process of
evaluating this throw's operand.

It turns this:

```
let
  set = {
    inner = throw "nested throw";
  };
in
throw set.inner

error:
       … caused by explicit throw
         at /pwd/in.nix:6:1:
            5| in
            6| throw set.inner
             | ^
            7|

       … while evaluating the attribute 'inner'
         at /pwd/in.nix:3:5:
            2|   set = {
            3|     inner = throw "nested throw";
             |     ^
            4|   };

       … caused by explicit throw
         at /pwd/in.nix:3:13:
            2|   set = {
            3|     inner = throw "nested throw";
             |             ^
            4|   };

       error: nested throw
```

into this:

```
error:
       … while calling the 'throw' builtin
         at /pwd/in.nix:6:1:
            5| in
            6| throw set.inner
             | ^
            7|

       … while evaluating the attribute 'inner'
         at /pwd/in.nix:3:5:
            2|   set = {
            3|     inner = throw "nested throw";
             |     ^
            4|   };

       … caused by explicit throw
         at /pwd/in.nix:3:13:
            2|   set = {
            3|     inner = throw "nested throw";
             |             ^
            4|   };

       error: nested throw
```

Notice the difference in the top context frame. Before it incorrectly
attributed the throw error to the both throws instead of just the one
that actually threw.

Change-Id: If3b0b8311f1ae2ff1471e260fe59d9166a6a6964
2026-04-11 12:46:24 -04:00
Yureka 9fea1b816f flake: allow using nixpkgs lowdown 3.0
Admittedly, I do not understand what the comment means:

> As soon as Nixpkgs updates to >= 3.0.0, change to lowdown_2_0!

But this should work fine for nixpkgs versions providing lowdown 2.x or
3.x, and not cause rebuilds of the nixpkgs Lix/Nix derivations.

Change-Id: I6fb9e775335b4dbc23add76b98106970956e19fb
2026-04-11 14:17:37 +00:00
Florian Klink 6c7ccc2588 libcstore: Fix null deref in writeDebugInfo for non-directory NARs
When index-debug-info is enabled and the store path being copied is a
regular file (not a directory), std::get_if<nar_index::Directory>
returns nullptr since the NAR root is a File variant. The loop then
immediately dereferences buildIdDir->contents on the null pointer,
causing a segfault.

Add a null check at the top of the loop to break early when the NAR
root is not a directory.

Change-Id: I3a6e792b84cc12c837ecaddf4fee889e1bcb6397
2026-04-11 12:33:46 +00:00
skye fce5777f9c libexpr/primops: Migrate primops to return Values
A significant part of #1136.
This is a rather large cl, because all of the primops need to be changed
together.

Change-Id: I7d92698d5344bd6186ee4fa47f5c21966a6a6964
2026-04-07 23:38:08 -04:00
skye bc9fb560ac libexpr/primops: Migrate addPath to return a Value
Part of #1136

Change-Id: I079da96c1ed7e7396e5f71b444e4e7b66a6a6964
2026-04-07 23:36:12 -04:00
skye 50aeb770e5 libexpr/primops: Migrate derivationStrictInternal to return a Value
Part of #1136

Change-Id: If00bc51c7ebd5ccd99a883788bc1ec506a6a6964
2026-04-07 23:35:12 -04:00
skye fe38b58e50 libexpr/primops: Migrate helper fn fetch to return a Value
Part of #1136

Change-Id: I5b21998d437aa82fb89e75b0b645269a6a6a6964
2026-04-07 22:40:04 -04:00
skye a1f52a1ce6 libexpr/primops: Migrate helper fn fetchTree to return a Value
Part of #1136

Change-Id: Icb79dfc99f530a2965199954ce784e166a6a6964
2026-04-07 22:39:30 -04:00
skye 6640ba572f libexpr/primops: Migrate helper fn anyorall to return a Value
Part of #1136

Change-Id: Id1aa3225d7c337dee72d070ef764c6006a6a6964
2026-04-07 22:38:52 -04:00
skye aed5b5cbce libexpr: Migrate EvalState::concatLists to return a Value
Part of #1136

Change-Id: Ie28ee8456191b3da20d53e95ea49e0ec6a6a6964
2026-04-07 22:38:24 -04:00
skye c01bd37a8d libexpr/primops: Migrate helper fn elemAt to return a Value
Part of #1136

Change-Id: Ib3c7040c7df729737643d3a9b833773d6a6a6964
2026-04-07 22:38:02 -04:00
skye 658404c2a0 libexpr/json-to-value: Migrate parseJSON to return a Value
Part of #1136

Change-Id: I5ac23ce461a106360b150e64a6bc0f2f6a6a6964
2026-04-07 22:37:44 -04:00
skye bb9f9cf553 lixexpr/primops: Migrate import helper fn to return a Value
Part of #1136

Change-Id: Ia2cdd540a105ae874430c0f6ba456d4d6a6a6964
2026-04-07 22:37:25 -04:00
skye 86126d6c89 libexpr: Migrate EvalPaths::allowAndSetStorePathString to return a Value
Part of #1136

Change-Id: Icf16109a63f1b8114e0af9db0a9213c46a6a6964
2026-04-07 22:35:12 -04:00
Tom Hubrecht cbeb4fcd69 repl: Fix the use command
The culprit was a space added at the wrong place, which messed with c++
raw strings.

Fixes #1178

Change-Id: Ic1e09cb7215d9a6dd2d13fd92242649b0e1fcd13
2026-04-07 11:02:53 +02:00
Qyriad d0190cff6f improve justfile, and add more docs about it
Change-Id: I00286276dc0ce17a5877a7bd13bb254d6a6a6964
2026-03-28 19:08:37 +01:00
rootile 76499d36ea f2/nix: rename _serialise to _serialise_config
Change-Id: Icaa10bf615ae5fa6d3a3957f74055c9d76f67483
2026-03-28 14:06:26 +01:00
rootile 3bc59b6e0a f2/testlib: fix typechecking for None values
Change-Id: Ie744be23d2b7963d8cd8f80cfeae051249e34d34
2026-03-28 14:06:26 +01:00
blokyk 001e3fde8f docs: add section about overlays in nix repl --help
I just copied and slightly edited the `man nix.conf(5)` docs about
`repl-overlays` to the nix repl help text (but cut out the more
complicated example and redirecting to the nix.conf docs for more
info).

Fixes #303

Change-Id: I85efaef606d8779ac66fe72cd3947d663f33fa44
2026-03-27 10:41:45 +00:00
skye 03ab7b4a76 package.nix: Remove unused linuxPackages input
This input was added in cl/2884, but was unused even then. The
`linuxPackages` within `buildPackages` is used instead.

Change-Id: I71c522ef683aa098eac0b356b22007ba6a6a6964
2026-03-24 11:43:30 -04:00
skye b94d615baa libexpr/json-to-value: Replace add with addValue and define TopLevelJSONValue
Calls to JSONState::add() always followed an assignment to
JSONState::value(), resulting in the new value going through
JSONState::v for no good reason. The only use of `v` outside of a
pointless stepping stone for `add` was to store the final top-level
Value before it is read out by JSONSax::result(), so it really only
makes sense for the top level JSONState to contain Value field.

Change-Id: I1758c7b770eb4b0c122e501b764dd42b6a6a6964
2026-03-23 19:37:27 -04:00
piegames 35b776540f libutil/LinearMap: Expose rbegin and rend functions
Change-Id: I9a4350cc147c98c785b26fbef6c235cd5c48a4cc
2026-03-23 14:47:39 +01:00