1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00
Commit graph

12190 commits

Author SHA1 Message Date
Jörg Thalheim
5b900120a2
Merge pull request #13117 from NixOS/file-pure-eval
Complain when using --pure-eval with --file
2025-05-01 10:26:41 +02:00
Jörg Thalheim
408746cba6 replaceSymlink: fix quoting in error message 2025-05-01 08:19:18 +02:00
mergify[bot]
4548dd1abb
Merge pull request #13112 from NaN-git/fix-json-getInteger
bugfix in getInteger(const nlohmann::json &) and add bounds checks
2025-04-30 21:20:49 +00:00
Eelco Dolstra
d46f741cdf Complain when using --pure-eval with --file
This never worked and cannot work because in pure eval mode, the
evaluator doesn't have access to the file.
2025-04-30 22:29:27 +02:00
Jeremy Fleischman
5089f1292d
Refactor, use MixOutLinkByDefault 2025-04-29 18:40:02 -07:00
Jeremy Fleischman
7df7bde306
Refactor, extract some shared code into UnresolvedApp::build 2025-04-29 18:40:02 -07:00
Robert Hensing
e14346c7da
Refactor, dedup nix formatter attribute methods 2025-04-29 18:40:02 -07:00
Jeremy Fleischman
ba6b617e75
Add nix formatter build command
`nix formatter build` is sort of like `nix build`: it builds, links, and
prints a path to the formatter program:

    $ nix formatter build
    /nix/store/cb9w44vkhk2x4adfxwgdkkf5gjmm856j-treefmt/bin/treefmt

Note that unlike `nix build`, this prints the full path to the program,
not just the store path (in the example above that would be
`/nix/store/cb9w44vkhk2x4adfxwgdkkf5gjmm856j-treefmt`).

Motivation
----------

I maintain a vim plugin that automatically runs `nix fmt` on files on
save. Since `nix fmt` can be quite slow due to nix evaluation, I choose
to cache the `nix fmt `entrypoint. This was very awkward to do, see the
implementation for details:
7864607231/lua/null-ls/builtins/formatting/nix_flake_fmt.lua (L83-L110).

I recently discovered that my implementation was buggy (it didn't handle
flakes that expose a `formatter` package, such as nixpkgs), so I had to
rework the implementation:
https://github.com/nvimtools/none-ls.nvim/pull/272.

With the new `nix formatter build` command, I can delete all this akward
code, and it will be easier for other folks to build performant editor
integrations for `nix fmt`.
2025-04-29 18:40:02 -07:00
Jeremy Fleischman
5ea7b97147
refactor: create a new nix formatter run command alias for nix fmt
This refactor shouldn't change much except add a new `nix formatter run`
command. This creates space for the new `nix formatter build` command,
which I'll be introducing in the next commit.
2025-04-29 18:40:02 -07:00
Philipp Otterbein
788be3f964 bugfix in getInteger(const nlohmann::json &) and add bounds checks
improve error messages, too
2025-04-30 01:38:48 +02:00
Eelco Dolstra
9099b7dd87
Merge pull request #13109 from trofi/osc-8-xterm-style-fix
libutil: amend OSC 8 escape stripping for xterm-style separator
2025-04-29 22:39:04 +02:00
Jörg Thalheim
0e2dc8774c
Merge pull request #13105 from roberth/refactor-cli-out-link
Factor out `MixOutLinkByDefault`
2025-04-29 21:19:34 +02:00
Sergei Trofimovich
e322b714dc libutil: amend OSC 8 escape stripping for xterm-style separator
Before the change `nix` was stripping warning flags
reported by `gcc-14` too eagerly:

    $ nix build -f. texinfo4
    error: builder for '/nix/store/i9948l91s3df44ip5jlpp6imbrcs646x-texinfo-4.13a.drv' failed with exit code 2;
           last 25 log lines:
           >  1495 | info_tag (mbi_iterator_t iter, int handle, size_t *plen)
           >       |                                            ~~~~~~~~^~~~
           > window.c:1887:39: error: passing argument 4 of 'printed_representation' from incompatible pointer type []
           >  1887 |                                       &replen);
           >       |                                       ^~~~~~~
           >       |                                       |
           >       |                                       int *

After the change the compiler flag remains:

    $ ~/patched.nix build -f. texinfo4
    error: builder for '/nix/store/i9948l91s3df44ip5jlpp6imbrcs646x-texinfo-4.13a.drv' failed with exit code 2;
       last 25 log lines:
       >  1495 | info_tag (mbi_iterator_t iter, int handle, size_t *plen)
       >       |                                            ~~~~~~~~^~~~
       > window.c:1887:39: error: passing argument 4 of 'printed_representation' from incompatible pointer type [-Wincompatible-pointer-types]
       >  1887 |                                       &replen);
       >       |                                       ^~~~~~~
       >       |                                       |
       >       |                                       int *

