Commit graph

18072 commits

Author SHA1 Message Date
detroyejr
d54dfbf879 addFlag: test that alias flags are allowed 2024-07-19 15:56:54 -04:00
detroyejr
74dccef004 addFlag: use aliases 2024-07-19 15:05:00 -04:00
Eelco Dolstra
c4213f0e6c
Merge pull request #11125 from DeterminateSystems/basic-connection
Factor out commonality between WorkerProto::Basic{Client,Server}Connection
2024-07-19 14:26:04 +02:00
Eelco Dolstra
58a79b6943 performOp(): Take a WorkerProto::BasicServerConnection 2024-07-19 13:35:46 +02:00
John Ericson
d629b27e3c
Merge pull request #11138 from emilazy/push-znxusvxozllv
libmain: add missing header include
2024-07-18 21:46:47 -04:00
Silvan Mosberger
0c91bb97e5 parser: Remove empty multiline string parts earlier
Makes parsing more consistent and is a super minor optimisation

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-07-19 00:43:44 +02:00
Silvan Mosberger
a6dccae223 Fix non-deterministic parser printing
In _very_ rare cases (I had about 7 cases out of 32200 files!),
the order of how inherit-from bindings are printed when using
`nix-instantiate --parse` gets messed up.

The cause of this seems to be because the std::map the bindings are
placed in is keyed on a _pointer_, which then uses an
[implementation-defined strict total order](https://en.cppreference.com/w/cpp/language/operator_comparison#Pointer_total_order).

The fix here is to key the bindings on their displacement instead,
which maintains the same order as they appear in the file.

Unfortunately I wasn't able to make a reproducible test for this in the
source, there's something about the local environment that makes it
unreproducible for me.

However I was able to make a reproducible test in a Nix build on a Nix
version from a very recent master:

    nix build github:infinisil/non-det-nix-parsing-repro

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-07-19 00:42:00 +02:00
Emily
31e151386b libmain: add missing header include 2024-07-18 23:26:22 +01:00
Eelco Dolstra
fa7aa0389a FdSource: Fix operator =
This wasn't moving the underlying buffer, so if the buffer was
non-empty, it could lose data.
2024-07-18 16:10:48 +02:00
Eelco Dolstra
d231d802f5 Typo 2024-07-18 16:10:48 +02:00
Eelco Dolstra
c1d5cf6f34 Factor out commonality between WorkerProto::Basic{Client,Server}Connection
This also renames clientVersion and daemonVersion to the more correct
protoVersion (since it's the version agreed to by both sides).
2024-07-18 16:10:48 +02:00
Robert Hensing
8ce4287409
Merge pull request #11086 from kognise/eval-cache-fixes
Eval cache: fix cache regressions
2024-07-18 14:57:07 +02:00
John Ericson
606ace41d2
Merge pull request #11112 from obsidiansystems/move-schemes-set
Move `uriSchemes` to `*StoreConfig`
2024-07-18 00:39:07 -04:00
John Ericson
2aa9cf34dd Move uriSchemes to *StoreConfig
It is a property of the configuration of a store --- how a store URL is
parsed into a store config, not a store itself.

Progress towards #10766
2024-07-17 23:48:19 -04:00
Farid Zakaria
57399bfc0e
Refactor unix domain socket store config (#11109)
Following what is outlined in #10766 refactor the uds-remote-store such
that the member variables (state) don't live in the store itself but in
the config object.

Additionally, the config object includes a new necessary constructor
that takes a scheme & authority.

Tests are commented out because of linking errors with the current config system.
When there is a new config system we can reenable them.

Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2024-07-17 23:32:27 -04:00
Eelco Dolstra
17051ca80a
Merge pull request #11061 from rhendric/rhendric/reference-manual
docs: fill out language/types.md#type-path
2024-07-17 21:59:05 +02:00
Eelco Dolstra
1e1a8e8ad1
Merge pull request #11058 from hercules-ci/more-nix-shell
Make `#!nix-shell` arguments and options relative to script
2024-07-17 21:52:34 +02:00
John Ericson
a915862450
Merge pull request #11126 from DeterminateSystems/dont-send-version-twice
BasicClientConnection::handshake(): Don't send our version twice
2024-07-17 15:50:17 -04:00
Eelco Dolstra
6867cb1096
Merge pull request #11103 from fzakaria/issue-10795
lint: fix shellcheck for misc/systemv/nix-daemon
2024-07-17 21:46:17 +02:00
Eelco Dolstra
b23da1ceca
Merge pull request #11100 from NixOS/pretty-print-idempotent
Pretty print idempotently
2024-07-17 21:35:27 +02:00
Eelco Dolstra
05751de32b
Merge pull request #10931 from hercules-ci/test-run-and-shell-envs
Test the `run` and `shell` envs for stray variables
2024-07-17 21:21:14 +02:00
RTUnreal
f0a1c130a1
doc: add example usage for Gitea in tarball fetcher (#11116)
Co-authored-by: Valentin Gagarin <valentin@gagarin.work>
2024-07-17 19:08:33 +00:00
Robert Hensing
83d585b423 C API: Make nix_err an enum
This generally gives a better experience with bindings generators,
possibly other tooling.

A possible risk is that some generators may not represent unknown
codes correctly.
Rust bindgen by default generates suitable code:
  * a type alias nix_err = c_int
  * individual constants for the known enum values
It does _not_ generate a closed type that can only hold the values
that were known at code generation time.

If this proves to be a problem, we could instead split the type:

`typedef int nix_err;` for return values
`enum nix_known_err` for code generation.

This would complicate the interface, so let's not do it unless it
is shown to be needed.
2024-07-17 16:54:30 +02:00
Eelco Dolstra
87f8ff23fe BasicClientConnection::handshake(): Don't send our version twice
This was accidentally introduced
in f71b4da0b3.  We didn't notice this
because the version got interpreted by the daemon as the obsolete "CPU
affinity will follow" field, and being non-zero, it would then read
another integer for the ignored CPU affinity.
2024-07-17 16:51:53 +02:00
Eelco Dolstra
621c23bbea
Merge pull request #11113 from NixOS/doc-comment-unordered-map
Doc comments: use std::unordered_map
2024-07-17 16:50:48 +02:00
Las Safin
464e5925cb
Avoid accessing uninitialized settings in own init (#11117)
The default value for the setting was evaluated by
calling a method on the object _being currently constructed_,
so we were using it before all fields were initialized.

This has been fixed by making the called method static,
and not using the previously used fields at all.

But functionality hasn't changed!
The fields were usually always zero (by chance?) anyway,
meaning the conditional path was always taken.

Thus the current logic has been kept, the code simplified,
and UB removed.

This was found with the helper of UBSan.
2024-07-17 14:10:01 +02:00
Robert Hensing
da3eff60bc printList: Force item before determining whether to print multi-line 2024-07-17 13:42:05 +02:00
Robert Hensing
a0635a80b2 printAttrs: Force item before determining whether to print multi-line 2024-07-17 13:42:05 +02:00
Robert Hensing
ece334b532 tests/functional/repl: Characterize side effecting print behavior
Reported on matrix by aleksana:
https://matrix.to/#/!VRULIdgoKmKPzJZzjj:nixos.org/$7wZp5lUDTd-_u6MYo8kWWcysjtqTiQqP8dLI0RDNVVM?via=nixos.org&via=matrix.org&via=nixos.dev
2024-07-17 13:42:05 +02:00
Robert Hensing
f5ebaea277 Simplify PosIdx::hash()
In C++ we don't need to salt the hash.
2024-07-17 13:31:31 +02:00
Robert Hensing
b230c01f73
Merge pull request #11014 from obsidiansystems/plugins-libmain
Move plugins infra to `libnixmain`
2024-07-17 09:42:09 +02:00
Silvan Mosberger
9fae50ed4b Add parser test for indented strings
So that in the next commit we can see what changes about this test
2024-07-17 02:43:47 +02:00
John Ericson
463256b9e8
Merge pull request #11122 from L-as/fix-ub
Fix ub
2024-07-16 18:51:17 -04:00
Las Safin
a1f3f103bc
Check if drv is initialized in DerivationGoal::waiteeDone
It might not be set, in which case we shouldn't do anything.
Surprisingly, this somehow did not cause segfaults before?

Caught by UBSan.
2024-07-16 22:01:39 +00:00
Las Safin
5b6a21acc5
Avoid casting function pointer in libutil test support
Casting function pointers seems to be almost always UB.
See https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type

Fixed by doing the casting of `void*` to `std::string*` inside the function instead.

Caught by UBSan.
2024-07-16 22:01:34 +00:00
Robert Hensing
8f22245fdf
Merge pull request #11119 from philiptaron/attrbute
builtins.genericClosure: fix documentation typo
2024-07-16 23:54:59 +02:00
Philip Taron
0a1a116f4b
builtins.genericClosure: fix documentation typo 2024-07-16 13:51:52 -07:00
Robert Hensing
7dce074634 tests/functional/lang: Avoid /usr/bin/env for sandbox 2024-07-16 22:43:56 +02:00
Robert Hensing
d0e9878389 Remove unused boost include and split out std-hash.hh
Splitting it out immediately answers questions like [this],
without increasing the number of compilation units.

I did consider using boost::hash_combine instead, but it doesn't seem
to be quite as capable, accepting only two arguments.

[this]: https://github.com/NixOS/nix/pull/11113#discussion_r1679991573
2024-07-16 22:31:25 +02:00
Robert Hensing
f9a1d6b018 tests/functional/lang: Add post processing and remove certain line numbers 2024-07-16 17:36:30 +02:00
Eelco Dolstra
9300f855fc
Merge pull request #11114 from DeterminateSystems/fix-warning
Pos::getSnippetUpTo(): Fix warning
2024-07-16 17:24:43 +02:00
Robert Hensing
74698d54c8 Document builtins.derivation 2024-07-16 17:20:09 +02:00
Robert Hensing
64b46000ad Add std::hash<PosIdx> 2024-07-16 16:46:41 +02:00
Eelco Dolstra
3d8fa9f668 Pos::getSnippetUpTo(): Fix warning 2024-07-16 16:34:13 +02:00
Robert Hensing
6c9d62dceb Doc comments: use std::unordered_map
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2024-07-16 15:19:39 +02:00
Eelco Dolstra
9c6678da0e
Merge pull request #11092 from DeterminateSystems/hash-SourcePath
Use std::unordered_map for the EvalState caches
2024-07-16 11:06:43 +02:00
John Ericson
4bbadba83a
Merge pull request #11108 from obsidiansystems/remote-store-constructors
Ensure we can construct remote store configs in isolation
2024-07-15 22:51:22 -04:00
Robert Hensing
41a03738d6 tests/functional: Also keep plain grep calls safe from newlines 2024-07-16 01:54:12 +02:00
Robert Hensing
644b97ce25 tests/functional: Make our grep* helpers reject newlines in the query
Newlines behave like *OR*; not "and then".
2024-07-16 01:41:22 +02:00
Robert Hensing
f2df3f0c6c tests/vars-and-functions: Add callerPrefix helper 2024-07-16 01:40:33 +02:00