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

19680 commits

Author SHA1 Message Date
Félix Baylac Jacqué
1c636284a3 MonitorFdHup: replace pthread_cancel trick with a notification pipe
On https://github.com/NixOS/nix/issues/8946, we faced a surprising
behaviour wrt. exception when using pthread_cancel. In a nutshell when
a thread is inside a catch block and it's getting pthread_cancel by
another one, then the original exception is bubbled up and crashes the
process.

We now poll on the notification pipe from the thread and exit when the
main thread closes its end. This solution does not exhibit surprising
behaviour wrt. exceptions.

Co-authored-by: Mic92 <joerg@thalheim.io>

Fixes https://github.com/NixOS/nix/issues/8946

See also Lix https://gerrit.lix.systems/c/lix/+/1605 which is very
similar by coincidence. Pulled a comment from that.
2025-03-23 18:34:52 -04:00
John Ericson
cb95791198 MonitorFdHup: introduce a num_fds variable
Better than just putting `1` in multiple spots.
2025-03-23 18:23:07 -04:00
John Ericson
d028bb4c4a MonitorFdHup: Cleanup a bit with designated initializers 2025-03-23 18:23:07 -04:00
Jörg Thalheim
8e0bc2c3a8 MonitorFdHup: raise explicit SysError rather unreachable
Syscalls can fail for many reasons and we don't want to loose the errno
and error context.
2025-03-23 18:22:48 -04:00
Sergei Zimmerman
d371aadb2b
tests/functional: Add regression test for broken :sh in repl
Can't really test `:u` because it needs <nixpkgs>.
2025-03-23 22:13:40 +00:00
Sergei Zimmerman
44055dc09d
libcmd/repl: Fix missing runNix in repl
Without this :u, :sh and :i repl commands fail with:

> Cannot run 'nix-shell'/`nix-env` because no method of calling the Nix
> CLI was provided. This is a configuration problem pertaining to how
> this program was built.

Remove the default ctor argument as it evidently makes catching
refactoring bugs much harder. `NixRepl` implementation lives completely
in `repl.cc`, so we can be as explicit as necessary.
2025-03-23 22:13:14 +00:00
Sergei Zimmerman
8066e4b0c3
libcmd/repl: Make AbstractNixRepl::create respect its store argument
The only reference (according to clangd) to this function also uses `openStore`,
so this is a no-op.
2025-03-23 22:10:43 +00:00
John Ericson
041394b741 monitor-fd.hh: Format
It's a pretty small diff, so let's just start formatting before we make
other changes.
2025-03-23 18:00:36 -04:00
Robert Hensing
bfc05d2e3b
Merge pull request #12723 from xokdvium/fix-man-doc-outputs
packaging/everything.nix: Fix doc and man outputs
2025-03-23 11:53:13 +00:00
Sergei Zimmerman
0ddfbc5939
packaging/everything.nix: Fix doc and man outputs
We want the $doc, $man outputs to be symlinks pointing to nix-manual and
nix-manual.man. Creating the directories first makes the `ln` command
produce symlink $doc/${nix-manual} instead.

```
$file /nix/store/q4dwlnd36gpfajgfcp6hca2xwy068wjq-nix-2.27.1-man/rwh8ky3k040wyrywl8k2v5b3csdfbdg7-nix-manual-2.27.1-man

/nix/store/q4dwlnd36gpfajgfcp6hca2xwy068wjq-nix-2.27.1-man/rwh8ky3k040wyrywl8k2v5b3csdfbdg7-nix-manual-2.27.1-man:
  symbolic link to /nix/store/rwh8ky3k040wyrywl8k2v5b3csdfbdg7-nix-manual-2.27.1-man
```

