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

20646 commits

Author SHA1 Message Date
John Ericson
4bc9ae67c7 Give DerivationBuilder a LocalStore not Store
This is just more honest, since we downcasted it to `LocalStore` in many
places. We had the downcast before because it wasn't needed in the hook
case, just the local building case, but now that `DerivationBuilder` is
separated and just does the building case, we have formalized the
boundary where the single downcast should occur.
2025-08-15 15:50:36 -04:00
John Ericson
14e355d87d Remove InitialOutput::wanted
No derivation goal type has a notion of variable wanted outputs any
more. They either want them all, or they just care about a single
output, in which case we would just store this information for the one
output in question.
2025-08-15 15:50:35 -04:00
John Ericson
316fef35dc
Merge pull request #13764 from obsidiansystems/simplify-store-dir
Simplify "Store dir" superclass
2025-08-15 15:24:47 -04:00
Sergei Zimmerman
1ed3ae8a9d
Merge pull request #13763 from obsidiansystems/more-flexible-get
More flexible typing for `get` in `util.hh`
2025-08-15 22:09:57 +03:00
John Ericson
0ef818dd92 More flexible typing for get in util.hh
This is good for e.g. `std::string_view` and `StringMap`.

Needed by #11139

Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
2025-08-15 14:23:37 -04:00
John Ericson
64c2ee3f45 Simplify "Store dir" superclass
We can cut out some gratuitous inhertence as follows:

- `MixStoreDirMethods` -> `StoreDirConfig`

- `StoreDirConfig` deleted because no longer needed. It is just folded
  into `StoreConfig`.

- `StoreDirConfigBase` -> `StoreConfigBase` same trick still needed, but
  now is for `StoreConfig` not `StoreDirConfig`

Here's how we got here:

1. I once factored out `StoreDirConfig` in #6236.

2. I factored out `MixStoreDirMethods` in #13154.

But, I didn't realize at point (2) that we didn't need `StoreDirConfig`
anymore, all uses of `StoreDirConfig` could instead be uses of
`MixStoreDirMethods`. Now I am doing that, and renaming
`MixStoreDirMethods` to just `StoreDirConfig` to reduce churn.
2025-08-15 14:12:37 -04:00
Sergei Zimmerman
22378ea093
Merge pull request #13762 from xokdvium/delete-footguns
libutil: Delete footgun overloads of get and getOr
2025-08-15 17:58:32 +03:00
Sergei Zimmerman
408c09a120
libutil: Delete footgun overloads of get and getOr
To avoid mistakes like the one in cea85e79ee.
These overloads are just asking for trouble.
2025-08-15 17:29:17 +03:00
Sergei Zimmerman
c736db5320
Merge pull request #13761 from xokdvium/fix-dangling-pointers
libstore: Fix dangling pointers in DerivationGoal constructors
2025-08-15 17:03:49 +03:00
Sergei Zimmerman
cea85e79ee
libstore: Fix dangling pointers in DerivationGoal constructors
This leads to a use-after free, because staticOutputHashes returns a temporary
object that dies before we can do a `return *mOutputHash`.

This is most likely the cause for random failures in Hydra [1].

[1]: https://hydra.nixos.org/build/305091330/nixlog/2
2025-08-15 16:39:28 +03:00
Jörg Thalheim
4e776a5be8
Merge pull request #13753 from obsidiansystems/simplify-derivation-goal
Simplify `DerivationGoal` in many ways
2025-08-15 08:25:47 +02:00
Sergei Zimmerman
f64000e3f4
Merge pull request #13756 from xokdvium/fix-copy-path-message
libstore: Fix makeCopyPathMessage
2025-08-15 02:10:41 +03:00
Sergei Zimmerman
e74ef417db
libstore: Fix makeCopyPathMessage
Old code completely ignored query parameters and it seems ok to keep
that behavior. There's a lot of code out there that parses nix code
like nix-output-monitor and it can't parse messages like:

> copying path '/nix/store/wha2hi4yhkjmccqhivxavbfspsg1wrsj-source' from 'https://cache.nixos.org' to 'local://'...

Let's not break these tools without a good reason. This goes in line
with what other code does by ignoring parameters in logs.

The issue is just in detecting the shorthand notations for the store
reference - not in printing the url in logs.

By default the daemon opens a local store with ?path-info-cache-size=0,
so that leads to the erronenous 'local://'.
2025-08-15 00:55:03 +03:00
John Ericson
4b4895e750
Merge pull request #13755 from xokdvium/concise-uri-logs
treewide: Remove getUri and replace with getHumanReadableURI where appropriate
2025-08-14 15:39:09 -04:00
Sergei Zimmerman
1b7ffa53af
treewide: Remove getUri and replace with getHumanReadableURI where appropriate
The problem with old code was that it used getUri for both the `diskCache`
as well as logging. This is really bad because it mixes the textual human
readable representation with the caching.

