1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 15:48:00 +02:00
Commit graph

11380 commits

Author SHA1 Message Date
Eelco Dolstra
da2c2547a9
Merge pull request #12033 from Mic92/various-picks
Various packaging improvements
2024-12-11 17:01:39 +01:00
Eelco Dolstra
50ba85167c
Merge pull request #12024 from NaN-git/null-char
fromJSON/fromTOML: throw if string contains null byte
2024-12-10 12:29:48 +01:00
Jörg Thalheim
7bd8ece4ba
Merge pull request #12009 from DeterminateSystems/401-cache
HttpBinaryCacheStore: Improve error message for unauthorized caches
2024-12-10 05:41:37 +01:00
Jörg Thalheim
41a464c68d tests/libstore.hh: reformat with clang-format after update 2024-12-10 05:28:50 +01:00
John Ericson
747256cbe1
Merge pull request #11921 from NixOS/log-json-tolerant
Make @nix json structured build log parsing warn instead of fail
2024-12-09 16:39:04 -05:00
Philipp Otterbein
3a9d64b8e3 fromJSON/fromTOML: throw if string contains null byte 2024-12-09 22:04:21 +01:00
Robert Hensing
f3c722cab2 Remove redundant warning: prefix from structured build log warning 2024-12-09 17:20:27 +01:00
Robert Hensing
d0b4db924a rename: build-utils-meson -> nix-meson-build-support
Fix a footgun. In my case, I had a couple of build ("output")
directories sitting around.

    rm -rf build-*

Was confused for a bit why a meson.build file was missing.

Probably also helps with autocompletion.

I tried meson-build-support first, but I had to add something like
a nix- prefix, in order to make meson happy. They've reserved the
meson- prefix.
2024-12-09 16:54:42 +01:00
Robert Hensing
03d4bfd852 Push log source description out of libutil and report build hook @nix warning correctly 2024-12-09 15:59:59 +01:00
Linus Heckemann
ee03fd478e libutil: handle json builder log messages with unexpected format
Before this change, expressions like:

with import <nixpkgs> {};
runCommand "foo" {} ''
  echo '@nix {}' >&$NIX_LOG_FD
''

would result in Lix crashing, because accessing nonexistent fields of
a JSON object throws an exception.

Rather than handling each field individually, we just catch JSON
exceptions wholesale. Since these log messages are an unusual
circumstance, log a warning when this happens.

Fixes #544.

