1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-10 12:36:01 +01:00
Commit graph

12519 commits

Author SHA1 Message Date
Jörg Thalheim
a4d03ba527
Merge pull request #13370 from NixOS/unit-tests-home
Give unit tests access to a $HOME directory
2025-07-17 15:56:26 +02:00
Jörg Thalheim
44963da787 Fix virtual method calls during construction in LocalBinaryCacheStore
Move init() call from constructor to openStore() method to avoid calling
virtual methods during object construction. This prevents undefined
behavior when virtual methods are called before the object is fully
constructed.
2025-07-17 15:45:32 +02:00
Jörg Thalheim
f12f96bcbb Fix virtual method calls during construction in S3BinaryCacheStoreImpl
Move init() call from constructor to openStore() method to avoid calling
virtual methods during object construction. This prevents undefined
behavior when virtual methods are called before the object is fully
constructed.
2025-07-17 15:45:32 +02:00
Jörg Thalheim
6681933643 Fix Windows header inclusions for clang-tidy
Move windows-error.hh includes inside _WIN32 guards to prevent
clang-tidy errors when analyzing these files on non-Windows platforms.
2025-07-17 15:40:46 +02:00
tomberek
de1d91f711
Merge pull request #13486 from fzakaria/issue-12935
Add helpful messages when file:// used as tarball
2025-07-17 02:51:31 -04:00
Farid Zakaria
196c21c5a0 Add helpful messages when file:// used as tarball
When `file://` is used accidentally in a flake as the source it is
expected to be a tarball by default.

Add some friendlier error messages to either inform the user this is not
in fact a tarball or if it's a git directory, let them know they can use
`git+file`.

fixes #12935
2025-07-16 21:17:07 -07:00
Farid Zakaria
a4f548fed1 Fix FetchGit test 2025-07-16 08:04:16 -07:00
Farid Zakaria
fb6f494d35 merge stderr to stdout so we can emit it 2025-07-16 08:04:16 -07:00
Farid Zakaria
8e8416387c Add error message when git returns non-0 for fetch
Users have complained that fetchGit is flaky however the culprit is
likely that `git fetch` was unable itself to download the repository for
whatever reason (i.e. poor network etc..)

Nothing was checking the status of `git fetch` and the error message
that would eventually surface to the users were that the commit was not
found.

Add explicit error checking for status code from `git fetch` and return
a message earlier on to indicate that the failure was from that point.

fixes #10431
2025-07-16 08:04:16 -07:00
Eelco Dolstra
1272c4957f
Merge pull request #13442 from NixOS/boost-minver
Require Boost 1.82.0 or higher
2025-07-16 14:54:14 +02:00
Eelco Dolstra
8e98f62a6e PosixSourceAccessor: Use concurrent_flat_map 2025-07-15 19:49:07 +02:00
Eelco Dolstra
7b2f24d688 Improve handleSQLiteBusy() message
Closes https://github.com/NixOS/nix/pull/10319.
2025-07-15 19:09:45 +02:00
Eelco Dolstra
fde6068874 Improve rendering of ignored exceptions
Instead of

  error (ignored): error: SQLite database '...' is busy

we now get

  error (ignored): SQLite database '...' is busy
2025-07-15 19:09:40 +02:00
Eelco Dolstra
6abc29bba5 Move boost version check to libutil 2025-07-15 15:17:33 +02:00
Eelco Dolstra
e8314e69ab
Merge pull request #13460 from m4dc4p/m4dc4p/handle-expired-tokens
Better Handling for Expired Credentials
2025-07-14 11:51:30 +02:00
Emily
5cd94436f5
libstore: fix Unix sockets in the build directory on sandboxed macOS
We’re already allowing `/tmp` anyway, so this should be harmless,
and it fixes a regression in the default configuration caused by
moving the build directories out of `temp-dir`. (For instance, that
broke the Lix `guessOrInventPath.sockets` test.)

Note that removing `/tmp` breaks quite a few builds, so although it may
be a good idea in general it would require work on the Nixpkgs side.

Fixes: 749afbbe99fd7b45f828b72628252feba9241362
Change-Id: I6a6a69645f429bc50d4cb24283feda3d3091f534

