Commit Graph
17552 Commits
Author SHA1 Message Date
eldritch horrors 3bf0dcaef3 libstore: split fetchToStore
only a single caller uses flat fetching at all. it still makes sense to
not inline that single caller for now, mostly due to activity reporting

Change-Id: I1a6420868443c3a684deafc7a4f567d4d4b1bd53
2025-03-03 02:02:49 +00:00
eldritch horrors f12cb77442 libstore: split Store::addToStore
same as before, only for a different method.

Change-Id: Id7238b26a25c21fe09df7147b16a39cc5371d8c0
2025-03-03 02:02:49 +00:00
Raito BezariusandGerrit Code Review 271f0e2507 Merge "libexpr: fix checkSourcePath purity regression" into main 2025-03-03 02:00:35 +00:00
Maximilian BoschandGerrit Code Review c0668db12c Merge "subprojects/nix-eval-jobs: bring back constituents" into main 2025-03-02 22:02:22 +00:00
eldritch horrors f1ecfbdd48 libstore: split Store::computeStorePathForPath
the two variants compute their store path hashes very differently, and
the flat version ignores the filter passed in by the user entirely. in
a future change we want to move filters out of store methods entirely,
splitting them now will make that task a lot easier when we are ready.

Change-Id: I5f23a26ca08e81923f33adf687056d0d464c2cb8
2025-03-02 17:37:12 +00:00
eldritch horrors 349516d6c7 libstore: remove unused parameter of Store::addToStore
Change-Id: I2816ed2689da8adb5634da180389e049e6ace6bc
2025-03-02 17:37:12 +00:00
eldritch horrors 8ce7d59c45 libstore: specialize Store::computeStorePathForPath
it's only used once at all, only with SHA256, and the hash it returned
was always ignored. probably a relic of a bygone age, but today is not
the time to clean this up. not before addToStore is rewritten, anyway.

Change-Id: I20e0b5a9bc85ccd05db79bf44f3e972fbd174902
2025-03-02 17:37:12 +00:00
eldritch horrors b5aa3a4197 libutil: inline ChainSource into sole remaining user
Change-Id: If0c81472a2e9b70e695631c147ce7eaae28d69d6
2025-03-02 17:37:12 +00:00
eldritch horrors 820c9bdaf5 libstore: don't abort when flat-importing non-files
fixes #705

Change-Id: I3be20235006425dd3bb6156510d021699f05b9ba
2025-03-02 17:37:12 +00:00
Alois Wohlschlager 9d99a7c2cf libexpr: fix checkSourcePath purity regression
Starting with commit 0dbfa7b26e access would also
be allowed to ancestors of allowed paths. This is (ironically) a significant
purity regression, since several users of the purity checks will themselves
assume that arbitrary descent is allowed. For example, `builtins.readDir` and
`builtins.path` could now refer to the filesystem root, breaking purity
entirely in the latter case by allowing to read arbitrary files. Restore the
previous behaviour of only allowing access to explicitly allowed paths.

Change-Id: Ie64180733ab735da9873255e1ccbf95ba7c9161c
2025-03-02 18:30:30 +01:00
eldritch horrors 94f15cb5a4 libutil: also test nar copies
Change-Id: Ia57005c476f289c7fbcbf7b96d6aa8e9d403bb86
2025-03-02 16:56:06 +00:00
Rebecca TurnerandJade Lovelace 20fea96996 Fix piping nix store ls output on macOS
`writeLogsToStderr` uses a static mutex in order to prevent log output
from being interleaved. On macOS, it was possible for a logger in a
non-main thread to call this function after the static mutex was
destructed, leading to strange errors. Deliberately leaking the mutex
prevents the destructor from being called, fixing the issue.

Closes #702

Co-Authored-By: Jade Lovelace <jadel@mercury.com>
Co-Authored-By: eldritch horrors <pennae@lix.systems>

