1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-09 18:41:03 +01:00
Commit graph

12686 commits

Author SHA1 Message Date
Cole Helbling
d3dc64b811 external-derivation-builder: chdir into tmpdir 2025-07-17 07:54:07 -07:00
Cole Helbling
51449d7a51 external-derivation-builder: run under build user, chown topTmpDir to builder
The chown to builder is necessary for granting the builder the ability to
access its entire ancestry (which is required on macOS for things like
mounting the build directory into a VM to work) while running under a
build user.

Eelco mentioned that the reason topTmpDir is generally 700 is because of
how the Linux chroot is setup, but since we do not use a chroot on macOS,
it's fine to make the build dir readable to the build user.
2025-07-17 07:53:47 -07:00
Eelco Dolstra
c1b0b15708 Merge remote-tracking branch 'detsys/detsys-main' into refactor-derivation-builder 2025-07-15 18:52:12 +02:00
Cole Helbling
de158c335c fixup: document why we're not writing through stdin right now 2025-07-14 11:13:04 -07:00
Cole Helbling
5b27325bc2 Revert "external-derivation-builder: write the json doc into builder's stdin"
This reverts commit d1f57c5dae.
2025-07-14 11:00:13 -07:00
Cole Helbling
efa239875b Add an external-builders experimental feature 2025-07-14 09:07:32 -07:00
Eelco Dolstra
dea86cd473 Tagging release 2.30.1
-----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEtUHVUwEnDgvPFcpdgXC0cm1xmN4FAmhyEcITHGVkb2xzdHJh
 QGdtYWlsLmNvbQAKCRCBcLRybXGY3lZeB/9D/FGpanG1tE/RgqJjJSrw0YKRPhFu
 +Qo+vCbW+ZjFdbXTHnWynpCO3/HJDf4AsXiSgUnhckS54hUZ2p10JIjOdCCWA8yh
 aZfBEfX8xWmgUU8tEbRVluUjwfTRVmuf+Y2znvoS++Ej2sNxip8I/gcd5nPb1G5M
 EEFB+/JKNVnFGdGwLdn5q6Ih5Z3XbnLHiSKMKCLhZTCBU6PWwpHbFgDgqreGNHyr
 jMkl2RFLzLvZhzIF7EYtO0PPDXWeDceQDrYzJKXYcWKHlrywAV6lGvKKhKW8l6OU
 a06c+I99M4LNIFK7ENraI2V408miRTvXmLPSQjCtkM1NM9+/cNZRtRlW
 =aYgN
 -----END PGP SIGNATURE-----

Merge tag '2.30.1' into sync-2.30.1

Tagging release 2.30.1
2025-07-12 12:53:18 +02:00
gustavderdrache
1cf202650a Address ifdef problem with macOS/BSD sandboxing
(cherry picked from commit e2ef2cfcbc)
2025-07-11 23:09:58 +00:00
gustavderdrache
8e21e61a51 Address ifdef problem with macOS/BSD sandboxing 2025-07-11 18:01:51 -04:00
Sergei Zimmerman
382e25405a libexpr: Fix invalid handling of errors for imported functions
c39cc00404 has added assertions for
all Value accesses and the following case has started failing with
an `unreachable`:

(/tmp/fun.nix):

```nix
{a}: a
```

```
$ nix eval --impure --expr 'import /tmp/fun.nix {a="a";b="b";}'
```

This would crash:

```
terminating due to unexpected unrecoverable internal error: Unexpected condition in getStorage at ../include/nix/expr/value.hh:844
```

This is not a regression, but rather surfaces an existing problem, which previously
was left undiagnosed. In the case of an import `fun` is the `import` primOp, so that read is invalid
and previously this resulted in an access into an inactive union member, which is UB.
The correct thing to use is `vCur`. Identical problem also affected the case of a missing argument.

Add previously failing test cases to the functional/lang test suite.

Fixes #13448.

