Commit Graph
17805 Commits
Author SHA1 Message Date
eldritch horrors dad17a54f7 libexpr: remove Value::determinePos
it was mostly useless, and now it's entirely unused.

Change-Id: I015c83779a7f860e325796684639f05083a50676
2025-04-27 17:38:57 +00:00
eldritch horrors c068aeaf61 treewide: don't determinePos in autoCallFunction
add a position parameter to the autocaller instead, and pass it much
more accurate position information where we have it easily available

Change-Id: If2f1c3006ca3f2b413492842905d079a8b752542
2025-04-27 17:38:57 +00:00
eldritch horrors db738ddb14 libexpr: don't determinePos in derivationStrictInternal
errors for individual attrs should report the position of the attribute,
not the position of the set they were taken from (which we'll assume was
the intent here). this is already the case for most attributes, only the
the extra-special __structuredAttrs and __ignoreNulls weren't annotated.

this includes not calling atPos(v) on errors builders since the position
of v is always invalid. error messages are unchanged by this part of the
patch (and the caller adds a trace pointing to the derivation name too).

Change-Id: Ia3540f9ce1f2505275e49dd4e4336b2a59d5b336
2025-04-27 17:38:57 +00:00
eldritch horrors abc26ca0d2 libexpr: don't determinePos in ExprBlackHole::eval
`v` is invalid, its position (if it exists at all) will be stale.

Change-Id: I79147c92fe6b2b077a9aa4783231b7aac05ef9d2
2025-04-27 17:38:57 +00:00
eldritch horrors 859c8caae2 libcmd: don't determinePos in repl
replInitFilesFunction is always valid, but pointing to it is misleading
because the source is inaccessible. every replInit is better identified
by its path if it isn't a lambda; determinePos will return noPos anyway

Change-Id: I0b6fcd2f95f121a802c87cb1085d3a0b1c585aeb
2025-04-27 17:38:57 +00:00
eldritch horrors ff776f5091 libexpr: don't determinePos for primop calls
it's pointless, they don't have position information.

Change-Id: I21f49e4d26f9ed7bc3772157882c84447f8e6387
2025-04-27 17:38:57 +00:00
eldritch horrors bdebc3797b cmd/libexpr: don't determinePos in value-to-json
it's not useful. nix-instantiate will always point to the wrong location
because "at the toplevel" is not a position we can point to. all nesting
conversions will point to strange places: the *original* definition of a
lambda value (or partial applications thereof), or nowhere at all (since
only lambda values can have their positions determined in the formatter)

Change-Id: I56bd9e1cf3cae11b4198f148a141ca758e4fe8ac
2025-04-27 17:38:57 +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
eldritch horrors 9d761ed5c1 nix: don't determinePos in flake check
by the time enumerateOutputs is called we've already established that
vFlake will evaluate to an attrset (as a locked flake it can't be any
other kind of value). the outputs attribute is likewise already a set
because the nix code that builds it says so. adding positions here is
merely an unnecessary debugging aid for developers working on flakes.

Change-Id: I2a10ddf1400f7650c6e303433f9fee8813f0188d
2025-04-26 22:14:05 +02:00
eldritch horrors 8a1b86631c treewide: don't determinePos for forcing
only attrsets, lambdas, and app nodes can have positions determined, and
none of these three types are incomplete. calling determinePos before we
force a value is thus only a convoluted copy operation for its argument.

Change-Id: I7e647aacca1fc8250f7bb11bb0071a4f7186047f
2025-04-26 22:14:05 +02:00
Raito BezariusandLix Systems Gerrit 9cc0cda16f Merge "libstore/ssh: fix the SSH connectivity check with non-POSIXy shells" into main 2025-04-26 11:06:49 +00:00
K900andeldritch horrors 227e4d349f libstore/ssh: fix the SSH connectivity check with non-POSIXy shells
SSH runs the command provided to it in the user's login shell.
That's a feature and is impossible to bypass (trust me, we tried).

The previous implementation of `echo started; nix-store --stdio`
broke with shells that treat `;` differently, e.g. nushell,
which eats the output of everything but the last command in a chain.

In the more general case, this means that a sufficiently weird shell
can do _anything_ it wants to the command we pass via SSH, so
we're forced to rely on as little functionality as possible.

The subset we're hereby settling on is just "running `bash` runs bash".
We then run bash, in non-interactive mode, which gives us a somewhat
consistent environment do to things in.

This whole thing is extremely cursed, but fixing it _correctly_
requires pretty much entirely rewriting how remote stores work,
and I'm not doing that right now.

Fixes #805.

