1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00
Commit graph

12190 commits

Author SHA1 Message Date
Las
a87589a035 Simplify local drv goal a bit more
- `chrootParentDir` can be a local variable instead of a class variable.

- `getChildStatus` can be inlined. Again, we have the `assert(!hook);`
  in the local building case, which makes for a simpler thing inlined.
2025-03-12 18:09:38 -04:00
Las
4b521f14ac Remove privateNetwork variable from local drv goal
Can just inline its definition, it was immutable.
2025-03-12 18:09:38 -04:00
John Ericson
87824bca6b Avoid pointless mutation
The code that was in between is now gone. We can just set `st` correctly
the first time.
2025-03-12 18:08:58 -04:00
John Ericson
145aa2f118 Remove dead hook code in LocalDerivationGoal::tryLocalBuild
The `assert` above proves that `hook` is not set.
2025-03-12 18:08:10 -04:00
Las
75feeecd5d Start simplifying {Local,}DerivationGoal cleanup code
Thanks to the previous commit, we can inline all these small callbacks.
In the build-hook case, they were empty, and now they disappear
entirely.

While `LocalDerivationGoal` can be used in the hook case (we use it
based on whether we have a local store, not based on whether we are
using the build hook, a decision which comes later), the previous
commit's inline moved the code into a spot where we know we are cleaning
up after local building, *not* after running the build hook. This allows
for much more simplification.
2025-03-12 18:05:08 -04:00
Las
e87ba85705 Inline buildDone from DerivationGoal into use sites
The basic idea is that while we have duplicated this function, we now
have one call-site in the local build case, and one call site in the
build hook case. This unlocks big opportunities to specialize each copy,
since they really shouldn't be doing the same things. By the time we are
are done, there should not be much duplication left.

See #12628 for further info.
2025-03-12 18:00:07 -04:00
John Ericson
1de97bbe2e Factor out "last 10 log lines" error message code
This will help avoid duplication later. In particular, the next commit
will not need to duplicate as much.
2025-03-12 18:00:07 -04:00
Jörg Thalheim
e9f1761597 libfetchers/git: fix caching head when using shallow clones
the old code was using the wrong cache directory, which lead to a
warning on every nix flake update

Update src/libfetchers/git.cc
2025-03-12 22:32:05 +01:00
Eelco Dolstra
78eed85ba3 Remove use of $NIX_HELD_LOCKS
This variable was once used to communicate already acquired store path
locks between Nix and the build hook, but this hasn't been the case
since 9bcb4d2dd9. So let's get rid of
it.
2025-03-12 21:28:56 +01:00
Eelco Dolstra
9c5a8e9352
Merge pull request #12636 from Mic92/crash-handler
port crash-handler from lix to nix
2025-03-12 20:59:20 +01:00
Jörg Thalheim
c9a3101bff
Merge pull request #12603 from NaN-git/fix-curl-retry
libstore: curl retry: reset content-encoding and don't use string after move
2025-03-12 13:47:51 +01:00
Jade Lovelace
163f94412a port crash-handler from lix to nix
It was first introduced in 19e0ce2c03

In Nix we only register the crash handler in main instead of initNix,
because library user may want to use their own crash handler.

Sample output:

Mar 12 08:38:06 eve nix[2303762]: Nix crashed. This is a bug. Please report this at https://github.com/NixOS/nix/issues with the following information included:
Mar 12 08:38:06 eve nix[2303762]: Exception: nix::SysError: error: writing to file: Resource temporarily unavailable
Mar 12 08:38:06 eve nix[2303762]: Stack trace:
Mar 12 08:38:06 eve nix[2303762]:  0# 0x000000000076876A in nix
                                   1# 0x00007FDA40E9F20A in /nix/store/2lhklm5aizx30qbw49acnrrzkj9lbmij-gcc-14-20241116-lib/lib/libstdc++.so.6
                                   2# std::unexpected() in /nix/store/2lhklm5aizx30qbw49acnrrzkj9lbmij-gcc-14-20241116-lib/lib/libstdc++.so.6
                                   3# 0x00007FDA40E9F487 in /nix/store/2lhklm5aizx30qbw49acnrrzkj9lbmij-gcc-14-20241116-lib/lib/libstdc++.so.6
                                   4# nix::writeFull(int, std::basic_string_view<char, std::char_traits<char> >, bool) in /home/joerg/git/nix/inst/lib/libnixutil.so
                                   5# nix::writeLine(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) in /home/joerg/git/nix/inst/lib/libnixutil.so
                                   6# nix::JSONLogger::write(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void> const&) in /home/joerg/git/nix/inst/lib/libnixutil.so
                                   7# nix::JSONLogger::logEI(nix::ErrorInfo const&) in /home/joerg/git/nix/inst/lib/libnixutil.so
                                   8# nix::Logger::logEI(nix::Verbosity, nix::ErrorInfo) in nix
                                   9# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /home/joerg/git/nix/inst/lib/libnixmain.so
                                  10# 0x000000000087A563 in nix
                                  11# 0x00007FDA40BD41FE in /nix/store/6q2mknq81cyscjmkv72fpcsvan56qhmg-glibc-2.40-66/lib/libc.so.6
                                  12# __libc_start_main in /nix/store/6q2mknq81cyscjmkv72fpcsvan56qhmg-glibc-2.40-66/lib/libc.so.6
                                  13# 0x00000000006F4DF5 in nix

