Commit Graph

23035 Commits

Author SHA1 Message Date
Amaan Qureshi
0d8ca7a888 fetchers: use pathToUrlPath in PathInputScheme::toURL 2026-03-02 12:46:16 -05:00
Amaan Qureshi
9c59f62890 url: handle Windows drive letters in fixGitURL 2026-03-02 12:45:36 -05:00
Amaan Qureshi
f3792cdad5 flakeref: use portable root detection in directory walk loops 2026-03-02 12:45:36 -05:00
Amaan Qureshi
b26f2ca3e6 tests: clear NIX_STORE env in fetchers, expr, and flake test environments 2026-03-02 12:45:36 -05:00
Amaan Qureshi
62d275d7c0 tests: use pathToUrlPath for file:// URL construction in git test 2026-03-02 12:45:36 -05:00
Sergei Zimmerman
116cfbc221 Merge pull request #15373 from NixOS/value-alloc-cache-thread-local
libexpr: Make Boehm allocation cache thread_local
2026-03-02 16:13:13 +00:00
Sergei Zimmerman
c806a241b8 Merge pull request #15363 from NixOS/release-notes
Release notes for 2.34.0
2026-03-02 15:29:17 +00:00
John Ericson
8999af2236 Merge pull request #15375 from NixOS/read-little-endian-bswap-tests
libutil: More efficient `readLittleEndian`
2026-03-02 15:00:14 +00:00
Sergei Zimmerman
756ea54470 Merge pull request #15374 from NixOS/windows-system-headers
Use #include <...> for Windows system headers
2026-03-02 13:23:49 +00:00
Sergei Zimmerman
9533aef459 libutil: More efficient readLittleEndian
Because unsigned char * can alias anything, the compiler has no choice
but to actually iterate byte-by-byte in readNum and readLittleEndian:

        │      movzbl -0x2f(%rbp),%eax
  12.54 │      movzbl -0x2e(%rbp),%edx
        │      shl    $0x8,%rax
   1.88 │      shl    $0x10,%rdx
        │      or     %rdx,%rax
        │      movzbl -0x30(%rbp),%edx
   5.09 │      or     %rdx,%rax
   2.37 │      movzbl -0x2d(%rbp),%edx
        │      shl    $0x18,%rdx
   3.95 │      or     %rdx,%rax
        │      movzbl -0x2c(%rbp),%edx
        │      shl    $0x20,%rdx
        │      or     %rax,%rdx
   5.59 │      movzbl -0x2b(%rbp),%eax
   3.29 │      shl    $0x28,%rax
        │      or     %rdx,%rax
   7.83 │      movzbl -0x2a(%rbp),%edx
        │      shl    $0x30,%rdx
        │      or     %rax,%rdx
   8.22 │      movzbl -0x29(%rbp),%eax
        │      shl    $0x38,%rax
        │      or     %rdx,%rax
   6.42 │      mov    %rax,%rcx
        │      mov    %rax,-0x60(%rbp)
   1.35 │      shr    $0x20,%rcxA

Which now compiles down to:

   2.20 │      mov  -0x30(%rbp),%rax
   3.12 │      mov  %rax,%rcx
        │      mov  %rax,-0x60(%rbp)
        │      shr  $0x20,%rcx
2026-03-02 15:56:44 +03:00
Eelco Dolstra
ca07011ed2 Use #include <...> for Windows system headers 2026-03-02 13:31:57 +01:00
Sergei Zimmerman
eba81abab9 libexpr: Make Boehm allocation cache thread_local
This seems quite natural to me, since boehm is necessarily a global
resource. I still think that it would be best if we don't make it a
requirement to only have a single instance of EvalState per thread, but
specifically for this use-case thread_local is a perfect fit.
2026-03-02 13:45:58 +03:00
Sergei Zimmerman
088df89457 Merge pull request #15371 from NixOS/sync-base-cond-var-template
libutil: Template SyncBase over `condition_variable` implementation
2026-03-02 09:43:26 +00:00
John Ericson
0aa4879aaa Merge pull request #15370 from puffnfresh/windows/remove-profiles-symlink
LocalStore: stop creating outdated profiles symlink
2026-03-02 03:29:50 +00:00
Sergei Zimmerman
decc061939 libutil: Template SyncBase over condition_variable implementation
This will allow us to use boost::fibers with the SyncBase class.
2026-03-02 00:58:18 +03:00
Brian McKenna
6244e5fcc1 LocalStore: stop creating outdated profiles symlink
This was done in 9799023545 but
accidentally reverted during a merge.
2026-03-02 07:56:50 +11:00
Sergei Zimmerman
5a3e65826a Add rootless daemon and nix-nswrapper release note
Co-authored-by: Artemis Tosini <artemis.tosini@obsidian.systems>
2026-02-28 01:12:39 +03:00
Sergei Zimmerman
74ec331a46 Indent lint infrastructure more 2026-02-28 00:20:55 +03:00
John Ericson
0acd0566e8 Merge pull request #15360 from roberth/fun
Have `fun`: `std::function` without null
2026-02-27 20:42:23 +00:00
Sergei Zimmerman
2a94f4d782 Add more release notes 2026-02-27 23:35:36 +03:00
Sergei Zimmerman
16f92c6547 Edit release notes 2026-02-27 22:28:54 +03:00
Sergei Zimmerman
cbca7dd47c release notes: 2.34.0 2026-02-27 22:03:28 +03:00
John Ericson
5d695d4af7 Merge pull request #15361 from NixOS/fix-i686-changelog-d
manual: Skip changelog-d on i686
2026-02-27 16:58:39 +00:00
Robert Hensing
152d7a9b48 refactor: use fun
- `fun` was used for variable/field names in a number of places.
  These have been replaced by similar or more descriptive names,
  to avoid name shadowing, which is not allowed in the GCC-based build.