(cherry picked from commit 6e78cc90d3)
2025-07-11 18:26:57 +00:00
Cole Helbling
d1f57c5dae external-derivation-builder: write the json doc into builder's stdin 2025-07-11 10:37:58 -07:00
Eelco Dolstra
7119d594fc fetchClosure: Fix gcc warning
Fixes:

[261/394] Linking target src/libexpr/libnixexpr.so
In function ‘copy’,
    inlined from ‘__ct ’ at /nix/store/24sdvjs6rfqs69d21gdn437mb3vc0svh-gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/basic_string.h:688:23,
    inlined from ‘operator+’ at /nix/store/24sdvjs6rfqs69d21gdn437mb3vc0svh-gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/basic_string.h:3735:43,
    inlined from ‘operator()’ at ../src/libexpr/primops/fetchClosure.cc:127:58,
    inlined from ‘prim_fetchClosure’ at ../src/libexpr/primops/fetchClosure.cc:132:88:
/nix/store/24sdvjs6rfqs69d21gdn437mb3vc0svh-gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/char_traits.h:427:56: warning: ‘__builtin_memcpy’ writing 74 bytes into a region of size 16 overflows the destination [-Wstringop-overflow=]
  427 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                                        ^
../src/libexpr/primops/fetchClosure.cc: In function ‘prim_fetchClosure’:
../src/libexpr/primops/fetchClosure.cc:132:88: note: at offset 16 into destination object ‘<anonymous>’ of size 32
  132 |             fromPath = state.coerceToStorePath(attr.pos, *attr.value, context, attrHint());
      |                                                                                        ^

(cherry picked from commit aa18dc54dc)
2025-07-10 18:33:39 +00:00
Eelco Dolstra
804729b4ec Merge remote-tracking branch 'detsys/detsys-main' into refactor-derivation-builder 2025-07-10 17:31:01 +02:00
Eelco Dolstra
37487eec8e lockFlake(): When updating a lock, respect the input's lock file
(cherry picked from commit 95437b90fc)
2025-07-10 04:29:39 +00:00
Eelco Dolstra
930aabb7f3
Merge pull request #139 from DeterminateSystems/remove-dead
Remove some dead code to minimize the upstream diff
2025-07-09 20:25:49 +00:00
Eelco Dolstra
47081aa94c Remove some dead code to minimize the upstream diff 2025-07-09 22:12:05 +02:00
Cole Helbling
e1d45bb040
Merge pull request #138 from DeterminateSystems/hide-double-copy-warning
Hide double copy warning
2025-07-09 20:06:56 +00:00
Cole Helbling
facfff45d3
Merge pull request #137 from DeterminateSystems/eelcodolstra/cf-65-determinate-nix-implicit-flake-lock-update-dont-update
lockFlake(): When updating a lock, respect the input's lock file
2025-07-09 20:00:02 +00:00
Eelco Dolstra
700ceb2ce1 Hide double copy warning 2025-07-09 21:52:47 +02:00
Eelco Dolstra
668088b876
Merge pull request #134 from DeterminateSystems/nix-flake-check-dont-build
nix flake check: Skip substitutable derivations
2025-07-09 19:07:52 +00:00
Eelco Dolstra
2ecc5156f4 lockFlake(): When updating a lock, respect the input's lock file 2025-07-09 19:04:29 +02:00
Eelco Dolstra
175406c313 Merge remote-tracking branch 'origin/2.30-maintenance' into sync-2.30.0 2025-07-07 19:23:15 +02:00
Robert Hensing
9f8df6878f doc: Add more links
Mostly in the 2.30 release notes
2025-07-07 16:47:02 +02:00
Eelco Dolstra
864ccb6e63
Merge pull request #13356 from SimSaladin/sim/fix-erase-output-paths
fix throwing output paths out of sandbox paths
2025-07-07 12:15:23 +02:00
Robert Hensing
c512fd1a4b
Merge pull request #13420 from NixOS/query-missing
Introduce MissingPaths struct for queryMissing() / printMissing()
2025-07-07 11:48:06 +02:00
Eelco Dolstra
5c9592194c nix flake check: Skip substitutable derivations
Since `nix flake check` doesn't produce a `result` symlink, it doesn't
actually need to build/substitute derivations that are already known
to have succeeded, i.e. that are substitutable.