Co-authored-by: eldritch horrors <pennae@lix.systems>
2025-03-12 10:23:02 +01:00
Jörg Thalheim
8e8edb5bf8
Merge pull request #12615 from xokdvium/ubsan-checks
flake: Enable UBSAN for checks
2025-03-11 14:22:20 +01:00
Sergei Zimmerman
24fbb456ba libutil/windows: Finally use the correct constructor for std::wstring
C++ is very intuitive /s [1]. Fixes #12631.

[1]: https://godbolt.org/z/jMa9GP5sq
2025-03-11 10:57:38 +00:00
Sergei Zimmerman
874587516c flake: Enable UBSAN for checks
Doing this makes catching non-obvious bugs easier. GHA CI workload is
already a concern and there isn't much benefit in running the tests with
and without sanitizers at the same time, so UBSAN is enabled for default
checks.

This change doesn't affect production builds in any way, but is rather a
step in the direction of improving automated testing during development.

Relates to #10969.
2025-03-09 00:24:47 +03:00
Robert Hensing
a047dec120
Merge pull request #12620 from nix-windows/c-api/leaks
c-api: fix a few memory leaks
2025-03-08 22:06:59 +01:00
Brian McKenna
79b019ec4f c-api: fix a few memory leaks 2025-03-08 20:23:07 +11:00
Brian McKenna
c58202c6f9 DerivedPathTest: disable prop_legacy_round_rip until fixed 2025-03-08 19:51:25 +11:00
Brian McKenna
c82ef825d4 coerceToSingleDerivedPathUnchecked: pass through experimental features
This fixes a few of the property tests, now that the property tests
are actually generating arbitrary data - some of that data now
requiring experimental features to function properly.
2025-03-08 19:14:58 +11:00
Brian McKenna
9a04f1e732 rapidcheck: change to working arbitrary instances
Here we're switching to combinators instead of dereference operator.
It turns out the dereference operator was being executed upon test
setup, meaning that we were only using a only single value for each of
the executions of the property tests! Really not good.

And on Windows, we instead get:

    operator* is not allowed in this context

ff6af6fc68/src/gen/detail/GenerationHandler.cpp (L16C31-L16C71)

Now a few of the property tests fail, because we're generating cases
which haven't been exercised before.
2025-03-08 19:08:29 +11:00
Jörg Thalheim
3b1e23af09 libstore/remote-store: avoid old-style casting for maxConnections
Type-checking works better this way as (type) style casting is too
permissive.
2025-03-07 04:00:26 +01:00
Jörg Thalheim
3b0b2fd8d6 libflake: fix double quoting when updating flakes 2025-03-07 04:00:24 +01:00
Jörg Thalheim
559a2d1bc7 libfetchers/git: fix double quoting in error message 2025-03-07 04:00:22 +01:00
Sergei Zimmerman
82f337de10 {libutil,libstore}: Factor out chmodIfNeeded
Using std::filesystem::path directly because we need .c_str()
anyway to interact with chmod. Path/string views don't have to be
null-terminated.
2025-03-05 02:43:11 +03:00
Robert Hensing
1e1c587073 repl: Fix :print corruption
See preceding commits.
2025-03-04 19:48:22 +01:00
Robert Hensing
30694b5d8a refactor: RAII logger suspension 2025-03-04 19:48:22 +01:00
Robert Hensing
880489051a repl: Fix value printing corruption
The resume call would get some non-flushed(?) data.
Extending the pause to include the newline makes the complete flush
part of the pause.
2025-03-04 19:48:22 +01:00
Robert Hensing
49d8ee5359 progress-bar: Make pause/resume nestable 2025-03-04 19:48:22 +01:00
Philipp Otterbein
b129fc8237 libstore: curl retry: reset content-encoding and don't use string after move 2025-03-04 18:05:33 +01:00
Robert Hensing
efbd4c1ebb
Merge pull request #12442 from NixOS/store-derivation-options
Expand manual on derivation outputs
2025-03-03 23:11:51 +01:00
John Ericson
a58e0584f5 Rework derivation input resolution
I refactored the way that input resolution works in `DerivationGoal`. To
be honest, it is probably unclear to the reader whether this new way is
better or worse. I suppose *intrinsic* motivation, I can say that

- the more structured use of `inputGoal` (a local variable) is better
  than the shotgrun approach with `inputDrvOutputs`

- A virtual `waiteeDone` was a hack, and now it's gone.

However, the *real* motivation of this is not the above things, but that
it is needed for my mammoth refactor fixing #11897 and #11928.

