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

20981 commits

Author SHA1 Message Date
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
Pierre-Etienne Meunier
aecd2b5d92 Fix macos sandbox issue
Co-authored-by: John Ericson <git@JohnEricson.me>

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
(cherry picked from commit 300465c7b8)
2025-03-19 20:21:53 +00: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
Eelco Dolstra
8674792eba Make the JSON logger more robust
We now ignore connection / write errors.
2025-03-14 17:33:48 +01:00
Eelco Dolstra
fd0d824fa5 Don't use DerivedPath::toJSON()
It doesn't work on unrealized paths.
2025-03-14 17:06:23 +01:00
mergify[bot]
bdaa8c55d2
Merge pull request #12655 from NixOS/mergify/bp/2.27-maintenance/pr-12645
Make debugger significantly faster (backport #12645)
2025-03-14 13:54:47 +00:00
Sergei Zimmerman
11919bc471 {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
```

(cherry picked from commit adbd08399c)
2025-03-14 13:22:53 +00:00
Sergei Zimmerman
593e0eebeb libutil: Fix Pos::getSourcePath
Previous implementation didn't actually check if
std::get_if returned a nullptr:

std::optional<SourcePath> getSourcePath() const {
    return *std::get_if<SourcePath>(&origin);
}

(cherry picked from commit 50123f2a56)
2025-03-14 13:22:52 +00:00
Sergei Zimmerman
8c2a792d2b libutil: Document hacks and problems around Pos class
This should provide context for follow-up commits in
the patch series.

(cherry picked from commit bf12aedf2e)
2025-03-14 13:22:52 +00:00
Sergei Zimmerman
b540c2419f {libutil,libexpr}: Move pos-idx,pos-table code to libutil
All of this code doesn't actually depend on anything from
libexpr. Because Pos is so tigtly coupled with Error, it
makes sense to have in the same library.

(cherry picked from commit a53b184e63)
2025-03-14 13:22:52 +00: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
Eelco Dolstra
762114b7c4 Log BuildResult 2025-03-13 19:42:52 +01:00
Eelco Dolstra
c515bc66f1 Provide a structured JSON serialisation of hashes 2025-03-13 18:52:29 +01:00
Eelco Dolstra
2a2af3f72f Logger::result(): Support logging arbitrary JSON objects 2025-03-13 18:39:46 +01: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
Eelco Dolstra
220000dc1a makeJSONLogger(): Support logging to a Unix domain socket 2025-03-13 15:48:52 +01:00
Eelco Dolstra
d9730fc93b Fix fd check 2025-03-13 15:42:17 +01:00
Sergei Zimmerman
50123f2a56 libutil: Fix Pos::getSourcePath
Previous implementation didn't actually check if
std::get_if returned a nullptr:

std::optional<SourcePath> getSourcePath() const {
    return *std::get_if<SourcePath>(&origin);
}
2025-03-13 13:29:08 +00:00
Sergei Zimmerman
bf12aedf2e libutil: Document hacks and problems around Pos class
This should provide context for follow-up commits in
the patch series.
2025-03-13 13:29:08 +00:00
Sergei Zimmerman
a53b184e63 {libutil,libexpr}: Move pos-idx,pos-table code to libutil
All of this code doesn't actually depend on anything from
libexpr. Because Pos is so tigtly coupled with Error, it
makes sense to have in the same library.
2025-03-13 13:29:08 +00:00
Eelco Dolstra
1efccf34b1 JSONLogger: Acquire a lock to prevent log messages from clobbering each other 2025-03-13 13:58:35 +01:00
Eelco Dolstra
29a9e638c1 Remove "@nix" prefix from json-log-path output 2025-03-13 13:37:38 +01:00
Eelco Dolstra
2972e73946 Turn NIX_LOG_FILE into a setting 2025-03-13 13:15:14 +01:00
Eelco Dolstra
1f702cdb01 Allow separate JSON logging
If the NIX_LOG_FILE environment variable is set, Nix will write JSON
log messages to that file in addition to the regular logger (e.g. the
progress bar).
2025-03-13 12:52:15 +01:00
Eelco Dolstra
8ef94c1114 Add a structured log message for FOD hash mismatches 2025-03-13 12:52:15 +01:00
Eelco Dolstra
1212b1fbfe JSONLogger: Log to a file descriptor instead of another Logger
Logging to another Logger was kind of nonsensical - it was really just
an easy way to get it to write its output to stderr, but that only
works if the underlying logger writes to stderr.

This change is needed to make it easy to log JSON output somewhere
else (like a file or socket).
2025-03-13 12:52:15 +01:00
John Ericson
b8eaf1b322
Merge pull request #12643 from obsidiansystems/delete-dead-goal-var
Remove unused parameter to the goal constructor
2025-03-12 16:45:26 -07:00
John Ericson
ecdcba27c5 Remove unused parameter to the goal constructor
It has been unused since 37fca662b0.
2025-03-12 19:09:54 -04:00