Change-Id: I14c80134cc493972752fad56b7f15fad8e4d5a5b
2025-02-28 18:17:47 -08:00
jadeandGerrit Code Review 99bc6867e8 Merge "daemon: test group membership better on macOS" into main 2025-02-28 22:20:29 +00:00
Maximilian Bosch 8cb2306138 subprojects/nix-eval-jobs: bring back constituents
Hydra used to support aggregate jobs that only succeeded when their
constituents succeed. This is still used by e.g. nixpkgs[1].

Prior art:
* https://git.lix.systems/lix-project/nix-eval-jobs/pulls/17: got ported
  into the CppNix implementation[2]
* https://github.com/nix-community/nix-eval-jobs/pull/349: implements
  glob expressions for constituents - something we needed at work. This
  also restructures the code a bit which is what I re-used here. The
  globbing is not part of this patch.

Essentially, the following things happen here (assuming `--constituents`
is set):

* Derivations with `_hydraAggregate = true;` are considered aggregates.
  These are not written to stdout when received by a worker, but stored
  until the end.

* Constituents can be drv paths or strings (that must be the `attr` of
  another job). In that case, the derivation of the aggregate job is
  rewritten so that it depends on the drv of the constituent job.

* At the very end the aggregate jobs are also written to stdout.

Additionally, this fixes one bug, the old `hydra-eval-jobs`
implementation had (and we actually hit at work):

Given the leaf jobs `packages.foo` & `packages.bar`, an aggregate job
`aggregate0` with

    _hydraAggregate = true;
    constituents = [ "packages.bar" "packages.foo" ];

and an aggregate job `aggregate1` with

    constituents = [ "aggregate0" ];

then it may happen depending on the order of evaluation that `aggregate1`
depends on the old derivation of `aggregate0` (i.e. the one without
rewritten constituents) and doesn't depend on `packages.foo` and
`packages.bar` because it was rewritten before `aggregate0` was
rewritten.

This is done in here correctly, but topologically sorting the aggregate
jobs before rewriting those.

[1] https://github.com/NixOS/nixpkgs/blob/bba6b37c9d0898867a7d9c38a1b5b77efcfb07b9/nixos/release-combined.nix#L69
[2] https://github.com/nix-community/nix-eval-jobs/pull/340

Change-Id: I5baad5e57336b4985ef8595e903814de83eb01c1
2025-02-28 20:20:42 +01:00
piegames 336f467b3f repl: Print message when adding variable
I've always been annoyed that it just silently succeeded without any
feedback, but now with the upcoming improvements on defining variables
this is more necessary than ever.

Change-Id: I565897fa2f97cf6f567d4449dcc8d4ad4eb73fce
2025-02-28 17:13:53 +01:00
piegames 708f1ea342 repl: Add changelog entry for recent improvements
I forgot to add a change log earlier, sorry

Change-Id: Idde2f26b8f0b9aa0bdbfcdb10a070ef1dd663d58
2025-02-28 17:13:53 +01:00
piegames 233be9be14 libexpr: Clean up BindingsState
- `pos` is not used anymore and can be removed
- `path` and `value` are more correctly placed in their own sub state,
to mirror `InheritState`

Change-Id: Ie7c8a3aea3fe4af0f9c5c15ab5897a59d1b3f7b0
2025-02-28 17:13:53 +01:00
piegames 65ce95d381 libexpr: Deprecate NUL bytes in strings
I absolutely want to go back to allowing them, I am strongly of the
opinion that nothing should be special about NUL in a string, but this
will have to wait until at least the GC rewrite, so for now the least I
can do is to disarm this gun.

Change-Id: Id14b6037bc8b274c6c60ad970b1c74d436fb62a7
2025-02-28 16:17:17 +01:00
piegames e38ad66ef7 libexpr: Deprecate CR and CRLF line endings
They are broken beyond repair, and barring a language version revision
this is our only option besides doing nothing about it.

Change-Id: I25fa4f032ca9b5ca67356946bcd889289583592e
2025-02-28 16:17:17 +01:00
Lily Ballardandjade 7f98021c93 daemon: test group membership better on macOS
macOS uses opendirectory for users and groups, which supports nested
groups and groups with synthesized membership. This means that asking
for a group's users isn't sufficient to test for group membership.