It is nice that this step could come first, rather than making that
refactor even bigger.
2025-03-03 10:31:56 -05:00
John Ericson
8fdb50761d SingleDerivedPath should be const in recursive data structures 2025-03-03 10:31:23 -05:00
John Ericson
f4f28cdd0e Revert "Revert "Revert "Adapt scheduler to work with dynamic derivations"""
The bug reappeared after all, and the fix introduced a different bug. I
just reverted on 2.27 first, in #12576, but upon further introspection
and discussion with @roberth, with preparing for and travelling to
Planet Nix I will not be able to fix it on `master` soon enough for a
revert to not be warranted here in the meantime also.

This reverts commit c98525235f.
2025-03-02 15:34:21 -05:00
Sergei Zimmerman
c99edc840c libutil/file-system.hh: Fix typos 2025-03-01 18:44:48 +00:00
Yannik Sander
954e9101ba Add host attribute of github/gitlab flakerefs to URL serialization
`GitArchiveInputScheme::toUrl` currently drops the `host` attribute,
creating invalid urls when locking `github:` or `gitlab:` urls pointing to alterative instances and serializing the input back to a url.

```
❯ cat flake.nix
{
  inputs.gnome-2048 = {
    url = "gitlab:GNOME/gnome-2048?host=gitlab.gnome.org";
    flake = false;
  };

  outputs = inputs: {};
}
f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35
❯ nix flake metadata
warning: creating lock file '/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35/flake.lock':
• Added input 'gnome-2048':
    'gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D' (2025-02-21)
Resolved URL:  path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35
Locked URL:    path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35?lastModified=1740744684&narHash=sha256-nxUL/JiTYbZX2c1XiN/TC6aA1hf%2B1YXsUvhL7ASY2uE%3D
Path:          /nix/store/f4xczpwhdxs8gal1rika1c5bvhyd472l-source
Last modified: 2025-02-28 13:11:24
Inputs:
└───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46)
```

Note the gnome-2048 input url missing the original host query.

The Url after this commit:

```
[...]
Inputs:
└───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?host=gitlab.gnome.org&narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46)
```
2025-02-28 13:14:16 +01:00
Eelco Dolstra
1293388039
Merge pull request #12544 from xokdvium/debugger-use-after-free
libexpr: Fix use-after-free of StaticEnv::up
2025-02-27 16:55:49 +01:00
John Ericson
2aa6e0f084 Expand manual on derivation outputs
Note, this includes some text adapted from from Eelco's dissertation
2025-02-27 02:13:36 -05:00
Eelco Dolstra
ec8f78b0be Fix mingw build
https://hydra.nixos.org/build/291153007
2025-02-26 19:54:47 +01:00
Eelco Dolstra
81834e7f00
Merge pull request #12566 from NaN-git/fix-curl-callback
libstore: fix curl callback function signature
2025-02-25 20:15:06 +01:00
Eelco Dolstra
671d1b0123
Merge pull request #12501 from DeterminateSystems/stop-progress-bar
Remove {start,stop}ProgressBar()
2025-02-25 20:07:29 +01:00
Philipp Otterbein
b074345d35 libstore: fix curl callback function signature 2025-02-25 19:42:59 +01:00
Robert Hensing
1222438ae7 Merge remote-tracking branch 'upstream/master' into tomberek.access-token-prefixing 2025-02-25 15:40:34 +01:00
Robert Hensing
c07172220c refact: Rename url -> hostAndPath
https://github.com/NixOS/nix/pull/12465/files#r1955286197

> Perhaps that is a misnomer.
2025-02-25 15:21:09 +01:00
Eelco Dolstra
14c9755462 nix flake archive: Recurse into relative path inputs
We can't ignore them entirely, since we do want to archive their
transitive inputs.

Fixes #12438.
2025-02-24 22:10:02 +01:00
Eelco Dolstra
b4dfeafed5 nix flake archive: Skip relative path inputs
Fixes #12438.
2025-02-24 15:30:30 +01:00
Eelco Dolstra
f3ea14c8dc
Merge pull request #12542 from tomberek/tomberek.ssl-default
doc: ssl-cert-file leaks into OSX builds
2025-02-24 14:51:34 +01:00
Eelco Dolstra
d904921eec
Merge pull request #12510 from tie/fix-progress-parallel
libstore: fix expected bytes in progress bar
2025-02-21 20:11:18 +01:00
Sergei Zimmerman
af2ddfdb3b libexpr: Fix use-after-free of StaticEnv::up
It's not very clear what the ownership model is here, but one thing
is certain: `.up` can't be destroyed before the StaticEnv that refers
to it is.

Changing a non-owning pointer to taking shared ownership of the parent
`StaticEnv` prevents the `.up` from being freed.

I'm not a huge fan of the inverted ownership, where child `StaticEnv`
takes a refcount of the parent, but this seems like the least intrusive
way to fix the use-after-free.

This shouldn't cause any shared_ptr cycles to appear (hopefully).
2025-02-21 14:36:39 +00:00
Fabian Möller
5cf9e18167
Fix perl store bindings
When #9863 converted the `Nix::Store` free functions into member functions, the
implicit `this` argument was not accounted for when iterating over the variable
number of arguments in some functions.
2025-02-21 11:49:00 +01:00
Thomas Bereknyei
bbf6ff29e6 doc: ssl-cert-file leaks into OSX builds 2025-02-20 17:57:10 -05:00