This is the reason `nix-env --help` is once again broken on 2.26/2.27/master
after 4108529.
2025-03-22 12:16:47 +00:00
Eelco Dolstra
d975d32d67
Merge pull request #12719 from NixOS/fix-links
rl-2.27.md: Fix GitHub links
2025-03-21 20:48:06 +01:00
Eelco Dolstra
be5a455a1a rl-2.27.md: Fix GitHub links
https://discourse.nixos.org/t/nix-2-27-0-released/62003/2?u=edolstra
2025-03-21 20:23:46 +01:00
Eelco Dolstra
cb66d3eea9
Merge pull request #12718 from NixOS/bump-2.28.0
Bump version
2025-03-21 20:10:24 +01:00
Eelco Dolstra
a1f05dc669 Bump version 2025-03-21 19:32:21 +01:00
Robert Hensing
2172c17b5e
Merge pull request #12701 from mightyiam/nix-infrec-base-error
stack overflow is EvalBaseError
2025-03-21 14:10:22 +00:00
mergify[bot]
f0b7b37425
Merge pull request #12697 from NixOS/worker-abstraction
Make Goal code use abstractions over interations with Worker
2025-03-21 10:38:29 +00:00
Shahar "Dawn" Or
23c7a45a05 stack overflow is EvalBaseError 2025-03-20 17:43:20 +00:00
The Tumultuous Unicorn Of Darkness
83ec81789a
Use feature_level field from libcpuid (#12674)
Close #11375

Co-authored-by: John Ericson <git@JohnEricson.me>
2025-03-20 13:11:55 -04:00
Las
36e5aa6c7d Make Goal code use abstractions over interations with Worker
Instead of calling `worker.waitForAWhile(shared_from_this())` etc.,
the subclasses of Goal instead call protected functions defined in Goal
that abstract over these.

The code for awaiting has also been heavily simplified.
Instead of calling `addWaitee`, then suspending,
`co_await await(waitees)` is called once, which also handles the suspend.

The end-goal is to remove all manual `co_await Suspend{}`s.
2025-03-19 18:36:43 -04:00
Jörg Thalheim
c97f779dbb
Merge pull request #12692 from obsidiansystems/small-derivation-goal-cleanups
Small derivation goal cleanups
2025-03-19 23:30:23 +01:00
John Ericson
3d333e0aff
Merge pull request #12667 from NixOS/in-dir-cleanup
Cleanup `isInDir` and  `isDirOrInDir`
2025-03-19 18:01:59 -04:00
Jörg Thalheim
12ad06c104
Merge pull request #12687 from Mic92/handle-eagain
libutil/file-descriptor: handle EAGAIN in read/write operations
2025-03-19 22:46:05 +01:00
John Ericson
91e90aaee0 Clean up one path computation with / operator
Because of the previous commit, we need to use `std::filesystem::path`
anyways.
2025-03-19 17:14:55 -04:00
John Ericson
d3de22b2be isInDir and isDirOrInDir: Clean up with std::filesystem
The behavior *does* change, per the tests, but I think the new behavior
is less buggy.
2025-03-19 17:13:21 -04:00
John Ericson
3286728e40 Simplify isInDir usage with isDirOrInDir 2025-03-19 17:12:49 -04:00
Jörg Thalheim
2790f5f9ae libutil/file-descriptor: handle EAGAIN in read/write operations
We now see exception beeing thrown when remote building in master
because of writing to a non-blocking file descriptor from our json logger.

> #0  0x00007f2ea97aea9c in __pthread_kill_implementation () from /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6
> #1  0x00007f2ea975c576 in raise () from /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6
> #2  0x00007f2ea9744935 in abort () from /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6
> #3  0x00007f2ea99e8c2b in __gnu_cxx::__verbose_terminate_handler() [clone .cold] () from /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
> #4  0x00007f2ea99f820a in __cxxabiv1::__terminate(void (*)()) () from /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
> #5  0x00007f2ea99f8275 in std::terminate() () from /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
> #6  0x00007f2ea99f84c7 in __cxa_throw () from /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
> #7  0x00007f2eaa5035c2 in nix::writeFull (fd=2, s=..., allowInterrupts=true) at ../unix/file-descriptor.cc:43
> #8  0x00007f2eaa5633c4 in nix::JSONLogger::write (this=this@entry=0x249a7d40, json=...) at /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/char_traits.h:358
> #9  0x00007f2eaa5658d7 in nix::JSONLogger::logEI (this=<optimized out>, ei=...) at ../logging.cc:242
> #10 0x00007f2ea9c5d048 in nix::Logger::logEI (ei=..., lvl=nix::lvlError, this=0x249a7d40) at /nix/store/a7cq5bqh0ryvnkv4m19ffchnvi8l9qx6-nix-util-2.27.0-dev/include/nix/logging.hh:108
> #11 nix::handleExceptions (programName="nix", fun=...) at ../shared.cc:343
> #12 0x0000000000465b1f in main (argc=<optimized out>, argv=<optimized out>) at /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/allocator.h:163
> (gdb) frame 10
> #10 0x00007f2ea9c5d048 in nix::Logger::logEI (ei=..., lvl=nix::lvlError, this=0x249a7d40) at /nix/store/a7cq5bqh0ryvnkv4m19ffchnvi8l9qx6-nix-util-2.27.0-dev/include/nix/logging.hh:108
> 108             logEI(ei);

So far only drainFD sets the non-blocking flag on a "readable" file descriptor,
while this is a "writeable" file descriptor.
It's not clear to me yet, why we see logs after that point, but it's
also not that bad to handle EAGAIN in read/write functions after all.
2025-03-19 22:02:18 +01:00
tomberek
5df1975246
Merge pull request #12570 from P-E-Meunier/macos-fix
Fix macos sandbox issue
2025-03-19 16:19:59 -04:00
Eelco Dolstra
0fa3edc921
Merge pull request #12682 from Mic92/logging
libfetchers: fix double quote in path printed in logger
2025-03-19 20:37:11 +01:00
Pierre-Etienne Meunier
300465c7b8 Fix macos sandbox issue
Co-authored-by: John Ericson <git@JohnEricson.me>

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2025-03-19 17:09:18 +00:00
Jörg Thalheim
314e9fbeda libfetchers: fix double quote in path printed in logger 2025-03-19 16:04:16 +01:00
mergify[bot]
d10f9488fe
Merge pull request #12658 from obsidiansystems/local-derivation-goal-hide-and-split
Move `RestrictedStore` into its own file+header
2025-03-19 10:00:34 +00:00
Jörg Thalheim
59ef89d886
Merge pull request #12677 from oldshensheep/master
Improve the documentation of store path
2025-03-19 10:24:38 +01:00
Jörg Thalheim
5ba9949b82
Merge pull request #12578 from roberth/complete-hydra-build-jobs
packaging: Make hydraJobs.build.* complete
2025-03-19 10:11:19 +01:00
oldshensheep
355a923e81 Improve the documentation of store path
# Conflicts:
#	doc/manual/source/protocols/store-path.md
2025-03-19 13:45:10 +08:00
John Ericson
f497711aa8
Merge pull request #12624 from KAction/store-path-doc
Improve the documentation of the store path protocol
2025-03-18 12:36:01 -04:00
Robert Hensing
95b0971031
Merge pull request #12652 from roberth/cli-json-pretty
nix-cli: Add --json --pretty / --no-pretty
2025-03-18 12:29:43 +00:00
Robert Hensing
9ff8309f47 Remove commented code
Some four years old; time to go
2025-03-18 08:14:07 +00:00
John Ericson
1c022077ea Get rid of on usage pair of actLock
Now that we have coroutines, we can go back to loops and regular RAII,
which is must less error-proone!

I look forward to removing the other instances!
2025-03-17 11:07:25 -04:00
John Ericson
7f8d348f3d Move derivationType from DerivationGoal to LocalDerivationGoal
The super class doesn't actually care.
2025-03-17 11:07:25 -04:00
John Ericson
5283589542 RestrictedStore: Move some definitions outside of the type declaration
Even when the type is not currently declared in a header, I still consider this a
more future-proof style.
2025-03-17 11:01:18 -04:00
John Ericson
5026d5af95 Move RestrictedStore into its own file+header
Perhaps more significantly, it no longer knows about
`LocalDerivationGoal`, and without any effort it also compiles on
Windows just fine. (`local-derivation-goal.{cc,hh}` is currently skipped
on Windows.)
2025-03-17 10:54:48 -04:00
John Ericson
2cfd031511
Merge pull request #12662 from obsidiansystems/local-derivation-goal-hide
Local derivation goal hide
2025-03-16 17:13:22 -04:00
Robert Hensing
e4bda20918
Merge pull request #12586 from xokdvium/refactor/chmod-if-needed
{libutil,libstore}: Factor out chmodIfNeeded
2025-03-15 09:06:28 +00:00
John Ericson
7f2b7b8bd1 Do not expose LocalDerivationGoal implementation
We just need to expose construction functions.
2025-03-14 15:57:24 -04:00
John Ericson
d572533774 Move signPathInfo to Store
Motivation is the same for moving `signRealisation` in
db8439c328.
2025-03-14 15:57:24 -04:00
Robert Hensing
1bff2aeec0
Merge pull request #12645 from xokdvium/debugger-perf
Make debugger significantly faster
2025-03-14 13:21:12 +00:00
Robert Hensing
fe00dfbd56 nix-cli: Add --json --pretty / --no-pretty
Default: istty(stdout)

This refactors `nix develop` internals a bit to use the `json` type
more. The assertion now operates in the in-memory json instead of
re-parsing it. While this is technically a weaker guarantee, we
should be able to rely on the library to get this right. It's its
most essential purpose.
2025-03-14 12:39:13 +00:00
Sergei Zimmerman
adbd08399c {libexpr,libcmd}: Make debugger significantly faster
The underlying issue is that debugger code path was
calling PosTable::operator[] in each eval method.
This has become incredibly expensive since 5d9fdab3de.

While we are it it, I've reworked the code to
not use std::shared_ptr where it really isn't necessary.

As I've documented in previous commits, this is actually
more a workaround for recursive header dependencies now
and is only necessary in `error.hh` code.

Some ad-hoc benchmarking:

After this commit:

```
Benchmark 1: nix eval nixpkgs#hello --impure --ignore-try --no-eval-cache --debugger
  Time (mean ± σ):     784.2 ms ±   7.1 ms    [User: 561.4 ms, System: 147.7 ms]
  Range (min … max):   773.5 ms … 792.6 ms    10 runs
```

On master 3604c7c51:

```
Benchmark 1: nix eval nixpkgs#hello --impure --ignore-try --no-eval-cache --debugger
  Time (mean ± σ):     22.914 s ±  0.178 s    [User: 18.524 s, System: 4.151 s]
  Range (min … max):   22.738 s … 23.290 s    10 runs
```
2025-03-13 16:24:30 +00:00
Jörg Thalheim
e9af7a0749
Merge pull request #12647 from DeterminateSystems/lock-json-logger
JSONLogger: Acquire a lock to prevent log messages from clobbering each other
2025-03-13 16:43:09 +01:00
Eelco Dolstra
d0227f8d02 JSONLogger: Acquire a lock to prevent log messages from clobbering each other 2025-03-13 16:02:10 +01:00