- Use in-place construction instead of assignment.

- `FilteringSourceAccessor::checkAccess` had a fallback for when
  `makeNotAllowedError` was null. Since `MakeNotAllowedError` is now
  `fun<>`, we've proven the null branch is dead code and have removed it.

- `src/nix/flake.cc`, `src/nix/search.cc`, `src/nix/ls.cc` are left
  as-is — the self-referential lambdas there cause too much
  reindentation for too little benefit.
2026-02-27 15:58:12 +01:00
Robert Hensing
4f5117f791 feat(libutil): add fun<Sig>, a non-nullable std::function wrapper
Like `ref<T>` guarantees a non-null pointer, `fun<Sig>` guarantees a
non-null callable.

When a callable is nullable, use `std::function` directly — not
`optional<fun<>>`. The two types serve complementary roles:
`fun<Sig>` for non-null, `std::function<Sig>` for nullable.

Construction from callables (lambdas, function pointers) is implicit
since these are inherently non-null. Construction from `std::function`
is explicit, since it may be empty. `fun(nullptr)` is a deleted
overload.

A moved-from `fun<>` violates its non-null invariant, matching the
precedent set by `ref<T>`. Deleting moves was considered but deemed
unnecessary: the goal of this type is to document and enforce an
invariant, not to force non-null at all costs including performance.

`get_fn()` exposes the underlying `std::function` for API that only
exists there, such as `target<>()`.
2026-02-27 15:58:12 +01:00
Sergei Zimmerman
5207c2e4bd manual: Skip changelog-d on i686 2026-02-27 16:46:49 +03:00
Sergei Zimmerman
2b5a1a9730 Merge pull request #15349 from roberth/fix-cli-messages
Fix package-related CLI messages
2026-02-27 10:30:04 +00:00
John Ericson
b0c932d591 Merge pull request #15354 from obsidiansystems/convert-path-setting
types: remove Path* typedefs
2026-02-27 06:37:48 +00:00
Amaan Qureshi
fc08c86a07 types: remove Path* typedefs
This commit replaces all usages with their underlying types, that being `std::string` for store
paths, `std::filesystem::path` for filesystem paths, `StringSet` for
path sets, and `std::string_view` for non-owning references.
2026-02-27 00:54:28 -05:00
John Ericson
3b003b7245 Merge pull request #15359 from NixOS/error-create-from-lambda
Add `SysError`/`WinError` constructors that take a `HintFmt`-producing function
2026-02-27 02:05:11 +00:00
John Ericson
718e4dbc02 Add SysError/WinError constructors that take a HintFmt-producing function
This allows capturing the current value/result of
`errno`/`GetLastError()` before constructing the error message. Useful
when the error message construction itself might clobber the error code
(e.g., calling `descriptorToPath()`).

Usage:
```
throw NativeSysError([&] { return HintFmt("msg %s", foo()); });
```

The error code is captured when the exception is constructed, then the
lambda is called to produce the `HintFmt`.

Also fix the Windows build
2026-02-26 20:15:21 -05:00
John Ericson
c522f58947 Merge pull request #15357 from obsidiansystems/remove-path-setting
Remove path setting
2026-02-26 23:26:03 +00:00
Amaan Qureshi
c165ae939f libstore: introduce StoreDirSetting for store directory 2026-02-26 17:31:53 -05:00
Amaan Qureshi
9ab4740d44 libutil: remove unused OptionalPathSetting 2026-02-26 17:14:44 -05:00
John Ericson
65617395c6 Merge pull request #15345 from obsidiansystems/no-abs-paths-in-eval-2
Create lint for absolute path literals
2026-02-26 22:11:58 +00:00
John Ericson
69d86ce2e4 Merge pull request #15356 from NixOS/fix-i686-unsigned-promotion-narinfo-disk-cache
Fix NarInfoDiskCache::queryCacheRaw on 32 bit platforms
2026-02-26 22:02:43 +00:00
Sergei Zimmerman
796f5cd724 treewide: Get rid of confusing time(0) and use proper nullptr literal
Use proper nullptr literal for NULL pointer instead of the rather confusing 0
literal.
2026-02-27 00:18:12 +03:00
Sergei Zimmerman
bcf2cd4feb Fix NarInfoDiskCache::queryCacheRaw on 32 bit platforms
Bug has existed for a long time, but was only recently surfaced by
6733f2e5ce. time_t was being implicitly promoted
to unsigned. Apparently time_t is still 32 bit for i686-linux in nixpkgs.