Also using getUri for the cache key is really problematic for the S3 store,
since it doesn't include the `endpoint` in the cache key, so it's totally broken.

This starts separating the logging / cache concerns by introducing a
`getHumanReadableURI` that should only be used for logging. The caching
logic now instead uses `getReference().render(/*withParams=*/false)` exclusively.
This would need to be fixed in follow-ups, because that's really fragile and
broken for some store types (but it was already broken before).
2025-08-14 16:47:05 +03:00
Jörg Thalheim
58eabe7479
Merge pull request #13754 from xokdvium/cleanup-docker-check-secrets
ci: Cleanup docker check secrets
2025-08-14 15:27:46 +02:00
Sergei Zimmerman
e6f3a193d8
libstore: Fix makeCopyPathMessage after config getUri refactor 2025-08-14 15:52:24 +03:00
Sergei Zimmerman
26dbda6302
ci/docker_push_image: Remove dead step
This step is now part of the check_secrets job and
the output is completely unused.
2025-08-14 14:54:45 +03:00
Sergei Zimmerman
48d15ed1fb
ci/check_secrets: Remove deprecated set-output 2025-08-14 14:54:20 +03:00
John Ericson
4a2de1dbab DerivationGoal Make some fields immutable
We can set both during construction, yay!
2025-08-14 00:39:00 -04:00
John Ericson
f155dffe59 DerivationGoal::done Clean up parameter types
We don't need to ask all these callers to build these single-entry maps
for us.
2025-08-14 00:35:52 -04:00
John Ericson
c940283750 DerivationBuilder
Move output result filtering logic and assert just into the branch where
it is not obviously a no op / meeting the assertion.

Add a comment too, while we are at it.
2025-08-14 00:35:34 -04:00
John Ericson
14441f9382 DerivationGoal inline gaveUpOnSubstitution lambda
We can shuffle around control flow so it's only called once. You'll
definitely want to review this diff ignoring whitespace.
2025-08-14 00:35:24 -04:00
John Ericson
88275e5723 DerivationGoal slight cleanup of some impure drv logic 2025-08-14 00:16:26 -04:00
John Ericson
7707d0acad Get rid of filterDrvOutputs
We don't need it any more, because we only used it in the
single-wanted-output `DerivationGoal`.
2025-08-14 00:09:08 -04:00
John Ericson
766a52ce87 DerivationOutput: Remove outputKnown state
Now that `DerivationGoal::checkPathValidity` is legible, we can see that
it only sets `outputKnown`, and doesn't read it. Likewise, with
co-routines, we don't have tiny scopes that make local variables
difficult. Between these two things, we can simply have
`checkPathValidity` return what it finds, rather than mutate some state,
and update everyting to use local variables.

The same transformation could probably be done to the other derivation
goal types (which currently, unfortunately, contain their own
`checkPathValidity`s, though they are diverging, and we hope and believe
that they continue to diverge).
2025-08-13 23:59:06 -04:00
John Ericson
2324fe3515 DerivationBuilder::checkPathValidity: Big simplify
`Store::queryPartialDerivationOutputMap` is nothing but checking
statically-known output paths, and then `Store::queryRealisation`, and
we were doing both of those things already. Inline that and simplify,
again taking advantage of the fact that we only care about one output.
2025-08-13 23:23:11 -04:00
John Ericson
b6ca60cb82 DerivationBuilder::checkPathValidity: Simplify allValid calc
Now that the loops is gone, we can just inline this mutation to a single
simple expression.
2025-08-13 23:01:58 -04:00
John Ericson
2600391147 Simplify DerivationGoal loop -> if
More taking advantage of single wanted output. Also `auto *` not `auto`
for easy reading.
2025-08-13 22:44:10 -04:00
John Ericson
1a6f92837a Don't use InitialOutput in DerivationGoal
We don't need the `wanted` field. Just inline the other two fields.
2025-08-13 22:43:33 -04:00
John Ericson
14173d761c Simplify DerivationGoal by just storing a singular initialOutput
We know we want exactly want output in `DerivationGoal` now (since
recent refactors), so we can start simplifying things to take advantage
of this.
2025-08-13 22:07:59 -04:00
John Ericson
4b6edfcfc7 DerivationBuildingGoal: Check outputs beforehand
See the comment in the code for details. Some of the code is duplicated
for now, but we'll be cleaning that up soon.
2025-08-13 22:06:14 -04:00
Sergei Zimmerman
cf7084a67c
Merge pull request #13739 from obsidiansystems/getUri-not-string
Rewrite `StoreConfig::getUri` in terms of new `StoreConfig::getReference`
2025-08-14 02:46:48 +03:00
John Ericson
3e7879e6df Rewrite StoreConfig::getUri in terms of new StoreConfig::getReference
Rather than having store implementations return a free-form URI string,
have them return a `StoreReference`. This reflects that fact that this
method is supposed to invert `resolveStoreConfig`, which goes from a
`StoreReference` to some `StoreConfig` concrete derived class (based on
the registry).