(This is a cherry-pick of commit d1db3e5fa3faa43b3d2f2e2e843e9cfc1e6e1b71)

Lix patch: https://gerrit.lix.systems/c/lix/+/3500
2025-07-13 19:19:38 +03:00
m4dc4p
f786c0b8d1
Update src/libstore/s3-binary-cache-store.cc
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2025-07-12 08:06:09 -07:00
m4dc4p
22d6969d66
Update src/libstore/s3-binary-cache-store.cc
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2025-07-12 08:05:52 -07:00
Justin Bailey
a48632f2e0 Better Handling for Expired Credentials
When AWS credentials expired, in some scenarios they led to the
nix process aborting with an error similar to ' Unable to parse ExceptionName: ExpiredToken'.

This change updates the S3 handling code such that those errors are treated like 403s or 404s.

Closes #13459
2025-07-11 17:30:47 -07:00
gustavderdrache
e2ef2cfcbc Address ifdef problem with macOS/BSD sandboxing 2025-07-11 18:09:07 -04:00
Sergei Zimmerman
6e78cc90d3
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.
2025-07-11 20:20:48 +03:00
Eelco Dolstra
a783468333
Merge pull request #13444 from roberth/fix-lessThan-doc
Fix `builtins.lessThan` doc
2025-07-10 20:32:47 +02:00
Robert Hensing
fc03b89ff4 Fix lessThan doc 2025-07-10 17:50:43 +02:00
Eelco Dolstra
ca9f2028b0 Simplify SymbolTable::create() 2025-07-10 12:28:34 +02:00
Eelco Dolstra
74a144ce98 Require Boost 1.81.0 or higher
Note: this version of Boost was released in December 2022.
2025-07-10 11:53:36 +02:00
Eelco Dolstra
aa18dc54dc 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());
      |                                                                                        ^
2025-07-10 11:41:32 +02:00
tomberek
485cbfc7f1
Merge pull request #13437 from NixOS/respect-transitive-locks
lockFlake(): When updating a lock, respect the input's lock file
2025-07-10 00:28:55 -04:00
Sergei Zimmerman
b19e9acc03
Merge pull request #13402 from DavHau/build-cores
build-cores: detect cores automatically if set to 0
2025-07-09 23:06:55 +03:00
Eelco Dolstra
95437b90fc lockFlake(): When updating a lock, respect the input's lock file 2025-07-09 19:19:15 +02:00
Connor Baker
a16491375a
globals.hh: fix broken link to nspawn example
The substitution included the `.` at the end of the URL, breaking it.
2025-07-08 12:59:16 -07:00
John Ericson
cf0df2607d
Merge pull request #13240 from obsidiansystems/dyn-drv-take-3
Get rid of `addWantedOutputs`
2025-07-07 11:39:45 -04: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
7781560724 libstore-tests: Fix impurity trying to access the Nix daemon
This failed on macOS:

  nix-store-tests-run> C++ exception with description "../nix_api_store.cc:33: nix_err_code(ctx) != NIX_OK, message: error: getting status of '/nix/var/nix/daemon-socket/socket': Operation not permitted" thrown in the test body.
2025-07-07 11:42:20 +02:00
Eelco Dolstra
f29acd5bbc Use writableTmpDirAsHomeHook 2025-07-07 11:12:55 +02:00
Eelco Dolstra
01388b3e78 Give unit tests access to a $HOME directory
Also, don't try to access cache.nixos.org in the libstore unit tests.
2025-07-07 11:02:51 +02:00
DavHau
fb5e22e318 build-cores: detect cores automatically if set to 0
This changes makes nix detect a machines available cores automatically whenever build-cores is set to 0.

So far, nix simply passed NIX_BUILD_CORES=0 whenever build-cores is set to 0. (only when build-cores is unset it was detecting cores automatically)

The behavior of passing NIX_BUILD_CORES=0 leads to a performance penalty when sourcing nixpkgs' generic builder's `setup.sh`, as setup.sh has to execute `nproc`. This significantly slows down sourcing of setup.sh
2025-07-07 10:33:42 +07: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
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