With this change, groups like `@localaccounts` or `@_developer` will
work in `trusted-users` and `allowed-users`.

Fixes https://github.com/NixOS/nix/issues/5885

Change-Id: I3b0783ce7cec303de5aba32c8e5ac0f976112c72
2025-02-28 04:45:02 +00:00
eldritch horrors 5778998cfa libutil: abstract nar parser for other kinds of sources
now we can feed the nar parser from something that isn't a Source, such
as a kj async stream. we will not be able to wrap the nar members quite
as nicely in that case since async generators are not a thing yet. once
we need that we can come up with some async generator mechanism though.

Change-Id: If9f5d7865c18e4293aa037b9acd29718e080b3e4
2025-02-27 23:51:06 +00:00
eldritch horrors 09ada20485 libutil: drop nar metadata variants
like parseAndCopyDump they're no longer needed for anything.

Change-Id: I7e40b9d398a88d4e98cd3e2263315afae057dcbd
2025-02-27 23:51:06 +00:00
eldritch horrors 6444e3894d libutil: drop parseAndCopyDump
with copyNAR no longer using it it doesn't have to be public any more,
and since parseDump does not need to pass through its input data we'll
also turn restore() into a plain function instead of a wire generator.

Change-Id: Idd3a0270089ff47a7dc8ca96eb03b002fa5ea37e
2025-02-27 23:51:06 +00:00
eldritch horrors 45be1e8d66 libutil: implement copyNAR with parse + dump
Change-Id: I2bf6a0dc052d2f4012cc8fe3ced4c8cefd6572e5
2025-02-27 23:51:06 +00:00
eldritch horrors e72f40aa5f libutil: split nar creation into listing and dumping
this will let us reuse the dumping code to implement copyNAR using parse
and dump, making both parseAndCopyDump and the DiscardVisitor redundant.

Change-Id: I21e86d1c0c016a6e005f718cd695eee7ea885273
2025-02-27 23:51:06 +00:00
eldritch horrors 833181d329 libutil: pass entry names to nar visitors, not full path
we now fully mirror the structure of the nar in the structure and
function arguments of nar parse visitors. this avoids allocations
and baseNameOf calls, and it's altogether cleaner than previously

Change-Id: I86ca14be0382c83206d45dbba0f043dade1c338c
2025-02-27 23:51:06 +00:00
eldritch horrors 17e6497ca4 libutil: attach nar member names to dentries, not inodes
this is where they should've been from the start, but during the first
rewrite it made little sense to move them. we have bigger plans today,
so we'll finally clean that up too. note the `Map` transform type that
is needed to make the current macros work. it shall be only temporary.

Change-Id: I928d197dbfe27b68cf8634d149c3259e86fbf123
2025-02-27 23:51:06 +00:00
eldritch horrors 52db1ecb3a libutil: mirror nar structure in nar visitor structure
this is an unfortunate but necessary intermediate state in which we can
mirror nar structure from the visitor side, but not yet from the parser
side. to move from paths to entry names we must first relocate names of
entries out of the entries themselves, and into their parent directory.

Change-Id: I2ea898230952a4f631eea67c66ac8dcbdfb19636
2025-02-27 23:51:06 +00:00
eldritch horrors ab9f6e311d libstore: don't rethrow Interrupted twice
Interrupted is thrown once *per thread* (or more!). don't rethrow a copy
from another thread while we are already handling FramedSink exceptions.

fixes #706

Change-Id: I21b2c9afd10f09919f4dbaf3c6cfbf7fa0156fa1
2025-02-28 00:17:26 +01:00
eldritch horrorsandGerrit Code Review 0195bca557 Merge changes If249f13c,I3466d2a7,I9f1d8412 into main
* changes:
  libstore: extract source implementation from NarIndexer
  libstore: don't use parseDump to discard nars
  libutil: add some c++ nar parser tests
