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

20700 commits

Author SHA1 Message Date
Farid Zakaria
33ceea6099 Unpeel reference for git+file
If the reference for git+file is an annotated tag, the revision will
differ than when it's fetched using other fetchers such as `github:`
since Github seems to automatiacally peel to the underlying commit.

Turns out that rev-parse has the capability through it's syntax to
request the underlying commit by "peeling" using the `^{commit}` syntax.

This is safe to apply in all scenarios where the goal is to get an
underlying commit.

fixes #11266
2025-07-21 21:10:41 -07:00
John Ericson
3cbcceee02
Merge pull request #13519 from xokdvium/pch-instantiate-templates
meson: Further optimize compile times with PCH template instantiations
2025-07-21 22:39:45 -04:00
Sergei Zimmerman
ebd311b7b7
meson: Correctly handle endianness for PowerPC CPU families
I've missed this while reviewing 6db6190002.
I only built big endian ppc64, so that didn't occur to me.

From meson manual:

> Those porting from autotools should note that Meson does not add
> endianness to the name of the cpu_family. For example, autotools will
> call little endian PPC64 "ppc64le", Meson will not, you must also check
> the .endian() value of the machine for this information.

This code should handle that correctly.
2025-07-22 03:27:27 +03:00
Farid Zakaria
0c32b0c8c3 Added comment to test case 2025-07-22 02:52:53 +03:00
Farid Zakaria
48083028ac Add a test case for failing git cache
builtins.fetchGit is not using the cached Git directory if
packed-references are used.

This is because the ref file for the fetchGit `refs/heads/master` is
used to check the mtime for whether to cache or not.

Let's at least codify this failure in a test case.
2025-07-22 02:52:53 +03:00
Sergei Zimmerman
9bc6c30d97
meson: Further optimize compile times with PCH template instantiations
This is a follow-up to 6ec50ba736, which
also almost halves the compile times on clang for subprojects that use PCH.

`-fpch-instantiate-templates` is a clang-only option to force the instantiation
of templates once in the PCH itself, not all of the translation units that
it gets included to. This really cuts down on the overhead from nlohmann::json
and std::format code:

 48244 ms: nlohmann::basic_json<>::parse<const char *> (76 times, avg 634 ms)
 36193 ms: nlohmann::basic_json<>::basic_json (310 times, avg 116 ms)
 28307 ms: nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::i... (76 times, avg 372 ms)
 20334 ms: nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::i... (76 times, avg 267 ms)
 17387 ms: nlohmann::basic_json<>::json_value::json_value (389 times, avg 44 ms)
 16822 ms: std::vformat_to<std::__format::_Sink_iter<char>> (76 times, avg 221 ms)
 16771 ms: std::__format::__do_vformat_to<std::__format::_Sink_iter<char>, char... (76 times, avg 220 ms)
 12160 ms: std::vformat_to<std::__format::_Sink_iter<wchar_t>> (76 times, avg 160 ms)
 12127 ms: std::__format::__do_vformat_to<std::__format::_Sink_iter<wchar_t>, w... (76 times, avg 159 ms)
 10397 ms: nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<... (76 times, avg 136 ms)
  9118 ms: nlohmann::basic_json<>::data::data (76 times, avg 119 ms)

Initially done by Jade Lovelace <lix@jade.fyi> in https://gerrit.lix.systems/c/lix/+/1842.
We are doing basically the same, but unconditionally. It would be
a huge pain to add a pch option for all subprojects to just support the
usecase of using clangd in a gcc devshell.

In total, this basically halves the frontend times for nix-util and nix-store
to the point that the most expensive part of the build is linking.

(nix-store before):

```
**** Time summary:
Compilation (77 times):
  Parsing (frontend):          243.4 s
  Codegen & opts (backend):    140.3 s
```

(nix-store after):

