Commit Graph
2480 Commits
Author SHA1 Message Date
Erik Jensen eef57410d7 Fix nix-copy-closure --include-outputs
The option has been broken since Nix 2.4. The flag was accepted, but not
used. This change plumbs it through to computeFSClosure.

Change-Id: Id6adee8ea8a6a4f457b24b650660f319e3daa2b2
2026-05-26 19:40:07 +00:00
Linus Heckemann 8edb857248 libfetchers: lock inputs before fetching them
Fixes #1122

Change-Id: I9243e692779a795066417a15c6315dd56a6a6964
2026-05-26 15:14:13 +00:00
Linus Heckemann 1f100371d7 doc/hacking: switch buildkite sso url to afnix
Change-Id: I7f7e65fe2dc52b40d4771e59198dd66a6a6a6964
2026-05-18 18:13:47 +02:00
piegames 481fc30ae7 libexpr/flakes: Replace the AST checks with maxCallDepth = 0
Change-Id: I7130cc941b4b7432df76a3995d298edfb28e6a01
2026-05-06 17:22:19 +02:00
eldritch horrorsandRaito Bezarius 2f7d7444f1 libutil: fix nar parser buffer overflow
string data shares a buffer with the binary string length field. size
calculations for string read buffers always include the length field;
sufficiently large length fields can cause these calculations to wrap.
a malicious nar could use this for OOB writes in the daemon (as root).

since we use strings only as tags for archive members and for symlinks
with their OS-dependent length limits we can simply limit string size.
1 MiB should be sufficient for all symlinks, and tags are always tiny.

Change-Id: I89fb05f73c1dbeda45d91244aba4cd526a3d83e1
2026-05-04 19:00:19 +02:00
Lunaphied cd573beb0a docs/hacking: fix to respect changes in justfile
We no longer have setup-custom, just use setup

Change-Id: I2a151d04dc3d90a98b79859b05c4e6706a6a6964
2026-05-01 11:12:54 +00:00
Jade Lovelaceandrootile e70ae36b3f libexpr/builtins: correctly handle integer edge cases in floor/ceil
We choose to throw an error in the invalid-input space where we *can*
produce a valid (but wrong) result to allow ourselves to, mirroring
CppNix, change the semantics to not corrupt it at all in the future,
while having a middle state where it is an error.

This is a largely-rewritten version of
https://github.com/NixOS/nix/pull/13013.

Co-authored-by: rootile <lix@rootile.de>

Fixes: https://github.com/NixOS/nix/issues/12899
Upstream-PR: https://github.com/NixOS/nix/pull/13013
Change-Id: I6a6a6964cdd1a88714952e80c660d1fa57d1f2d8
2026-04-30 16:10:47 +02:00
blokyk f8b13b254b libcmd/repl: print backtraces from outer to innermost frame
before this change, the innermost frame was all the way at the top,
which means that in very nested code you'd have to scroll though
dozens or hundreds of frames before even seeing where you are, because
the last lines (which are immediately visible when the command returns)
would be the nix code's entry point and other outer frames instead,
which is rarely relevant.

this CL reverses this order, so that the innermost frames are the last
ones printed, and thus are immediately visible. (note that this is
already how errors are printed by nix in other contexts anyway, the
debugger's :bt is the only thing that prints the trace in "forward"
order.)

because `DebugState.traces()` use the homegrown `libutil::Generator`
instead of an stdlib container, we have to do that reversing ourselves,
in this case by just storing every element in an `std::list` (in reverse
order) and then traversing it. this is feels kinda dirty, but i don't
know any other way, and it's not exactly performance-critical.

Change-Id: I9f23e40e57f72a251d65a335b3bba3c3f77b935d
2026-04-28 12:09:13 +02: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
Michael Daniels a5205265c0 manual: correct broken link to Gerrit wiki
Change-Id: Ida19e872da316c7d3170f0ef2bc60712c31b2ae1
2026-04-20 03:30:28 +00: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
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
Qyriad d0190cff6f improve justfile, and add more docs about it
Change-Id: I00286276dc0ce17a5877a7bd13bb254d6a6a6964
2026-03-28 19:08:37 +01:00
Maximilian Bosch 0488a0181d libcmd: allow setting nested attributes via --arg/--argstr
Closes #496

When running

    nix-build ../nixpkgs --arg config.allowUnfree true -A hello-unfree

the package `hello-unfree` is now built rather than getting an
eval-error rejecting instantiation. This is because `config.allowUnfree`
is now interpreted as nested attribute-set declaration, similar to how
it's done in `nix repl`.