Change-Id: Idc2d8acf6e37046b3ec212f42e29269163dca893
(cherry picked from commit e55cd3beea710db727fd966f265a1b715b7285f3)
2024-12-09 15:59:59 +01:00
Philipp Otterbein
ad3a67a2a0 optimize string concat 2024-12-07 04:42:04 +01:00
Robert Hensing
a7cdb55b44
Merge pull request #12013 from DeterminateSystems/fix-11996
nix hash convert: Support SRI hashes that lack trailing '=' characters
2024-12-05 23:29:30 +01:00
‮rekcäH nitraM‮
49fa31fb4c
Fix typo (#12015) 2024-12-05 19:10:59 +00:00
Eelco Dolstra
408c2faf93 nix hash: Don't print 'nix hash' deprecation message
Fixes #11997.
2024-12-05 16:25:05 +01:00
Eelco Dolstra
33b645cedf nix hash convert: Don't fail on uppercase base-16 hashes 2024-12-05 16:19:21 +01:00
Eelco Dolstra
52f1cd0595 nix hash convert: Support SRI hashes that lack trailing '=' characters
Fixes #11996.
2024-12-05 16:02:35 +01:00
Eelco Dolstra
3b21ea40cc HttpBinaryCacheStore: Improve error message for unauthorized caches
Instead of the unhelpful

  warning: 'https://cache.flakehub.com' does not appear to be a binary cache

you now get

  warning: unable to download 'https://cache.flakehub.com/nix-cache-info': HTTP error 401

           response body:

           {"code":401,"error":"Unauthorized","message":"Unauthorized."}
2024-12-04 16:52:30 +01:00
mupdt
abcfdb4bda s3-binary-cache: show the error's request ID
The request ID is essential for traceability and debugging purposes.
It allows us to connect client-side to server-side events.
2024-12-04 05:49:21 -05:00
Eelco Dolstra
e5e09006f9 Work around gcc warning
Same as 57fea81f8a.
2024-11-28 15:25:51 +01:00
Ryan Hendrickson
8034589d7e parser-state: fix attribute merging 2024-11-27 21:41:47 +01:00
Sergei Trofimovich
d67aa03414 src/perl/meson.build: fall back to 'bz2' library lookup
Upstream `bzip2` does not provide `pkg-config` files. As a result an
attempt to build `nix` on some distributions like Gentoo failos the
configure as:

    $ meson setup ..
    ...
    Executing subproject perl
    ...
    perl| Run-time dependency bzip2 found: NO (tried pkgconfig and cmake)
    ../src/perl/meson.build:68:12: ERROR: Dependency "bzip2" not found, tried pkgconfig and cmake

The change falls back to `bz2` library for such cases.
2024-11-26 18:37:53 +00:00
Eelco Dolstra
d0f84fd2a5
Merge pull request #11959 from Mic92/better-errors
more readable errors if symlinks cannot be created
2024-11-26 18:06:27 +01:00
Eelco Dolstra
4f50b1d178
Merge pull request #11944 from xokdvium/dev/remove-unnecessary-copies
fix(treewide): remove unnecessary copying in range for loops
2024-11-26 12:56:51 +01:00
Jörg Thalheim
5b8728d393 more readable errors if symlinks cannot be created
Before:

filesystem error: cannot create symlink: Permission denied [/nix/store/1s2p3a4rs172336hj2l8n20nz74hf71j-nix-eval-jobs-2.24.1.drv] [/1s2p3a4rs172336hj2l8n20nz74hf71j-nix-eval-jobs-2.24.1.drv.tmp-2772352-1316231068]

Now:

creating symlink '/wfxz2q489c811n08cdqj7ywxm3n4z6m5-nix-eval-jobs-2.24.1.drv.tmp-2971297-324653080' -> '/nix/store/wfxz2q489c811n08cdqj7ywxm3n4z6m5-nix-eval-jobs-2.24.1.drv': Permission denied
2024-11-26 09:35:40 +01:00
Sergei Zimmerman
f9980b5715 fix(libutil/config): declare virtual dtor for AbstractConfig
This prevents any potential cases of deletion through base pointer and its
non-virtual dtor, which might leak memory. Also gets rid of the warning:

/nix/store/fg7ass3a5m5pgl26qzfdniicbwbgzccy-gcc-13.2.0/include/c++/13.2.0/bits/stl_construct.h:88:2: warning: destructor called on non-final 'nix::flake::Settings' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
   88 |         __location->~_Tp();
....
../src/libflake-c/nix_api_flake.cc:10:30: note: in instantiation of function template specialization 'nix::make_ref<nix::flake::Settings>' requested here
   10 |         auto settings = nix::make_ref<nix::flake::Settings>();
2024-11-26 00:17:30 +03:00
Sergei Zimmerman
fafaec5ac3 fix(treewide): remove unnecessary copying in range for loops
This gets rid of unnecessary copies in range-based-for loops and
local variables, when they are used solely as `const &`.

Also added a fixme comment about a suspicious move out of const,
which might not be intended.
2024-11-26 00:06:29 +03:00
John Ericson
4fc5295328
Merge pull request #11953 from DeterminateSystems/fix-warning
Work around gcc warning
2024-11-25 10:40:06 -05:00
Eelco Dolstra
57fea81f8a Work around gcc warning
This shuts up a 300-line warning that includes

  /nix/store/fg7ass3a5m5pgl26qzfdniicbwbgzccy-gcc-13.2.0/include/c++/13.2.0/bits/stl_tree.h:182:25: warning: ‘*(std::_Rb_tree_header*)((char*)&<unnamed> + offsetof(nix::value_type, nix::DerivedPath::<unnamed>.std::variant<nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Variant_base<nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Move_assign_base<false, nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Copy_assign_base<false, nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Move_ctor_base<false, nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Copy_ctor_base<false, nix::DerivedPathOpaque, nix::DerivedPathBuilt>::<unnamed>.std::__detail::__variant::_Variant_storage<false, nix::DerivedPathOpaque, nix::DerivedPathBuilt>::_M_u) + 24).std::_Rb_tree_header::_M_header.std::_Rb_tree_node_base::_M_parent’ may be used uninitialized [-Wmaybe-uninitialized]
    182 |       if (__x._M_header._M_parent != nullptr)
        |           ~~~~~~~~~~~~~~^~~~~~~~~
2024-11-25 16:01:54 +01:00
Jörg Thalheim
3180c09723
Merge pull request #11951 from Mic92/libstore
source-accessor: fix case where normalization goes beyond root
2024-11-25 15:46:18 +01:00
Jörg Thalheim
3fb7481e64 source-accessor: fix case where normalization goes beyond root
fixes https://github.com/NixOS/nix/issues/11936
2024-11-25 15:11:36 +01:00
Robert Hensing
46b0f7755f
Merge pull request #11940 from NixOS/c-api-libflake
C API: Add libflake-c
2024-11-25 10:00:56 +01:00
Robert Hensing
d004c524b8 test: Change FAIL to throw
[FAIL()] is a macro with `return`, making it unsuitable for helpers.

This uses std::runtime_error, because gtest does not seem to provide an
exception type of its own for this purpose. [AssertionException] is for
a different use case.

[FAIL()]: https://google.github.io/googletest/reference/assertions.html#FAIL
[AssertionException]: 35d0c36560/docs/reference/testing.md (assertionexception-assertionexception)
2024-11-24 23:57:24 +01:00
Robert Hensing
4eecf3c20a Add nix-flake-c, nix_flake_init_global, nix_flake_settings_new 2024-11-24 23:57:24 +01:00
Robert Hensing
f06f611ff3 refactor: Extract unsafe_new_with_self 2024-11-24 23:57:24 +01:00
Robert Hensing
1bd7517801 Doc nix_get_path_string 2024-11-24 23:57:24 +01:00
Robert Hensing
82a23d9b6b libexpr-c: Add nix_eval_state_builder 2024-11-24 23:57:24 +01:00
Sergei Zimmerman
fbffd47fb7 build(lib{expr,store,util}-test-support): depend on -c libraries
Since lib{expr,store,util}-test-support subprojects define nix_api_* helpers
for testing nix c bindings, they need to publicly depend on -c counterparts.
This makes their headers self-sufficient and does not rely on the -tests to add
necessary dependencies.
2024-11-24 09:53:10 +00:00
Jörg Thalheim
acb60fc359
Merge pull request #11937 from xokdvium/dev/exterminate-dead-variables
chore: get rid of dead code and unused variables where appropriate
2024-11-24 10:50:58 +01:00
Jörg Thalheim
fb6e37b834
Merge pull request #11943 from xokdvium/dev/registry-remove-use-erase
refactor(libfetchers/registry): use standard remove_if + erase
2024-11-24 10:43:42 +01:00
Sergei Zimmerman
09ddc34b62 refactor(libfetchers/registry): use standard remove_if + erase
Get rid of this fixme. This does not appear to be used anywhere in
the nix codebase itself. Not sure why the comment mentioned C++20 erase
member function with predicate, but iterator-based algorithms are also fine.
2024-11-24 00:19:26 +03:00
Sergei Zimmerman
756758d968 chore: get rid of dead code and unused variables where appropriate
Looks like some cruft has been left over from previous refactorings.
This removes dead variables, which should not have side effects in their
constructors. In cases where the variable initialization has a purpose
[[maybe_unused]] is inserted to silence compiler warnings.
2024-11-22 18:05:53 +03:00
tomberek
3e9cc78eb5
Merge pull request #11908 from Mic92/pull-request
document shallow clone options in git fetchers
2024-11-22 09:26:11 -05:00
Eelco Dolstra
feb46688a2
Merge pull request #11909 from DeterminateSystems/flakeref
Clean up flakeref parsing
2024-11-22 13:18:23 +01:00
Eelco Dolstra
ebb19cc1cd
Drop std::make_pair
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2024-11-22 09:14:01 +01:00
Jörg Thalheim
838d3c1ad0
Merge pull request #11933 from DeterminateSystems/no-narHash
fetchTree: Don't crash if narHash is missing
2024-11-22 08:07:50 +01:00
Eelco Dolstra
965ca18db8 Merge build-utils-meson/{diagnostics,threads} into build-utils-meson/common
This reduces the amount of boilerplate. More importantly, it provides
a place to add compiler flags (such as -O3) without having to add it
to every subproject (and the risk of forgetting to include it).
2024-11-21 20:34:54 +01:00
Eelco Dolstra
f4f4b698f6 fetchTree: Don't crash if narHash is missing
Fixes

  nix: ../src/libexpr/primops/fetchTree.cc:37: void nix::emitTreeAttrs(EvalState&, const StorePath&, const fetchers::Input&, Value&, bool, bool): Assertion `narHash' failed.

on a lock file with an input that doesn't have a narHash. This can
happen when using a lock file created by the lazy-trees branch.

Cherry-picked from lazy-trees.
2024-11-21 16:53:34 +01:00
Eelco Dolstra
45b0158d91
Merge pull request #11915 from NixOS/bump-fetcher-cache-version
Bump fetcher cache version
2024-11-21 16:34:20 +01:00
John Ericson
82f6fba0d4
Merge pull request #11668 from DeterminateSystems/schema-migrations
Support fine-grained database schema migrations
2024-11-20 16:32:36 -05:00
Eelco Dolstra
db0525692d Formatting 2024-11-20 21:07:22 +01:00