```
**** Time summary:
Compilation (77 times):
  Parsing (frontend):          120.2 s
  Codegen & opts (backend):    141.2 s
```
2025-07-22 02:39:06 +03:00
Sergei Zimmerman
e2b0ff18f8
Merge pull request #13514 from OPNA2608/fix/meson-powerpc-cpu-names
treewide: Fix Meson CPU names for powerpc CPUs
2025-07-22 01:48:22 +03:00
OPNA2608
6db6190002 treewide: Fix Meson CPU names for powerpc CPUs 2025-07-21 19:03:49 +02:00
Robert Hensing
6ec50ba736
Merge pull request #13512 from xokdvium/speed-up-builds-pch
Reintroduce precompiled headers
2025-07-21 12:38:52 +02:00
Sergei Zimmerman
7e184bbc29
Merge pull request #13510 from xokdvium/build-profiling 2025-07-21 11:44:12 +03:00
Sergei Zimmerman
9dae9f6cab
nix-cli: Speed up builds by using precompiled headers 2025-07-20 22:02:01 +03:00
Sergei Zimmerman
46469983e7
libcmd: Speed up builds by using precompiled headers 2025-07-20 22:01:59 +03:00
Sergei Zimmerman
af6c84b523
libexpr: Speed up builds by using precompiled headers 2025-07-20 22:01:56 +03:00
Sergei Zimmerman
33d031095f
libstore: Speed up builds by using precompiled headers 2025-07-20 22:01:53 +03:00
Sergei Zimmerman
e920e28734
libutil: Speed up builds by using precompiled headers 2025-07-20 22:01:51 +03:00
Sergei Zimmerman
9c58c8f739
ci: Add build profiling job
This adds a GHA jobs to help analyze build times
and its regressions. It is based on `clangStdenv` with `-ftime-trace`
together with `ClangBuildAnalyzer` to prepare markdown summary for
individual components.

This also has the minor benefit of dogfooding CA and impure derivations.
2025-07-20 18:26:26 +03:00
Sergei Zimmerman
c70e1433ab
Merge pull request #13073 from roberth/first-class-splicing
First class cross
2025-07-19 17:58:10 +03:00
Robert Hensing
9b9e49e8e4 overlays.default: Only set nix
We should keep users' pkgs tidy.
2025-07-19 16:27:55 +03:00
Robert Hensing
e70dac8244 doc: Add brief comments to the components
Users can access these through the `lib.makeComponents` return value,
so it's helpful to briefly explain some of them.

This doesn't replace `meta.description`, but supplements it.
(TODO: improve `meta.description`)
2025-07-19 16:27:55 +03:00
Robert Hensing
0468c1d69a flake.nix: Create package sets independent of overlay
This was carefully refactored by inlining some Nixpkgs definitions
like `generateSplicesForMkScope`, so the memoization properties
should remain the same.
2025-07-19 16:27:55 +03:00
Sergei Zimmerman
a54284cbc7
rl-next: Add release note about IPv6 Scoped Addresses in URIs 2025-07-18 21:24:03 +03:00
Sergei Zimmerman
bd1d2d1041
libutil: Use Boost.URL in parseURL
Boost.URL is a significantly more RFC-compliant parser
than what libutil currently has a bundle of incomprehensible
regexes.

One aspect of this change is that RFC4007 ZoneId IPv6 literals
are represented in URIs according to RFC6874 [1].

Previously they were represented naively like so: [fe80::818c:da4d:8975:415c\%enp0s25].
This is not entirely correct, because the percent itself has to be pct-encoded:

> "%" is always treated as
   an escape character in a URI, so, according to the established URI
   syntax [RFC3986] any occurrences of literal "%" symbols in a URI MUST
   be percent-encoded and represented in the form "%25".  Thus, the
   scoped address fe80::a%en1 would appear in a URI as
   http://[fe80::a%25en1].

[1]: https://datatracker.ietf.org/doc/html/rfc6874

Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
2025-07-18 21:24:01 +03:00
Sergei Zimmerman
d020f21a2a
libutil: Use default operator== for ParsedURL
The default comparison operator can be generated
by the compiler since C++20.
2025-07-18 21:23:42 +03:00
Sergei Zimmerman
ad449c0288
libutil: Refactor percentDecode,percentEncode to use Boost.URL
The myriad of hand-rolled URL parsing and validation code
is a constant source of problems. Regexes are not a great way
of writing parsers and there's a history of getting them wrong.
Boost.URL is a good library we can outsource most of the heavy
lifting to.
2025-07-18 21:23:40 +03:00
Sergei Zimmerman
d9053390ce
libutil-test-support: Add HasSubstrIgnoreANSIMatcher
This matcher is useful for checking error messages, which
always contain ANSI escapes.
2025-07-18 21:23:38 +03:00
Sergei Zimmerman
ffc9bfb66d
lib{store,flake}-tests: Add test for spaces in URIs
These cases do not seem to be covered by the test suite at all.
2025-07-18 21:23:35 +03:00
Sergei Zimmerman
b8d223a210
Merge pull request #13108 from DeterminateSystems/check-format
Rip off the bandaid: Format the codebase with clang-format
2025-07-18 20:38:50 +03:00
Graham Christensen
fb493ad7ca Update .git-blame-ignore-revs to ignore the mass reformatting 2025-07-18 12:47:27 -04:00
Graham Christensen
e4f62e4608 Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter,
* It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files
* Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose,