`StoreConfig::getUri` is kept only as a convenience for the common case
that we want to immediately render the `StoreReference`.

A few tests were changed to use `local://` not `local`, since
`StoreReference` does not encode the `local` and `daemon` shorthands
(and instead desugars them to `local://` and `unix://` right away). I
think that is fine. `local` and `daemon` still work as input.
2025-08-13 19:06:59 -04:00
Sergei Zimmerman
dfcbe70564
Merge pull request #13750 from obsidiansystems/simplify-derivation-goal-0
Simplify `DerivationGoal` in two ways
2025-08-14 02:02:03 +03:00
John Ericson
ed55937002 Make many members of DerivationGoal private 2025-08-13 17:50:39 -04:00
John Ericson
c37df9c87c Inline DerivationGoal::query{,Partial}DerivationOutputMap
The functions are used just once.
2025-08-13 17:50:35 -04:00
Jörg Thalheim
be3a508b74
Merge pull request #13748 from Mic92/toml-revert
Revert "Merge pull request #13741 from xokdvium/toml-timestamps"
2025-08-13 22:51:55 +02:00
Jörg Thalheim
75740fbd75 Revert "Merge pull request #13741 from xokdvium/toml-timestamps"
This reverts commit 53ac49f72c, reversing
changes made to 8e5ca787f4.

This broke nixpkgs eval test that was depending overflowing integers...
2025-08-13 22:46:09 +02:00
Jörg Thalheim
5d3197bb6c
Merge pull request #13497 from Mic92/repl-use-after-free-fix
Fix use-after-free warning in repl.cc
2025-08-13 21:55:01 +02:00
Jörg Thalheim
53ac49f72c
Merge pull request #13741 from xokdvium/toml-timestamps
libexpr: Canonicalize TOML timestamps for toml11 > 4.0
2025-08-13 21:22:15 +02:00
Sergei Zimmerman
8e5ca787f4
Merge pull request #13743 from kip93/fix/lfs-ssh
Fix Git LFS SSH issues
2025-08-13 21:50:41 +03:00
Leandro Reina
ccf658ed5c
Fix Git LFS SSH issues
* Adds support for NIX_SSHOPTS
* Properly uses the parsed port from URL (fixes #13337)
* Don't guess the HTTP endpoint, use the response of git-lfs-authenticate
* Add an SSH Git LFS test
* Removed some unused test code
2025-08-13 21:04:29 +03:00
Jörg Thalheim
68839b9545
Merge pull request #13742 from xokdvium/fix-i686
libutil: Fix i686-linux build on clangStdenv
2025-08-13 09:03:25 +02:00
Sergei Zimmerman
b5289fa130
libutil: Fix i686-linux build on clangStdenv
Clang refused to do a narrowing conversion in an initializer list:

```
 local-keys.cc:56:90: note: insert an explicit cast to silence this issue
return name + ":" + base64::encode(std::as_bytes(std::span<const unsigned char>{sig, sigLen}));
                                                                                    ^~~~~~
                                                                                    static_cast<size_type>( )
```
2025-08-12 22:48:15 +03:00
Sergei Zimmerman
320b2c74ef
packaging: Build with toml11 4.4.0 2025-08-12 22:22:12 +03:00
Sergei Zimmerman
dc769d72cb
libexpr: Canonicalize TOML timestamps for toml11 > 4.0
This addresses several changes from toml11 4.0 bump in
nixpkgs [1].

1. Added more regression tests for timestamp formats.
   Special attention needs to be paid to the precision
   of the subsecond range for local-time. Prior versions select the closest
   (upwards) multiple of 3 with a hard cap of 9 digits.

2. Normalize local datetime and offset datetime to always
   use the uppercase separator `T`. This is actually the issue
   surfaced in [2]. This canonicalization is basically a requirement
   by (a certain reading) of rfc3339 section 5.6 [3].

3. If using toml11 >= 4.0 also keep the old behavior wrt
   to the number of digits used for subsecond part of the local-time.
   Newer versions cap it at 6 digits unconditionally.

[1]: https://www.github.com/NixOS/nixpkgs/pull/331649
[2]: https://www.github.com/NixOS/nix/issues/11441
[3]: https://datatracker.ietf.org/doc/html/rfc3339
2025-08-12 21:49:30 +03:00
Jörg Thalheim
ffe5c1ecb4
Merge pull request #13737 from NixOS/dependabot/github_actions/actions/download-artifact-5
build(deps): bump actions/download-artifact from 4 to 5
2025-08-12 15:43:43 +02:00
Sergei Zimmerman
d8fc55a46e
libexpr: Use table.size() instead of unnecessary loop 2025-08-12 14:58:53 +03:00
Sergei Zimmerman
a80a5c4dba
libexpr: Use recursive lambda instead of std::function
There's no reason to use a std::function for recursive lambdas
since there are polymorphic lambdas.
2025-08-12 14:55:29 +03:00