This can speed up CI jobs in cases where the derivations have already
been built by other jobs. For instance, a command like

  nix flake check github:NixOS/hydra/aa62c7f7db31753f0cde690f8654dd1907fc0ce2

should no longer build anything because the outputs are already in
cache.nixos.org.
2025-07-04 17:07:18 +02:00
Eelco Dolstra
f039f6886a nix-build: Drop unnecessary call to queryMissing()
This is already done by Worker::run().
2025-07-04 16:34:34 +02:00
Eelco Dolstra
5d308ccca5 printMissing(): Take a MissingPaths argument 2025-07-04 16:34:30 +02:00
Eelco Dolstra
af05ce0f6d queryMissing(): Return a struct
...instead of having a bunch of pass-by-reference arguments.
2025-07-04 16:34:24 +02:00
Eelco Dolstra
1df17735f5 nix-build: Drop unnecessary call to queryMissing()
This is already done by Worker::run().
2025-07-04 16:32:37 +02:00
Eelco Dolstra
3a636205c5 printMissing(): Take a MissingPaths argument 2025-07-04 16:27:08 +02:00
Eelco Dolstra
53a743b8c5 queryMissing(): Return a struct
...instead of having a bunch of pass-by-reference arguments.
2025-07-04 16:21:38 +02:00
Eelco Dolstra
eb97d8c170 Fix indentation of "Unable to start any build" error message
The use of R"(...)" added a bunch of unnecessary whitespace, e.g.

  error:
                             Unable to start any build;
                             either increase '--max-jobs' or enable remote builds.

                             For more information run 'man nix.conf' and search for '/machines'.

Now we get

  error: Unable to start any build; either increase '--max-jobs' or enable remote builds.

         For more information run 'man nix.conf' and search for '/machines'.
2025-07-04 15:21:31 +02:00
Eelco Dolstra
d4f67fd46d
Merge pull request #13369 from NixOS/null-revision-not-locked
Git fetcher: Do not consider a null revision (i.e. workdir) to be locked
2025-07-03 19:56:21 +02:00
Sergei Zimmerman
5a20a48f13
libexpr: Reduce the size of Value down to 16 bytes
This shaves off a very significand amount of memory used
for evaluation as well as reduces the GC-managed heap.

Previously the union discriminator (InternalType) was
stored as a separate field in the Value, which takes up
whole 8 bytes due to padding needed for member alignment.
This effectively wasted 7 whole bytes of memory. Instead
of doing that InternalType is instead packed into pointer
alignment niches. As it turns out, there's more than enough
unused bits there for the bit packing to be effective.

See the doxygen comment in the ValueStorage specialization
for more details.

This does not add any performance overhead, even though
we now consistently assert the InternalType in all getters.

This can also be made atomic with a double width compare-and-swap
instruction on x86_64 (CMPXCHG16B instruction) for parallel evaluation.
2025-07-02 22:27:37 +03:00
Sergei Zimmerman
e73fcf7b53
libexpr: Use proxy ListView for all Value list accesses
This also makes it possible to make `payload` field private
in the `ValueStorage` class template.
2025-07-02 21:57:02 +03:00
Sergei Zimmerman
c39cc00404
libexpr: Factor out Payload union to a default implementation of ValueStorage
This factors out most of the value representation into a mixin class.
`finishValue` is now gone for good and replaced with a simple template
function `setStorage` which derives the type information/disriminator from
the type of the argument. Likewise, reading of the value goes through function
template `getStorage`.