Change-Id: Icac846e8cd821cbca91860ddaa0f657b4317dbf8
Co-authored-by: eldritch horrors <pennae@lix.systems>
2025-04-26 13:46:16 +03: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
Tom Hubrecht 834133c1d5 chore(docker.nix): Replace mapAttrsFlatten by mapAttrsToList
The former is deprecated

Change-Id: I9e2a7656e257afe321183b7f6c30deab47ebb61a
2025-04-25 11:13:11 +02:00
Raito BezariusandLix Systems Gerrit a133633ecc Merge "lixexpr: Declutter error traces" into main 2025-04-24 19:07:06 +00:00
2b22dae1ba lixexpr: Declutter error traces
Now that we can correctly point to all expressions, we can remove
redundant intermediate traces to reduce clutter.

Co-authored-by: eldritch horrors <pennae@lix.systems>
Co-authored-by: Raito Bezarius <raito@lix.systems>
Change-Id: I3e9d7c1c7a6599a8e68302448bbb961d051002b7
2025-04-24 20:44:57 +02:00
Raito BezariusandLix Systems Gerrit c36c83c4c6 Merge "dtrace: fix on macOS (except in the package)" into main 2025-04-24 16:33:48 +00:00
eldritch horrors feebecd60b treewide: wrap std::regex_error
otherwise lix may crash when e.g. nix search receives invalid regex.
we now also give better error messages for regex errors during eval.

fixes #803

Change-Id: Icc7c578ff488ba520efac5d898572ccf4486e9a8
2025-04-24 13:48:15 +00: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
Linus HeckemannandLix Systems Gerrit 14055866dc Merge "libexpr/get-drvs: improve error messages on bad outputsToInstall" into main 2025-04-22 15:35:54 +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
giliceandLix Systems Gerrit 930ac12346 Merge "libutil: canonPath: error instead of panic on empty path" into main 2025-04-21 15:35:54 +00:00
eldritch horrors 9bb24a5cdb libstore: SSHMaster master -> SSH ssh
we no longer explicitly configure these ssh options, so we now
have *even less* reason to stick to old and awful terminology.

Change-Id: I8f38f5486e6918f69c61ddc2d6882b6bb50554c6
2025-04-21 13:43:44 +00: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
helle 2238f7a8ab Replace existing external command/custom sub command tests with functional2 tests
This removes the bash dependency issue that the previous test had, the
tests are translated roughly 1 to 1 and do not address any of the TOD
list items.

Closes #800, also superceeds I81817b9fe4a5eeb019f7e04b5a60e091bbde26b2

Change-Id: Ie440cd0a602d4ca4a48edcaf517b7358ec572710
2025-04-19 20:09:44 +02:00
Linus Heckemann aeb27b2e25 libexpr/get-drvs: improve error messages on bad outputsToInstall
Change-Id: I6540f4e77c0d98f357f6f3960bfe3ce4d1c3c6fb
2025-04-16 11:20:48 +02:00
gilice 341e6049a7 libutil: canonPath: error instead of panic on empty path
This could previously crash lix:

Before:
$ nix eval -E '{type="derivation"; drvPath="";}'
nix: lix/libutil/file-system.cc:45: Path nix::canonPath(PathView, bool): Assertion `path != ""' failed.
Aborted (core dumped)

After:
$ nix eval -E '{type="derivation"; drvPath="";}'
error:
       … while evaluating the drvPath of a derivation
         at «string»:1:21:
            1| {type="derivation"; drvPath="";}
             |                     ^

       error: path '' is not in the Nix store

Fixes #536

Change-Id: I406dc9e58047be8f263cf2e4bc3ed5da75a46602
2025-04-12 16:31:28 +02:00
jadeandLix Systems Gerrit 81d4769849 Merge "fix: make test/ headers compliant with styleguide" into main 2025-04-10 16:25:52 +00:00
FireFlyandLix Systems Gerrit 6b3162be9c Merge changes Idd20d965,I27e2c7d8 into main
* changes:
  tests: fix deprecated of googletest macro use
  tests: ignore deprecated uses in rapidcheck
2025-04-10 11:48:09 +00:00
Jade Lovelace c0de512e14 fix: make test/ headers compliant with styleguide
These were not included in that check. Beats me as to why.

Change-Id: Ib44c7f0b10672359026f95daeb088039cf6df4eb
2025-04-09 23:46:41 -07:00
SkyeandLix Systems Gerrit 73114a1b8b Merge "Clean up includes" into main 2025-04-09 18:00:08 +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
FireFly 478253b16a tests: fix deprecated of googletest macro use
Change-Id: Idd20d9659116c352f05876acd91f5c3d8325f097
2025-04-09 17:15:19 +02:00
FireFly a8c3fbf0cc tests: ignore deprecated uses in rapidcheck
There is a pull request [1] addressing these upstream--it doesn't appear
likely to be merged anytime soon though... this is a no-op til we enable
-Wdeprecated-declarations, but helps in the direction of #744

[1]: https://github.com/emil-e/rapidcheck/pull/325

Change-Id: I27e2c7d81df152de8674696f2a56d5f21c414ce3
2025-04-09 17:04:42 +02: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
skyrelia ba1c9d52ec Clean up includes
This cleans up includes that clangd reports as unused, usually by deleting the offending include. The process was to delete an include and see if it still builds. If not, try to find a more specific include(s) that works, that was previously transitively included. If the original include seems intended to re-export said transitive include, mark the transitive include as `// IWYU pragma: export`. Otherwise, replace the original include with the transitive include(s). If none of the above applies, because the original file depends on code directly in the include somehow, or the direct include is an external dependency that cannot be modified, restore the original include and mark it as `// IWYU pragma: keep`.