Let's rip the bandaid off?

Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
2025-07-18 12:47:27 -04:00
Graham Christensen
e7af2e6566 Drop a ton of files that should just get formatted 2025-07-18 12:46:51 -04:00
Graham Christensen
41bf87ec70 Update clang-format with fixing namespace coments, and separate definition blocks 2025-07-18 12:46:51 -04:00
Graham Christensen
6896761d79 Add sed 2025-07-18 12:46:51 -04:00
Graham Christensen
ee9b57cbf5 format.sh: support looping until it is happy 2025-07-18 12:46:51 -04:00
Sergei Zimmerman
60c48b7058
Merge pull request #13501 from k1gen/fix-rsync-requirement
Require rsync in nix-manual meson.build
2025-07-18 00:43:27 +03:00
Oleksandr Knyshuk
cfb8a31885
Require rsync in nix-manual meson.build
Closes: #13313
2025-07-17 22:59:37 +02:00
Jörg Thalheim
599c1d78ed
Merge pull request #13496 from k1gen/fix-help-shell-command
Fix `nix help shell` by properly handling command aliases
2025-07-17 19:40:47 +02:00
Jörg Thalheim
4c95086879
Merge pull request #13493 from Mic92/clang-tidy-virtual-methods
Fix virtual method calls during construction
2025-07-17 17:41:18 +02:00
Oleksandr Knyshuk
d678b071d6
Make nix help shell work by handling aliases properly
Previously, `nix help shell` failed with "Nix has no subcommand 'shell'" despite `nix shell --help`
working correctly. This happened because the `shell` command is actually an alias for `env shell`,
and the help system wasn't resolving aliases when looking up documentation.

This patch modifies the `showHelp` function to check for and resolve aliases before generating the
manpage name, ensuring that shorthand commands like `shell` get proper help documentation.

Closes: #13431
2025-07-17 17:26:56 +02:00
Jörg Thalheim
3c0cd73418 Fix uninitialized field in Attr constructor
The default constructor for Attr was not initializing the value pointer,
which could lead to undefined behavior when the uninitialized pointer is
accessed. This was caught by clang-tidy's UninitializedObject check.

This fixes the warning:
  1 uninitialized field at the end of the constructor call
  [clang-analyzer-optin.cplusplus.UninitializedObject]
2025-07-17 17:12:20 +02:00
Jörg Thalheim
6bf940d636 Fix clang-tidy uninitialized value warning in derivation-options.cc
Make lambda capture explicit to avoid clang-analyzer-core.CallAndMessage warning
2025-07-17 17:09:46 +02:00
Jörg Thalheim
4ba3b15a10 Fix s3.hh to include public config header
The s3.hh public header was incorrectly including store-config-private.hh
instead of the public config.hh. Since NIX_WITH_S3_SUPPORT is defined in
the public config, this caused clang-tidy to report it as undefined.
2025-07-17 17:09:38 +02:00
Jörg Thalheim
6e733b0544 Fix SIZE_MAX undefined warning in fchmodat2-compat.hh
Include <cstdint> to ensure SIZE_MAX is defined
2025-07-17 17:08:49 +02:00
Jörg Thalheim
32a11a64c1
Merge pull request #13491 from Mic92/clang-tidy-windows-fixes
Fix Windows header inclusions for clang-tidy
2025-07-17 16:46:54 +02:00
Jörg Thalheim
36d451ddf4
Merge pull request #13476 from NixOS/improve-ignored-exceptions
Improve rendering of ignored exceptions
2025-07-17 15:57:59 +02:00
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
tomberek
5ced59a21b
Merge pull request #13449 from fzakaria/issue-10431
Add error message when git returns non-0 for fetch
2025-07-17 02:50:13 -04:00