1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00
Commit graph

20474 commits

Author SHA1 Message Date
Oleksandr Knyshuk
6d46dc9f6a
Add warn-short-path-literals setting
Add a new setting to warn about path literals that don't start with "." or "/". When enabled,
expressions like `foo/bar` will emit a warning suggesting to use `./foo/bar` instead.

A functional test is included.

The setting defaults to false for backward compatibility but could eventually default to true in
the future.

Closes: #13374

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2025-07-29 15:47:58 +02:00
John Ericson
47f5e5fbef
Merge pull request #13567 from xokdvium/split-sanitizers-ci
ci: Run sanitizer tests in a separate job
2025-07-28 17:21:19 -04:00
Sergei Zimmerman
413f782176
ci: Run sanitizer tests in a separate job
This should speed up the CI somewhat by parallelizing
the work across the matrix of configurations.
2025-07-28 23:37:04 +03:00
Jörg Thalheim
9c9473aa9b
Merge pull request #13566 from xokdvium/refactor-ci-tests
flake: Factor out checks into ci/gha/tests for reusability
2025-07-28 21:11:13 +02:00
Robert Hensing
5bd68f24aa
Merge pull request #13543 from obsidiansystems/git-256
Implement support for Git hashing with SHA-256
2025-07-28 21:00:32 +02:00
Sergei Zimmerman
9913ec55ba
flake: Factor out checks into ci/gha/tests for reusability
This moves out the checks that get run in GHA CI into ci/gha/tests
folder and splits those into `topLevel` and `componentTests` attributes.
The idea behind this is to make it easier to parametrize tests that can
be run with sanitizers in order to run those as a matrix of jobs. The same
can be said for static builds.

Existing stdenv selection infrastructure via `lib.makeComponents` would
also allow us to switch over to using `clangStdenv` to significantly speed
up pre-merge CI (though the default stdenv would still be used for non-overridable
topLevel checks, like installer artifacts).
2025-07-28 03:26:48 +03:00
Sergei Zimmerman
cff021898d
Merge pull request #13525 from alurm/patch-1
doc/advanced-attributes.md: remove stray backslashes in the rendered output
2025-07-28 01:34:58 +03:00
John Ericson
44a8f8d02b
Merge pull request #13558 from xokdvium/nix-cpu-system-fix
meson: Fix `nix_system_cpu` for MIPS and 32 bit ARM systems
2025-07-26 19:18:57 -04:00
Sergei Zimmerman
a2561b853a
Merge pull request #13557 from Jayman2000/sometimes-build-manual-when-cross-compiling
Sometimes build `nix-manual` when cross compiling
2025-07-27 01:28:34 +03:00
Sergei Zimmerman
60d124b36e
meson: Fix nix_system_cpu for MIPS and 32 bit ARM systems
Prior patches in 54dc5314e8
and 6db6190002 fixed the default
system double for i686 and ppc/ppc64. This also patch also covers
32 bit arm and mips. ARM cpu names are taken from host_machine.cpu()
for a lack of a better option, but host_machine.cpu_family() is
preferred, since that is supposed to be somewhat standard for cross
files. Endianness is handled correctly by looking at host_machine.endian().

This also updates the documentation to be up to date to how system cpu
is translated from the host_machine specification.
2025-07-27 00:50:53 +03:00
Jason Yundt
5e407e6abb Sometimes build nix-manual when cross compiling
Before this change, if you were cross compiling Nix, then the nix-manual
subproject would never get built. In some situations, it makes sense to
not build the nix-manual subproject when cross compiling. For example,
if the build system is x86_64 and the host system is riscv64, then it
makes sense to not build the manual. Building the manual requires
executing certain build artifacts, and you can’t run x86_64 executables
on riscv64 systems.

That being said, there are some situations where it does make sense to
build the nix-manual subproject when cross compiling. For example, if
the build system is x86_64 and the host system is i686, then it doesn’t
make sense to not build the manual. You can run i686 executables on
x86_64 systems just fine.

This change makes it so that the nix-manual subproject will sometimes
get built when cross compiling. Specifically, the nix-manual subproject
will get built as long as the doc-gen option is enabled and the build
system is capable of running host binaries.

---

The main motivation behind this change is to fix this Nixpkgs issue [1].
Building pkgs.nixStatic counts as cross compiling Nix, and
pkgs.nixStatic is supposed to produce a man output. Building
pkgs.nixStatic currently fails because it isn’t actually producing a man
output. That issue will go away once this commit gets backported to Nix
2.28.x.

[1]: <https://github.com/NixOS/nixpkgs/issues/426410>
2025-07-26 15:00:02 -04:00
John Ericson
d21e3f88ec Implement support for Git hashing with SHA-256
SHA-256 is Git's next hash algorithm. The world is still basically stuck
on SHA-1 with git, but shouldn't be. We can at least do our part to get
ready.