Change-Id: I5ce3d34dad76b0cad0a6a7990fea13add393aad3
2025-04-08 12:13:42 +00:00
Commentator2.0 fb0ef6ca6b Made parser warnings use Error info
no other warn calls were found, which have position information

Change-Id: If9773b86a756e5b2e4096d3f6b3a5114bfed5bee
2025-04-08 10:21:53 +02:00
eldritch horrors 2ef4b69760 libutil: disallow implicit ref creations
448c7d50e1 was a bit over-eager and didn't
make the `ref(enable_shared_from_this &)` constructor explicit. this has
confused hydra maintainers, and is just generally bad practice since any
reference is allowed to implicitly convert, even if those references are
not associated with an active control block. we can't avoid this problem
entirely, but we can make what happens more explicit by ... well, making
the involved constructor explicit. enable_shared_from_this is statically
unsafe in principle and we really have to get rid of this nonsense soon.

Change-Id: I8b48ef4353e6301b61af3569083f42bc7379b0a4
2025-04-06 20:29:25 +02:00
eldritch horrors b4c6bfd72a libutil: trace unwinding through async tasks
this gives us a semblance of a stack trace if async tasks fail, like:

    Async task trace (probably incomplete):
    #0: virtual kj::Promise<Result<Goal::WorkResult>> nix::LocalDerivationGoal::tryLocalBuild() (lix/libstore/build/local-derivation-goal.cc:257:33)
    	building of '//0ppb5aj4p3vp0icnkq4yibajw1czvdja-bash52-009.drv^out' from .drv file
    #1: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::outputsSubstitutionTried() (lix/libstore/build/derivation-goal.cc:381:47)
    	building of '//0ppb5aj4p3vp0icnkq4yibajw1czvdja-bash52-009.drv^out' from .drv file
    #2: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::loadDerivation() (lix/libstore/build/derivation-goal.cc:213:41)
    	building of '//0ppb5aj4p3vp0icnkq4yibajw1czvdja-bash52-009.drv^out' from .drv file
    #3: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::gaveUpOnSubstitution() (lix/libstore/build/derivation-goal.cc:453:62)
    	building of '//f8rkb1vam9y9vi9scsm1v213b01rm72h-bash-5.2p37.drv^out' from .drv file
    #4: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::outputsSubstitutionTried() (lix/libstore/build/derivation-goal.cc:381:47)
    	building of '//f8rkb1vam9y9vi9scsm1v213b01rm72h-bash-5.2p37.drv^out' from .drv file
    #5: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::loadDerivation() (lix/libstore/build/derivation-goal.cc:213:41)
    	building of '//f8rkb1vam9y9vi9scsm1v213b01rm72h-bash-5.2p37.drv^out' from .drv file
    #6: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::gaveUpOnSubstitution() (lix/libstore/build/derivation-goal.cc:453:62)
    	building of '//qa9jvc4j6fphzwr63k5c829b2hr04q6z-foo.drv^*' from .drv file
    #7: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::outputsSubstitutionTried() (lix/libstore/build/derivation-goal.cc:381:47)
    	building of '//qa9jvc4j6fphzwr63k5c829b2hr04q6z-foo.drv^*' from .drv file
    #8: kj::Promise<Result<Goal::WorkResult>> nix::DerivationGoal::loadDerivation() (lix/libstore/build/derivation-goal.cc:213:41)
    	building of '//qa9jvc4j6fphzwr63k5c829b2hr04q6z-foo.drv^*' from .drv file
    #9: virtual kj::Promise<Result<void>> nix::Store::buildPaths(const std::vector<DerivedPath> &, BuildMode, std::shared_ptr<Store>) (lix/libstore/build/entry-points.cc:20:11)