2025-02-27 20:22:25 +00:00
jadeandGerrit Code Review c75616d185 Merge "build-release-notes: ban unprefixed issue numbers" into main 2025-02-27 20:01:37 +00:00
eldritch horrors e1caeb9680 libstore: extract source implementation from NarIndexer
this is conflating concerns (position tracking in the input stream and
actually unpacking its contents) in an unhelpful way and is preventing
us removing full-path access requirements from the visitor concept. we
want to move from reconstructing and then deconstructing paths to only
passing individual entry names to nar parsers, who can then build full
paths from the nar root only if the need those to function. not all of
our implementations need this; only one of the three does, one ignores
the paths entirely, and the third even takes the reconstruction apart.

Change-Id: If249f13c5b9ae5b9e4e4a3777875ef8364ee6229
2025-02-27 19:52:44 +00:00
eldritch horrors c6a4cd6e3a libstore: don't use parseDump to discard nars
this is a step towards using nar parser visitors only where we need nar
parser visitors. the performance impact of this should be insignificant
and perhaps slightly positive since we no longer allocate anything when
discarding a file member. mostly it is a step towards a NARParseVisitor
that has no default behavior; we have only three implementations total,
and most of them don ot even *use* most of the default implementations.

Change-Id: I3466d2a77500778eb152f56ebd441cf1be223dc6
2025-02-27 19:52:44 +00:00
eldritch horrors 0b4912a0fb libutil: add some c++ nar parser tests
functional2 can't test the actual nar parser library :(

Change-Id: I9f1d8412ba6ed912f74c9edcc2d54216fbda793e
2025-02-27 19:52:44 +00:00
Andy HamonandGerrit Code Review 39fc2de7ef Merge "feat: add a --priority flag to nix-env --install" into main 2025-02-27 19:39:02 +00:00
Jade Lovelace 6bc008900a build-release-notes: ban unprefixed issue numbers
This is necessary to cleanly and unambiguously transition to using
forgejo issues, since we now control our own destiny.

If we ban unprefixed numbers for a couple of releases, we ensure there
are no releases in active support with the wrong unprefixed number
semantics that could receive backports.

Change-Id: I1c94541dcb3f071399f439870b48cd76557b70d2
2025-02-27 10:49:16 -08:00
Maximilian BoschandGerrit Code Review 03ade5e6d7 Merge "subprojects/nix-eval-jobs: clean up package metadata" into main 2025-02-27 09:14:53 +00:00
Maximilian Bosch 110b5ebd04 subprojects/nix-eval-jobs: clean up package metadata
* Point `meta.homepage` to the correct location
* Remove `meta.maintainers` field: the folks listed in there maintain
  the upstream package. I decided to remove it since we don't use
  `meta.maintainers` in this repository to indicate maintainership of a
  component.

Change-Id: Iec7b0eb463bc8f41907909e87ec9280c19dc86f5
2025-02-27 09:57:48 +01:00
Seth Flynn 8082f0b843 build: strip compiler references from runtime closure
Sourced from https://github.com/NixOS/nixpkgs/pull/375030

Fixes: https://git.lix.systems/lix-project/lix/issues/699
Change-Id: Id215437a6519a140dd91127cbd6c2b518f34a397
2025-02-26 23:06:56 -05:00
Andrew Hamon 2bdac6b7ec feat: add a --priority flag to nix-env --install
Backport of https://github.com/NixOS/nix/pull/12275

nix-env can read priorities from a derivations meta attributes, but this
only works when installing a nix expression.

nix-env can also install bare store paths, however meta attributes are
not readable in that case. This means that a store path can not be
installed with a specific priority.

Some cases where it is advantageous to install a store path: a remote
host following a `nix copy`, or any time you want to save some
evaluation time and happen to already know the store path.

This PR addresses this shortcoming by adding a --priority flag to
nix-env --install.