Fixes https://hydra.nixos.org/build/322992746/nixlog/1
2026-02-27 00:16:39 +03:00
John Ericson
ed494f00ca Create lint for absolute path literals
Fixes #8738
2026-02-26 15:06:18 -05:00
Robert Hensing
eda9c014c5 fix(eval): render store path context in user-facing format
forceStringNoCtx error messages leaked internal string context
representation (e.g. '!out!<hash>-name.drv'). Use DerivedPath
syntax instead: '<store-path>^out' for built, plain path for
opaque, and '<drv-path> (deep)' for deep derivation references.
2026-02-26 18:06:51 +01:00
Robert Hensing
1442133f1e fix(get-drvs): correct misleading "CA derivations" error in queryOutPath
The error had nothing to do with content-addressed derivations; it
triggers when a supposed derivation attrset simply lacks an outPath
attribute.
2026-02-26 18:06:51 +01:00
Robert Hensing
fd984a3e9d tests: add CLI characterisation tests
Improve coverage ahead of changes to get-drvs.cc and related code.
Each fixture is a separate file to avoid line-number churn in error
expectations.
2026-02-26 18:06:51 +01:00
Sergei Zimmerman
128688db63 Merge pull request #15280 from NixOS/local-store-filesystem
libstore: Fix pct-encoding issues in store references
2026-02-26 15:37:50 +00:00
Sergei Zimmerman
224c8182df libstore: Fix pct-encoding issues in store references
When the common pattern for store config constructors is to accept
an arbitrary string it's unclear whether it needs pct-decoding or not.
Prior to c436b7a32a the string passed to
the constructors was a mix of encoded authority and decoded path concatenated
with a `/`. After that commit it accidentally started accepting pct-encoded
result of renderAuthorityAndPath, but only in some code paths. This lead to
file:///tmp/a+b to be created on disk in /tmp/a%2Bb directory. Similar issue
affected the less-known variant with local:///tmp/a+b. Regular store references
that are local paths were not affected.

This patch changes the constructors to accept different types to signify what
is actually needed to let the factory method handle this in a consistent way:

- std::filesystem::path - local binary cache store and local store
- ParsedURL::Authority - for ssh stores
- ParsedURL - for http stores

(Some MinGW build fixes by Amaan Qureshi <git@amaanq.com>)
2026-02-26 16:40:49 +03:00
Sergei Zimmerman
db06ac411c Merge pull request #15347 from obsidiansystems/unlink-wrapper
Create two wrappers for `unlink`
2026-02-26 09:20:16 +00:00
John Ericson
d9dd677448 Create two wrappers for unlink
See b9ef088e80 for why
`std::filesystem::remove` was no good.
2026-02-25 22:27:59 -05:00
John Ericson
ee955b3206 Merge pull request #15346 from obsidiansystems/return-owned-fd
Return `AutoCloseFD` in open-like functions
2026-02-26 02:09:43 +00:00
John Ericson
89dd96efbf Return AutoCloseFD in open-like functions
This reflects the fact that it is returning a new, "owned" file
descriptor, that it is the caller's responsibility to close.

Co-authored-by: Amaan Qureshi <git@amaanq.com>
2026-02-25 20:17:30 -05:00
John Ericson
6481e75283 Merge pull request #15344 from NixOS/no-filesystem-remove
Revert "libstore: replace unlink() with std::filesystem::remove()"
2026-02-26 00:50:16 +00:00
John Ericson
b9ef088e80 Revert "libstore: replace unlink() with std::filesystem::remove()"
This reverts commit b8caabe25f.

`std::filesystem::remove` will actually do a `rmdir` for directories.
Per https://en.cppreference.com/w/cpp/filesystem/remove.html :

> The file or empty directory identified by the path p is deleted as if
> by the POSIX remove. Symlinks are not followed (symlink is removed,
> not its target).

See
https://pubs.opengroup.org/onlinepubs/9699919799/functions/remove.html

This is a behavior change that we can't be sure is fine, so let's revert
for now. We can do an unlink wrapper later to avoid the `.string()`.
2026-02-25 18:59:28 -05:00