To prevent sudden breakage, this behavior was carefully deprecated with
Nix throwing an error if the identifier for `--arg` is not a pure
identifier, but an expression as above.

Any kind of merging is rejected. I.e. doing

    nix-build ../nixpkgs --arg config '{cudaSupport = true;}' --arg config.allowUnfree true

is prohibited. That way we don't have to think about merge semantics for
cases like this (or even worse `--arg config 'rec { ... }'`). Another
nice side-effect of this is that we don't need to create an EvalState to
force the values and implement merging.

Change-Id: I8b560883a4468a3f32f915764b08f5fdd8fe71bb
2026-03-21 23:16:30 +01:00
Maximilian Bosch 2a11984a58 libexpr: allow empty attr-names in parseAttrPath if they are quoted
While it doesn't make sense to have `foo..bar`, the attribute-path
`foo."".bar` is valid and shouldn't throw.

Change-Id: Ifcddaad6233c6ba8f17cb5c953c2101d276dfeb6
2026-03-21 23:16:30 +01:00
blokyk 66d702d28d libexpr/primops: make break force its argument
previously, `builtins.break` didn't force its argument, resulting in
a value wrapped with `break` being opaque to most builtins if not
also wrapped with `seq`. see [lix-project/lix#1165] for more details
on what this can break.

this tiny fix just adds a call to `forceValue` inside `prim_break`,
but unfortunately this "breaks" a few existing tests because it
changes the call stack; those tests' golden outputs have been adjusted
without modifying their intended purpose.

Fixes #1165

[lix-project/lix#1165]: https://git.lix.systems/lix-project/lix/issues/1165

Change-Id: I5fe4ee3ff28b38aaf924125b8978130812e58fef
2026-03-21 18:38:43 +01:00
blokyk daadfed9ae libcmd/repl: allow :st argument to be relative to current stack index
See [lix-project/lix#1156], but basically currently the `:st <n>`
debugger command doesn't allow any negative indices, and putting a plus
sign in front of the arg doesn't change anything; thus, we can exploit
that "design space" to allow users to move between different stack
frames easily, by simply prepending their arg with a +/- sign.

The actual behavior is little more nuanced when you account for errors:
as suggested by @pennae (thanks! :), when the user inputs an offset that
would result in an invalid frame index, the debugger instead clamps it
to the closest bound (i.e. 0 for negative offsets, $maxFrame for
positive ones) and just prints a warning.

Fixes #1156

[lix-project/lix#1156]: https://git.lix.systems/lix-project/lix/issues/1156

Change-Id: I02a0cdb6aaebbdb0515308880a3bf9c0d2fcd25e
2026-03-20 18:22:24 +01:00
blokykandeldritch horrors 6e1e76f10f libcmd/repl: print error for invalid :st argument
currently, the `:st <n>` command in the debugger will simply silently
fail if the argument cannot be converted to an integer, or if it falls
outside the range of valid stack indices. this isn't too big of problem,
but it can be nicer to tell the user something went wrong, rather than
not give them any output and having them guess (esp. in the second case).

this commit adds two errors, one for each case:

  1. the argument is not actually an integer, or is outside INT_MIN/MAX
     -> "argument '%arg' is not a valid integer"

  2. the argument is an integer outside the range of stack traces
     -> "stack index must be between 0 and %max_frame, but was %arg"

Change-Id: I8109feeede79a9ad3db9ee7dc95d37e7dd19741a
2026-03-18 13:15:13 +00:00
sterni f7d7b5d93f libcmd: remove support for lowdown < 1.4.0
NixOS 25.05 which distributed lowdown < 1.4 has been EOL for a bit now,
25.11 ships lowdown 2.0.4.

Dropping support means we can tweak the lowdown options for terminal
output which have been added in 1.4.0 without having diverging behavior
in possible builds of Lix.

Change-Id: Icae97cf5e9e680766b8a6f4e85514f4c4625d1dd
2026-03-17 21:38:42 +00:00
Linus Heckemann f87d753987 libexpr: print flake config warning to stderr
Fixes #1155

Change-Id: Ie63f9200f7c06b1eec6c52518d6f523f6a6a6964
2026-03-17 07:10:00 +00:00
Jade Lovelaceandeldritch horrors 2cea406121 version.json: begin the 2.96 series
Change-Id: I21c37e20fc2e5786367aa9b6e5ebb7ba12eb8b6c
2026-03-13 22:59:53 +01:00
Jade Lovelace dc7d5c45a4 release: release notes for 2.95.0
Release created with releng/create_release.xsh

Change-Id: I4cb4c81a440787fe5417369e5a058c8bb51c0cb1
2026-03-13 09:06:04 -07:00
rootile a05dbd2d7f docs: fix typo in distributed builds
Change-Id: Ie0bf1e6f2cecade786647aab1030279b57b7efb7
2026-03-13 16:24:51 +01:00
Raito Bezarius 7c53a2cf9c manual/rl-next/f1-lang: reduce CLs to 1 in the chain
This avoids a large list of CLs when a user can discover all the CLs by
browsing the chain.

Change-Id: I1890eb87e8bf6f930d3d00c3f7156690bb8de068
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-03-10 17:09:22 +00:00
Raito Bezarius 5789f4b0a9 manual/rl-next: fine-tune the release notes
Follow up of https://gerrit.lix.systems/c/lix/+/5346?tab=comments for
the obvious pieces.

Change-Id: If0f640f786b0778d016187cb24c0513a48b5a30b
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-03-10 17:09:22 +00:00
rootile 03edd9f75d release-notes: add horrors to deprecated features credits
Change-Id: I73ed3198cfdbab15edddc9393010cafdf5050176
2026-03-09 22:44:29 +00:00
Raito Bezarius 31a4f4547a Revert "libexpr/primops: allow storePath in pure evaluation mode"
This reverts commit 37ccd28c3b.

Reason for revert: https://git.lix.systems/lix-project/lix/issues/1147
More impurities were introduced than we wanted.

Fixes #1147.

Change-Id: Iec3b1d0e9a77484a68c6d9307a7a527fda236ed2
2026-03-05 17:09:46 +00:00
b7cf773540 libexpr: warn when encountering IFD with warn-import-from-derivation
This is intended to be a softer version of
`allow-import-from-derivation`, allowing for users to only flag when IFD
is encountered rather than error out

Based-on: https://github.com/NixOS/nix/pull/13279
Co-authored-by: gustavderdrache <alex.ford@determinate.systems>
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Change-Id: I879a444e3a24b4e82a8cea3a5a94834c78c3924a
2026-03-05 13:39:12 +00:00
Raito Bezariusandeldritch horrors 37ccd28c3b libexpr/primops: allow storePath in pure evaluation mode
`builtins.storePath` allows you to use "external" knowledge of present
store paths in your store to be used in your expressions.

This is sometimes used to avoid double wrapping store paths, for example
when dealing with nixpkgs sources (`builtins.storePath pkgs.path` is a
frequent pattern).

Unfortunately, using your external knowledge of present store paths is
technically impure because Flakes is about not depending on the *STATE*
of your store, no matter what you know about it or what you do to ensure
that your knowledge is accurate.

That being said, `builtins.storePath` is already possible in the
fragment of "pure Nixlang" via a clever use of `builtins.appendContext`.

Precisely:

```
  storePath = path:
  let path' = builtins.unsafeDiscardStringContext path;
  in
  # NOTE: merging the context set in all generality is impossible
because getContext on a pure path doesn't work.
    builtins.appendContext path' { ${path'} = { path = true; }; };
```

works in pure contexts.

Because of this, we deem that storePath should be allowed in pure
contexts and users do not have to come up with a `storePath` polyfill.

Fixes #402.

Change-Id: I5fff750a4feed082745431835db451f945249cfb
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-03-04 11:33:30 +00:00
Raito Bezarius e8015836e3 libcmd/profiles: keep derivations if keep-env-derivations = true
nix3 CLI never honored that setting.

When we update a nix3 profile element with new built store paths for
which we know the deriver (the derivation path which built it), we add
the derivation paths to the profile element to prevent garbage
collection the same way the nix2 CLI logic does.

Fixes #1095.

Change-Id: Icc236d174c5ce5ffe042d1c8e1968f6cb5b50359
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-03-03 22:13:02 +00:00
isabelandRaito Bezarius fc649250ec libexpr/flake-config: collect untrusted settings into one prompt
Instead of showing untrusted configuration items one by one, collect all
of them into one batched ask with 4 options:

- apply the configuration wholesale **for now** (yes)
- apply the configuration wholesale and trust it permanently (allow
  permanently)
- selectively choose subset (no)
- rejecting the configuration wholesale (no to all)

Note that we do not offer options to reject permanently a configuration,
that's what `--no-accept-flake-config` is for.

Individual prompts gain a new option to distinguish "yes for now" and
"yes forever".

Fixes #682.

Change-Id: I2492717ac277af33ea4ac9b1a11bd7d6d1bfe0db
2026-03-03 21:57:03 +00:00
Raito Bezarius 74300fd0a7 libexpr/primops: reject __json in structured attrs derivations
In structured attrs derivations, __json is used to serialize the `env`
attribute into a JSON object.

If the derivation enables structured attributes AND specify its own
`__json`, one of the field will take precedence (the reader can have fun
by guessing which one).

To reduce underspecification, we disallow `__json` in structured
attributes derivations.

Fixes #380.

Change-Id: I51c3b2af1ff9449471ba81d4c72df6a7a263eef7
Signed-off-by: Raito Bezarius <raito@lix.systems>
2026-03-01 19:05:54 +00:00
Tom Hubrecht d52033fc77 nix/develop: Don't ignore SSL_CERT_FILE when its value is meaningful
Change-Id: I31e85a5995edc40ed2e687077ffdf563e717abb4
2026-02-28 12:32:45 +00:00
Jade Lovelace 01ff67595b nix3-add-path: add references-list argument for ca with references
This is not ca-derivations. We don't care about self-references or any of the
rewriting or stuff like that; if you want something like that, write
your user code so it figures out where it is.

The reason I want to do this is for integrating other build systems with
Lix: if you're importing something built *outside the store* with a
non-Nix build system, it makes no sense to put it in an input-addressed
path since it's not possible to come up with a derivation for it.
But you need *some* hash, so the output hashing is the most sensible option.
It is also nice because of not needing trusted user privileges to import
it, since the hash describes the exact contents of the output path.

We use this feature (implemented externally to Lix; this CL eliminates
that step) at Mercury to integrate buck2 with Nix on the output side: we
import things to the Nix store as ca paths with references.

These can then be consumed by Nix language with:

```
# Hack from https://git.lix.systems/lix-project/lix/issues/402#issuecomment-5889
path:
builtins.appendContext path {
  ${path} = {
    path = true;
  };
}
```

Test plan:
```
$ nix store add-path --references-list xx-refs-list ./README.md
/nix/store/szcwnm13d9gmxx8fly0bz82l42jgysw6-README.md

$ cat xx-refs-list
/nix/store/g9hhwjbkdrw0wnbd3axfs4icyb37nr6b-bash-interactive-5.3p3

$ nix path-info --json /nix/store/szcwnm13d9gmxx8fly0bz82l42jgysw6-README.md | jq .
[
  {
    "ca": "fixed:r:sha256:1pj59fy7zcrn949ry9kgv4ba17h2sy3z2is469abj912cvbl14n3",
    "narHash": "sha256-w5JA12YiJLlUMkRH8YfXAp6gFtlvJp8TSTazf7xLRd4=",
    "narSize": 1384,
    "path": "/nix/store/szcwnm13d9gmxx8fly0bz82l42jgysw6-README.md",
    "references": [
      "/nix/store/g9hhwjbkdrw0wnbd3axfs4icyb37nr6b-bash-interactive-5.3p3"
    ],
    "registrationTime": 1771266146,
    "valid": true
  }
]
```

Change-Id: I005a03003dfc24108e018e599dbe0b5d6a6a6964
2026-02-21 22:50:13 +00:00
vczf 86268bd618 meson: fix broken build when using custom build directory
Fixes path resolution issue with meson-embedded bash script when
`build` is a symlink, or a custom build directory is passed as a
argument to `just` or `meson`.

Change-Id: I67b13c524d196241bb9a8a3b8ad2c17c2c094ed8
2026-02-20 23:32:33 +00:00
eldritch horrors aa896041e0 libstore: asyncify build child setup completion wait
Change-Id: Ica70af2a1205830f1ca4bb48f42d09923cff2e58
2026-02-03 14:11:59 +00:00
eldritch horrors ac64c727b5 libstore: move build child launching to libexec
this allows us great flexibility in how children are launched (since the
actual launching is done by a separate executable), makes fork no longer
needed in the core codebase (outside of runProgram, anyway), and we even
get to use linux vfork to its full potential to decrease the launch cost
of sandboxes to a constant factor (previously it was O(#drvs + #deps) of
the build graph, which obviously goes to n² quickly if you are unlucky.)

Change-Id: I66e2d1b20242dc24d708666ef325fb8725bd9296
2026-02-03 14:11:33 +00:00
eldritch horrors 576ff2f598 update nixpkgs, pre-commit-hooks
the devshell no longer worked for us due to the recent deprecations :D
let's update pre-commit too because while it doesn't fail it does warn

Change-Id: Ic2060c82e4e97bb7a96cebd29097abefabdfe733
2026-02-02 15:08:49 +01:00
rootile 64d610fddc chore: reflect account migration
Change-Id: Iee327470932e58707473e876982cf22b392c2efa
2026-01-31 20:59:02 +00:00
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
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
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