Change-Id: Ibd9365d0058820a9c2aeecc909b81a0410d5764b
2025-02-26 19:11:39 -08:00
Raito BezariusandGerrit Code Review d037b9e102 Merge "libexpr: rectify filtering logic for filter builtins under chroot stores" into main 2025-02-27 01:37:13 +00:00
62ee2aea29 libexpr: rectify filtering logic for filter builtins under chroot stores
Under chroot or diverted store setups, the filtering logic of
`builtins.filterSource` and `builtins.path` (which shares the same filtering
logic as `filterSource`) would incorrectly pass physical paths to the
filter function instead of logical store paths.

This caused actual breakage in nixpkgs when the `lib.fileset` library was
introduced. Due to this unresolved bug in Nix, the library was forbidden
from use: <https://github.com/NixOS/nixpkgs/pull/369694>.

To the best of our knowledge, this bug has existed since CppNix 2.3.

The existing tests were strengthened to cover these cases, but
additional testing may be required, particularly regarding symlink
handling.

References: https://github.com/NixOS/nix/pull/12512 (CppNix fix to the
problem using "union" abstractions).

Co-authored-by: Raito Bezarius <raito@lix.systems>
Co-authored-by: Alois Wohlschlager <alois1@gmx-topmail.de>
Co-authored-by: eldritch horrors <pennae@lix.systems>
Signed-off-by: Raito Bezarius <raito@lix.systems>
Change-Id: Iaf6ca8c506eeca145393ce100c64db12178daa62
2025-02-27 00:26:48 +01:00
jadeandGerrit Code Review 6588f8796b Merge "fix: flakes now obey --eval-system" into main 2025-02-26 22:23:56 +00:00
Charles HallandGerrit Code Review 5d055896bc Merge "change Nix to Lix in an error message" into main 2025-02-26 20:20:49 +00:00
Jade Lovelace 29f5ce07db fix: flakes now obey --eval-system
This required changing an excessive number of places since flakes code
is a delicious bowl of copy pasta.

I didn't change all of the usage sites since some of them run things on
the local machine and you actually want it to be the real system there.

Nevertheless, we probably should have the daemon do something much
different when it receives a `system` setting:
https://git.lix.systems/lix-project/lix/issues/694

Fixes: https://git.lix.systems/lix-project/lix/issues/692
Fixes: https://git.lix.systems/lix-project/lix/issues/673
Fixes: https://github.com/NixOS/nix/issues/11359
Change-Id: I55e696c09794d2520b60238a84829c98fcad7ccc
2025-02-26 12:05:07 -08:00
Maximilian BoschandGerrit Code Review 596ffc290e Merge changes I88816cc1,Ib4ff5f03 into main
* changes:
  subprojects/nix-eval-jobs: fix gcroots
  subprojects/nix-eval-jobs: build tests in Hydra jobs
2025-02-26 18:51:08 +00:00
eldritch horrors 78f8ffefbf libstore: *always* delete tmpdirs during derivation goal destruction
deletePath checks for interruption, and when interrupted simply exits
without doing anything of note. this may be useful in some instances,
but in the case of a user interrupting a build running on a daemon it
leaves temporary directories sitting around until they are deleted by
the user or by some automated mechanism. we simply shouldn't do this.

note the this means that large build directories now cause the daemon
(and single-user processes) to not be interruptible during cleanup of
cancelled builds. we plan to address this by getting rid of this very
haphazard mechanism once asyncification is completed (hopefully soon)

fixes #678 (again)

Change-Id: Ifff3769620bc9ef7684bc84354aed6c7f932bd87
2025-02-26 17:24:59 +00:00
eldritch horrorsandGerrit Code Review ee49ed56c3 Merge "crash handling: remove catch-alls in main, crash hard" into main 2025-02-26 14:54:34 +00:00
Charles Hall efa61369ff change Nix to Lix in an error message
Change-Id: I258d966c9a5a28dee80a330e9fa30590943ebaff
2025-02-25 20:19:17 -08:00
eldritch horrors 11cde67e21 libstore: asyncify Store::addMultipleToStore source set
this will let us asyncify narFromPath, in some distant future.

Change-Id: I722718e434ee105d74aa14688829cca6c29ac442
2025-02-26 00:15:05 +00:00