it's not much, but it's a lot better than nothing. sadly we're forced
to disable another clang-tidy warning now, but since that one's about
assert side effects being compiled out in release mode and we've long
since decided to just not do that we are not affected by this at all.

also see #724 for a related but different approach to origin tracing.

Change-Id: I8161f82ca39d0b271316ea4df80513acc1b06a03
2025-04-06 12:14:51 +02:00
eldritch horrors 8d8bb60796 treewide: lint against non-lix exceptions
we generally do not want to catch or throw these. catching them to print
and discard is fine, tests are largely exempt, and cases in which we can
be certain where the exception came from are also fine to *catch*. we'll
try to never *throw* (or rethrow) these if possible though because doing
so will make it impossible to construct async traces for the exceptions.

Change-Id: I3b71c32ecd16afc2246c946472f5629a1fa31f2c
2025-04-06 12:14:38 +02:00
eldritch horrors 63d550938b treewide: derive all lix exceptions from BaseError
even the non-errors. we should probably insert a BaseException here.

Change-Id: I1b1af8ba0bf49251fe9d1a24c6559db3ef4a59d2
2025-04-06 11:52:32 +02:00
eldritch horrors 8506a2aa00 libutil: add ForeignException
this wraps a non-lix exception so we'll be able to add async traces. to
not interfere with existing infrastructure we also add a BaseException,
deriving from BaseError would have foreign exceptions match on the very
broad catches we have in libmain even though we want these logged only.

Change-Id: I5545788c299e9bbdb4d730458914bfd816870794
2025-04-06 11:52:30 +02:00
FireFlyandLix Systems Gerrit f24eeae6e6 Merge "libstore: move away from deprecated curl calls" into main 2025-04-06 09:14:08 +00:00
FireFly 14252cb4a8 libstore: move away from deprecated curl calls
CURLINFO_PROTOCOL [1] is deprecated in favour of CURLINFO_SCHEME, which
unfortunately requires a case-insensitive string check to tell the URL
scheme used.  While we're here, also cache the status code returned from
`getHTTPStatus`.

CURLOPT_PROGRESSFUNCTION [2] is deprecated in favour of
CURLOPT_XFERINFOFUNCTION, which simply uses more appropriate types for
the parameters of the callback.

Another step toward fg#744

[1]: https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html
[2]: https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html

Change-Id: Icd1feacad45ab5df71d95f4ef370df41ee1393ea
2025-04-06 00:13:20 +02:00
eldritch horrors 949a561540 libutil: explicitly mark ref(shared_ptr) as unsafe
we'll also assert instead of throwing an exception because that just
seems more useful. this should never *ever* happen, and it is on the
callers of such conversions to ensure that the conversion *is* safe.

Change-Id: Ib0696af4f037046f2d45bf5b1b255393ea9b5f05
2025-04-05 21:57:45 +02:00
eldritch horrors dd8dbb56fc libutil: make ref casts safer
don't throw if a downcast fails, have that particular casting method
return an optional instead and check the result at the call site. we
also rename dynamic_pointer_cast to try_cast_shared for consistency.

Change-Id: I65ee0fb498b1b2b8b418935fce4358a654f984e5
2025-04-05 21:57:45 +02:00
eldritch horrors 448c7d50e1 libutil: add shared_from_this support to ref
we don't need to unsafely cast a shared_from_this pointer to create a
ref (the pointer must be non-null to not invoke nasal demons anyway).

Change-Id: I133fe5f07b2cff8ec2c925f0528f4c5288827261
2025-04-05 21:57:45 +02:00
eldritch horrors aa358eac91 libutil: remove unused ref constructor
this one is dangerous anyway.

Change-Id: Id4fb777fff516cdb6a6e8e0b2fd7611418ae2e49
2025-04-05 21:57:45 +02:00
eldritch horrors c4b8b92904 treewide: store optional refs as exactly this
don't store them as shared_ptrs and cast them back to ref when needed.
we have sufficiently few instances of this pattern that we can spare a
few bytes to make the code less implicitly unsafe (and a bit clearer).

Change-Id: Ied573ab2e116ae228730390ff4c6b0469c59ff6a
2025-04-05 21:57:45 +02:00
eldritch horrors 14db530ac0 libexpr: restrict EvalErrorBuilder to building EvalErrors
Change-Id: Iadd0fee4c12c5d0b6ee74dccbf8785c829d20d95
2025-04-05 21:57:45 +02:00