Note the difference in flag rendering around the warning.

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda has a
good sumamry of why it happens. Befomre the change `nix` was handling
just one form or URL separator:

    $ printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'

Now it also handled another for (used by gcc-14`):

    printf '\e]8;;http://example.com\aThis is a link\e]8;;\a\n'

While at it fixed accumulation of trailing escape `\e\\` symbol.
2025-04-29 16:12:18 +01:00
John Ericson
46030181d4 Delete dead code
We had multiple copies of some static functions after splitting out
`DerivationBuilder` by mistake.
2025-04-28 11:19:36 -04:00
Robert Hensing
9d1f00e31d Factor out MixOutLinkByDefault 2025-04-28 16:54:00 +02:00
Eelco Dolstra
5565679b45
Merge pull request #13100 from NaN-git/fix-musl-deadlock
allocate SimpleLogger before forking
2025-04-28 09:01:06 +02:00
Philipp Otterbein
4e95f662db allocate SimpleLogger before forking 2025-04-28 00:46:44 +02:00
Robert Hensing
c81202b358
Merge pull request #13096 from NixOS/no-use-registries
getFlake(): Don't use registries for refetching
2025-04-27 00:42:51 +02:00
Robert Hensing
ee59af99f8
Merge pull request #13098 from roberth/fix-string-ctor
Fix flake-c out of bounds access
2025-04-26 18:46:11 +02:00
Robert Hensing
94916136dc Fix flake-c out of bounds access
The explicit include is needed for clangd to not get confused somehow,
which is also what threw me off initially and made me pick the wrong
constructor.
The (pointer, number, number) constructor first constructs a C string
and then takes a substring from that, but we didn't specify that the
buffer needs to be NUL-terminated, and then what would be the point of
the size argument anyway...

basic_string.h:

>	basic_string(const _Tp& __t, size_type __pos, size_type __n,
>		     const _Alloc& __a = _Alloc())
>	: basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { }

Valgrind on nixops4/rust/nix-flake tests:

==1344422== Conditional jump or move depends on uninitialised value(s)
==1344422==    at 0x48513E8: strlen (vg_replace_strmem.c:505)
==1344422==    by 0x488E941: UnknownInlinedFun (char_traits.h:391)
==1344422==    by 0x488E941: UnknownInlinedFun (string_view:141)
==1344422==    by 0x488E941: UnknownInlinedFun (basic_string.h:790)
==1344422==    by 0x488E941: nix_flake_reference_and_fragment_from_string (nix_api_flake.cc:81)
==1344422==    by 0x127332: nix_flake::FlakeReference::parse_with_fragment (lib.rs:123)
2025-04-25 17:07:32 +02:00
Eelco Dolstra
953ec00794 getFlake(): Don't use registries for refetching
`newLockedRef` is already resolved so there is no need to re-resolve
it.
2025-04-25 13:46:42 +02:00
Sergei Zimmerman
9fff868e39
libutil: Add missing format arguments to UsageError ctor
Once again found by an automated migration to `std::format`.
I've tested that boost::format works fine with `std::string_view`
arguments.
2025-04-25 13:35:16 +03:00
Jörg Thalheim
27047570b5
Merge pull request #13086 from xokdvium/bad-format-string
libutil: Fix invalid boost format string in infinite symlink recursion error
2025-04-25 11:20:04 +02:00
Jörg Thalheim
96a1740942
Merge pull request #13088 from NixOS/fix-ignore-local-registries
Fix ignore local registries
2025-04-25 11:19:25 +02:00
Sergei Zimmerman
1b5c8aac12
libutil: Use correct argument to Error format ctor
It seems that the intention was to format a number in base 8 (as
suggested by the %o format specifier), but `perms` is a `std::string`
and not a number. Looks like `rawMode` is the correct thing to use here.
2025-04-24 22:27:03 +00:00
Sergei Zimmerman
bfb357c40b
libutil: Fix invalid boost format string in infinite symlink recursion error
Found while working on an automated migration to `std::format`.
2025-04-24 21:00:24 +00:00
Eelco Dolstra
68de26d38a lockFlake(): Allow registry lookups for the top-level flake
Fixes #13050.
2025-04-24 18:59:10 +02:00
Cole Helbling
e1b68244ad
nix-cli: restore binary-dist artifact to Hydra static builds 2025-04-24 08:46:47 -07:00
Eelco Dolstra
dda265f09a Reapply "Actually ignore system/user registries during locking"
This reverts commit 3b5f0d9fb3.
2025-04-24 17:33:27 +02:00
Jörg Thalheim
3b5f0d9fb3 Revert "Actually ignore system/user registries during locking"
This reverts commit 77d4316353.
2025-04-24 11:28:11 +02:00
Robert Hensing
8a1c40b927
Merge pull request #13065 from roberth/escapeShellArg
Rename `shellEscape` -> `escapeShellArgAlways`
2025-04-23 23:35:15 +02:00
Robert Hensing
1e5b1d9973 Rename shellEscape -> escapeShellArgAlways
This name is close to the Nixpkgs lib function `escapeShellArg`,
making it easier to find.

A friendlier function with the same behavior as lib could be added
later.
2025-04-23 22:56:07 +02:00
John Ericson
9eb608cbef
Merge pull request #13070 from DeterminateSystems/fix-windows
Don't build MonitorFdHup test on Windows
2025-04-23 14:23:15 -04:00
John Ericson
714662e675
Merge pull request #13068 from DeterminateSystems/fix-warning
DerivationBuilder: Fix compiler warning
2025-04-23 14:10:55 -04:00
John Ericson
052d5cb3fe
Merge pull request #13067 from DeterminateSystems/move-libflake
Move libflake/flake/* to libflake
2025-04-23 14:03:35 -04:00
Eelco Dolstra
a9b6213221 Don't build MonitorFdHup on Windows
https://hydra.nixos.org/build/295398462
2025-04-23 19:51:13 +02:00
Eelco Dolstra
fd0835e7d7 Fix signedness error on FreeBSD
https://hydra.nixos.org/build/295398446
2025-04-23 17:41:35 +02:00
Eelco Dolstra
d07541be29 DerivationBuilder: Fix compiler warning
Fixes

  ../src/libstore/unix/build/derivation-builder.cc:1130:86: warning: the compiler can assume that the address of ‘nix::DerivationBuilderParams::drv’ will never be NULL [-Waddress]
   1130 |     if (useChroot && settings.preBuildHook != "" && dynamic_cast<const Derivation *>(&drv)) {
        |                                                                                        ^~~~

Assuming this check was left over from the time `drv` could be a
`BasicDerivation`.
2025-04-23 17:28:09 +02:00
Eelco Dolstra
bc67e47298 Move libflake/flake/* to libflake 2025-04-23 17:20:42 +02:00
John Ericson
155411397d
Merge pull request #13055 from obsidiansystems/inlined-resolvedFinished
Inline `DerivationGoal::resolvedFinished`
2025-04-20 19:11:38 -04:00
John Ericson
54b7ccc466
Merge pull request #13053 from obsidiansystems/no-more-local-derivation-goal
Get rid of `LocalDerivationGoal`
2025-04-20 18:50:05 -04:00
John Ericson
16f640a9b2 Inline DerivationGoal::resolvedFinished
`resolvedDrvGoal` can just become a local variable!
2025-04-20 18:32:19 -04:00
Robert Hensing
15fa95f925
Merge pull request #13052 from rhendric/rhendric/increase-429-delay
libstore: increase retry delay for 429
2025-04-21 00:31:15 +02:00
John Ericson
4e586149df Get rid of LocalDerivationGoal
I split it out before to try to separate the building logic, but now we
have the much better `DerivationBuilder` abstraction for that. With that
change, I think `LocalDerivationGoal` has outlived its usefulness.

We just inline it back into `DerivationGoal`, and do so with minimal
`#ifdef` for Windows.

Note that the order of statements in `~DerivationGoal` is different than
it was after the `~LocalDerivationGoal` split, but it is *restored* to
the way it original was before --- evidently I did the split slightly
wrong, but nobody noticed, probably because the order doesn't actually
matter.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2025-04-20 18:09:41 -04:00
Robert Hensing
047f2bc1af refactor: Extract RETRY_TIME constants in filetransfer 2025-04-20 23:29:22 +02:00
Robert Hensing
363ee6dfcb Fix non-virtual destructor warning 2025-04-20 23:05:21 +02:00
Ryan Hendrickson
85420b8537 libstore: increase retry delay for 429
A 429 (Too Many Requests) error should not be retried after a quarter of
a second; that's just silly. GitHub recommends a minute.
2025-04-20 14:49:03 -04:00
John Ericson
5eeeb44f79 Remove double indirection from DerivationBuilder params
Now that `DerivationBuilder` is created after the underlying data has
already been initialized, we can just refer this data normally, with a
direct reference.

Only `parsedDrv` takes a (borrowing) pointer, because independent of
initialization the derivation may or may not have structured attrs.
2025-04-18 12:26:05 -04:00
John Ericson
2b2ea218d9 Delay constructing a DerivationBuilder until we're about to build
This makes the simplification in the following commit possible.
2025-04-18 12:26:05 -04:00
John Ericson
27907e6cac Add documentation for DerivationBuilder::{parsedDrv, drvOptions} 2025-04-18 12:26:05 -04:00