An empty type `Null` is introduced to make the bijection InternalType <-> C++ type
complete.
2025-07-02 21:51:15 +03:00
Sergei Zimmerman
810455f1b8
libexpr: Simplify Value::is* methods by introducing isa function template 2025-07-02 21:51:12 +03:00
Sergei Zimmerman
1a033ee4ee
libexpr: Use single tSmallList Value discriminator for small lists 2025-07-02 21:51:09 +03:00
Sergei Zimmerman
ea32580c9b
libexpr: Format value.hh
The following commits will touch this file significantly, so
it's better to get the formatting out of the way first.
2025-07-02 21:51:07 +03:00
Robert Hensing
04a731b4b9
Merge pull request #13387 from NaN-git/opt-listToAttrs
libexpr: don't allocate additional set in `builtins.listToAttrs`
2025-07-02 11:55:39 +02:00
Sergei Zimmerman
d16af1d099
libfetchers: Add missing include guard to git-lfs-fetch.hh
This is a publicly installed header without a header guard.
Doesn't seem right.
2025-07-02 00:57:35 +03:00
Eelco Dolstra
5879ab1577
Merge pull request #13400 from NixOS/fix-deep-overrides
Fix deep flake input overrides
2025-07-01 19:34:55 +02:00
Eelco Dolstra
4458a9061b
Merge pull request #13406 from xokdvium/libflake-dead-code
libflake: Remove unused maybeParseFlakeRef and maybeParseFlakeRefWith…
2025-07-01 17:03:00 +02:00
Sergei Zimmerman
8708e9a526
libutil: Use caching directory_entry API in PosixSourceAccessor::readDirectory
Previous use of symlink_status() always translated into a stat call, leading
to huge performance penalties for by-name-overlay in nixpkgs. The comment
below references the possible caching, but that seemed to be erroneous, since
the correct way to make use of the caching API is by calling a bunch of `is_*`
functions [1]. For example, here's how libstdc++ does that [2], [3].

This translates to great nixpkgs eval performance improvements:

```
Benchmark 1: GC_INITIAL_HEAP_SIZE=4G result/bin/nix-instantiate ../nixpkgs -A hello --readonly-mode
  Time (mean ± σ):     186.7 ms ±   6.7 ms    [User: 121.3 ms, System: 64.9 ms]
  Range (min … max):   179.4 ms … 201.6 ms    16 runs

Benchmark 2: GC_INITIAL_HEAP_SIZE=4G nix-instantiate ../nixpkgs -A hello --readonly-mode
  Time (mean ± σ):     230.6 ms ±   5.0 ms    [User: 126.9 ms, System: 103.1 ms]
  Range (min … max):   225.1 ms … 241.4 ms    13 runs
```

[1]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0317r1.html
[2]: 8ea555b7b4/libstdc%2B%2B-v3/include/bits/fs_dir.h (L341-L348)
[3]: 8ea555b7b4/libstdc%2B%2B-v3/include/bits/fs_dir.h (L161-L163)
2025-06-30 23:29:07 +03:00
Cole Helbling
1521a819b7
external-derivation-builder: args must always be specified
I don't want to figure out how to make nlohmann treat std::optional<>
the same way Rust's serde_json treats Option<> (i.e. skip it if it's
not there).
2025-06-30 11:44:02 -07:00
John Ericson
b64a310eb2 Fix warning when HAVE_EMBEDDED_SANDBOX_SHELL is not set
Clang doesn't like the double indent that is needed for the `if...else`
that is CPP'd away. Adding braces is fine in the `if...else...` case,
and fine as a naked block in the CPP'd away case, and properly-indented
both ways.
2025-06-30 11:40:10 -07:00
Cole Helbling
ef4e7df6a5
Merge detsys-main 2025-06-30 11:31:06 -07:00
Eelco Dolstra
42351656c3
Merge pull request #127 from DeterminateSystems/eelcodolstra/fh-865-add-nix-flake-prefetch-inputs-command-to-fetch-inputs-in
nix flake prefetch-inputs: Add
2025-06-30 18:01:47 +00:00
Eelco Dolstra
e809a5626e
Merge pull request #130 from DeterminateSystems/improve-nix-store-delete-errors
nix store delete: Show why deletion fails
2025-06-30 15:04:19 +00:00