On the C++ implementation side, only a little bit of generalization was
needed, and that was fairly straight-forward. The tests (unit and
system) were actually bigger, and care was taken to make sure they were
all cover both algorithms equally.
2025-07-25 10:19:08 -04:00
Jörg Thalheim
7f4acb9f10
Merge pull request #13553 from roberth/fix-url
Fix documentation link
2025-07-25 11:37:58 +02:00
Robert Hensing
49f411c08c Update developer facing links to nix.dev
Not broken, but it's a tiny bit quicker
2025-07-25 10:59:44 +02:00
Robert Hensing
b7782809cb docs, messages: Resolve nixos.org/manual/nix/stable redirect
Loads a bit quicker
2025-07-25 10:18:13 +02:00
Robert Hensing
35835e0644 Fix documentation link
The file was renamed. We've also moved to nix.dev, but that was
redirected properly.
Closes #13488
2025-07-25 10:18:11 +02:00
Sergei Zimmerman
d4c562c6ff
Merge pull request #13546 from xokdvium/dogfood-ci-boolean
ci: Make it actually possible to disable dogfooding
2025-07-25 02:18:00 +03:00
Sergei Zimmerman
f0695e177f
ci: Make it actually possible to disable dogfooding
Github composite actions are a real treat. Boolean inputs
are not actually booleans but rather strings [1].

[1]: https://www.github.com/actions/runner/issues/2238
2025-07-25 00:31:04 +03:00
Eelco Dolstra
2b22871ea2
Merge pull request #13535 from NixOS/fix-i686
Fix nix_system_cpu on i686-linux
2025-07-24 19:13:06 +02:00
Eelco Dolstra
54dc5314e8 Fix nix_system_cpu on i686-linux
Fixes #13532.
2025-07-24 18:06:06 +02:00
John Ericson
f0485520cc
Merge pull request #13530 from KAction/contrib/0/nar-format/out
Fix documentation of the NAR archive structure
2025-07-24 11:17:33 -04:00
Eelco Dolstra
cbdb497c79
Merge pull request #13478 from NixOS/posix-source-accessor-concurrent-map
PosixSourceAccessor: Use concurrent_flat_map
2025-07-24 11:19:37 +02:00
Robert Hensing
3543a73195
Merge pull request #13456 from fzakaria/git-pack-ref-cache
Add a test case where fetchGit is failing to cache due to packed-refs
2025-07-23 23:04:29 +02:00
Robert Hensing
eed1d370d0
Merge pull request #13521 from fzakaria/fzakaria/issue-11266
Unpeel reference for git+file
2025-07-23 22:36:44 +02:00
Jörg Thalheim
a3f6508761
Merge pull request #13520 from xokdvium/ppc-meson-endian
meson: Correctly handle endianness for PowerPC CPU families
2025-07-23 22:35:58 +02:00
Jörg Thalheim
7ff426627d
Merge pull request #13506 from xokdvium/simplify-installer-tests
ci: Simplify installer tests
2025-07-23 22:25:38 +02:00
Sergei Zimmerman
c6d0d33e4d ci: Simplify installer tests 2025-07-23 21:52:23 +02:00
Eelco Dolstra
3a67cafa0d Merge branch 'master' (reformat) 2025-07-23 21:22:27 +02:00
Eelco Dolstra
72e8f7cd35 Merge branch 'master' (pre-reformat) 2025-07-23 21:22:19 +02:00
Alan Urmancheev
bd29dc67b7
doc/advanced-attributes.md: remove stray backslashes in the rendered output
They have appeared literally because the was an empty line after them.
2025-07-23 17:32:52 +04:00
Dmitry Bogatov
143b87c1a9 Fix documentation of the NAR archive structure
For regular, non-executable files, there is no str("") between str("regular")
and str("contents"). Note that str("") is exactly 8 zero bytes, while just ""
is actual empty string (0 bytes).
2025-07-22 20:00:00 -04:00
Sergei Zimmerman
9671275198
Merge pull request #13522 from juhp/patch-1
meson: libfetchers needs libgit2 1.9+
2025-07-22 21:45:17 +03:00
Jens Petersen
ff6ab3b213
meson: libfetchers needs libgit2 1.9+
libfetchers uses `git_mempack_write_thin_pack` which was introduced in libgit2-1.9.0

This avoids error like:

../src/libfetchers/git-utils.cc: In member function ‘virtual void nix::GitRepoImpl::flush()’:
../src/libfetchers/git-utils.cc:270:13: error: ‘git_mempack_write_thin_pack’ was not declared in this scope
  270 |             git_mempack_write_thin_pack(mempack_backend, packBuilder.get())
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

on older libgit2 (like 1.7.2 in Centos Stream 10)
2025-07-22 22:58:55 +08:00
Farid Zakaria
aadfb682d4 Fix fetchGit functional tests to peel as well 2025-07-21 22:01:05 -07:00
Farid Zakaria
98858148dc Add unit test 2025-07-21 21:56:11 -07:00
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