Commit Graph

11283 Commits

Author SHA1 Message Date
Eelco Dolstra
2e2198fd91
Merge pull request #11855 from nix-windows/fix-windows-env-var-arg-order
Fix argument order in the Windows implementation of `getEnvOs`
2024-11-12 10:47:12 +01:00
John Ericson
355f08a728 Fix argument order in the Windows implementation of getEnvOs
See the build failure in https://github.com/msys2/MINGW-packages/pull/22499
2024-11-12 00:52:17 -05:00
Eelco Dolstra
f29e7867a9 Revert "Merge pull request #11826 from DeterminateSystems/revert-11804"
This reverts commit aeffdeffc8, reversing
changes made to 723fdeb4f1.
2024-11-11 15:21:34 +01:00
Eelco Dolstra
67a42e6240 Merge remote-tracking branch 'origin/master' into flake-substitution 2024-11-11 13:57:24 +01:00
Robert Hensing
545956d56a
Merge pull request #11849 from NixOS/autocall-const
autoCallFunction: accept const Bindings &
2024-11-10 21:31:11 +01:00
Robert Hensing
a3613f2a3c autoCallFunction: accept const Bindings &
It does not need to mutate the attrs.
`const` is shallow.
Avoids a const_cast in the hercules-ci-cnix-expr bindings.
2024-11-10 20:52:05 +01:00
Jörg Thalheim
aa9c0bc1ee
Merge pull request #11843 from xokdvium/dev/move-fixes
fix(treewide): clean up move semantics
2024-11-09 21:57:27 +01:00
Jörg Thalheim
cdcf9bd2fa
Merge pull request #11847 from xokdvium/dev/some-vector-reserves
refactor(treewide): reserve vector capacity when final size is known
2024-11-09 21:49:36 +01:00
Sergei Zimmerman
0fe3b54ee1 refactor(treewide): reserve vector capacity when final size is known
In these trivial cases the final vector size (or lower bound on the size) is known,
so we can avoid some vector reallocations. This is not very important, but is just
good practice and general hygiene.
2024-11-09 22:40:49 +03:00
Sergei Zimmerman
96eeb6f4ff refactor(treewide): make some move ctors noexcept where appropriate
This is good practice to avoid pessimisations.
Left comments for the reasoning why ctors should be noexcept.
There are some tricky cases where we intentionally want throwing move ctors/assignments.
But those cases should really be reviewed, since some of those can be replaced
with more idiomatic copy/move-and-swap.
2024-11-09 12:09:33 +03:00
Eelco Dolstra
4dceca51de Don't allow __final in fetchTree
It's now only allowed in fetchFinalTree, which is not exposed to users
but only to call-flake.nix.
2024-11-08 19:27:54 +01:00
Sergei Zimmerman
0347bca15b fix(libstore/path-info): make ValidPathInfo move constructible/assignable 2024-11-08 20:48:00 +03:00
Sergei Zimmerman
149802b9f5 fix(libstore): make BasicDerivation move-constructible/assignable 2024-11-08 20:10:38 +03:00
Sergei Zimmerman
8dd787fbf6 fix(libutil): remove no-op move from const 2024-11-08 20:10:38 +03:00
Sergei Zimmerman
6c3f720e2c fix(treewide): move arguments where needed
Moving from arguments where it should be done.
2024-11-08 20:10:38 +03:00
Sergei Zimmerman
af63d67ba5 fix(libutils): make ref move assignable/constructible 2024-11-08 20:10:38 +03:00
Sergei Zimmerman
17b49134fa fix(treewide): fix incorrect usage of std::move
`auto &&` and `T &&` are forwarding references and can be
either lvalue or rvalue references. Moving from universal references
is incorrect and should not be done.

Moving from integral or floating-point values is pointless and just
worsens debug performance.
2024-11-08 20:10:38 +03:00
Eelco Dolstra
d90b56d527 Remove no longer needed hack 2024-11-08 17:31:35 +01:00
Eelco Dolstra
ecb418e163 Merge remote-tracking branch 'origin/master' into flake-substitution 2024-11-08 16:42:12 +01:00
Sergei Zimmerman
3e0129ce3b fix(libutil/posix-source-accessor.cc): get rid of use-after-move bug
Naming class member variables the same as constructor arguments is a very
slippery slope because of how member variable names get resolved. Compiler
is not very helpful here and we need static analysis to forbid this kind of
stuff.

The following example illustrates the cause quite well:

```cpp

struct B {
    B(int) {}
};

struct A {
    A(int b): b([&](){
        return b;
        static_assert(std::is_same_v<decltype(b), int>);
    }()) {
       static_assert(std::is_same_v<decltype(b), int>);
    }
    void member() {
        static_assert(std::is_same_v<decltype(b), B>);
    }
    B b;
};

int main() {
    A(1).member();
}
```

From N4861 6.5.1 Unqualified name lookup:

> In all the cases listed in [basic.lookup.unqual], the scopes are searched
> for a declaration in the order listed in each of the respective categories;
> name lookup ends as soon as a declaration is found for the name.
> If no declaration is found, the program is ill-formed.

In the affected code there was a use-after-move for all accesses in the constructor
body, but this UB wasn't triggered.

These types of errors are trivial to catch via clang-tidy's [clang-analyzer-cplusplus.Move].
2024-11-08 16:07:45 +03:00
Jörg Thalheim
aeffdeffc8
Merge pull request #11826 from DeterminateSystems/revert-11804
Revert "Merge pull request #11804 from obsidiansystems/remove-old-make"
2024-11-08 12:04:55 +01:00
John Ericson
a6149eb89d Add eofOk parameter to the Windows readLine impl
Now the two implementations are back in sync.
2024-11-07 15:11:44 -05:00
John Ericson
372353722e Clean up standard stream logic
Now we have enough portability stuff
2024-11-07 15:11:41 -05:00
Eelco Dolstra
47bffe20e4 Revert "Merge pull request #10980 from kjeremy/flake-show-description"
This reverts commit 1c5ad159d6, reversing
changes made to 67de193277.

This reverts commit ce4e4a158e, reversing
changes made to 43e82c9446.
2024-11-07 18:12:04 +01:00
Eelco Dolstra
67d231c046 Revert "Merge pull request #11804 from obsidiansystems/remove-old-make"
This reverts commit 619eeb658a, reversing
changes made to 1af94bf471.
2024-11-07 13:46:37 +01:00
Robert Hensing
f4b05cf8ec fix: Build nix-store on arm with libatomic 2024-11-07 11:40:02 +01:00
Robert Hensing
ffc1b30f50 refact: Extract build-utils-meson/libatomic 2024-11-07 11:40:02 +01:00
Robert Hensing
388271e8ec initRepoAtomically: Catch directory_not_empty 2024-11-06 23:52:48 +01:00
John Ericson
e70c9bb06a Remove old build system 2024-11-06 16:09:18 -05:00
John Ericson
ba34ea9fe7 Add missing deps to the dev shell 2024-11-06 16:09:18 -05:00
Robert Hensing
3112e59734 ProgressBar::ask: Accept EOF as a no
This may occur when stderr is a tty but stdin is empty.
E.g.

    $ nix build </dev/null
    error: unexpected EOF reading a line

These stdio handles are how some non-interactive sandboxes behave,
including the Nix build sandbox and Hercules CI Effects.
2024-11-06 19:45:19 +01:00
Robert Hensing
f7b1e535a3 nix::readLine: Add eofOk parameter 2024-11-06 14:42:51 +01:00
Eelco Dolstra
b7882d51f2 Rename argument "final" to "result" to avoid ambiguity 2024-11-06 13:19:53 +01:00
Eelco Dolstra
0401e2710f More docs 2024-11-06 13:12:02 +01:00
Eelco Dolstra
a150798ce4 Document "final" semantics 2024-11-06 13:05:37 +01:00
Sergei Zimmerman
2e7466a4e0 fix(libutil-tests/nix_api_util): get rid of unnecessary memory leaks 2024-11-06 10:55:39 +03:00
Jörg Thalheim
2ef5e222df
Merge pull request #11813 from xokdvium/dev/fix-use-after-free-libstore-tests
fix(libstore-tests): remove use-after-free bug for `StringSource`
2024-11-06 06:48:20 +01:00
John Ericson
bf19e5c34b
Merge pull request #11803 from obsidiansystems/factor-out-dev-shell
Dev shell improvements
2024-11-05 23:58:52 -05:00
Sergei Zimmerman
5bc8957c73 fix(libstore-tests): remove use-after-free bug for StringSource
Unfortunately `StringSource` class is very easy was very easy to misuse
because the ctor took a plain `std::string_view` which has a bad habit
of being implicitly convertible from an rvalue `std::string`. This lead
to unintentional use-after-free bugs.

This patch makes `StringSource` much harder to misuse by disabling the ctor
from a `std::string &&` (but `const std::string &` is ok).

Fix affected tests from libstore-tests.
Reformat those tests with clangd's range formatting since the diff is tiny
and it seems appropriate.
2024-11-06 02:28:21 +03:00
John Ericson
dfd0033afb
Merge pull request #11809 from nix-windows/windows-build/meson-fixes
Meson fixes for msys2 builds
2024-11-05 10:46:03 -05:00
Brian McKenna
c25967384f msys2: link in wsock32 in libstore 2024-11-06 00:18:59 +11:00
Brian McKenna
f1fd277f1e msys2: make symbolic linking work in Meson 2024-11-06 00:18:58 +11:00
Brian McKenna
9dca7aeece Set Windows API version in Meson 2024-11-05 23:36:08 +11:00
John Ericson
26ea905312 Include more deps for the dev shell
When we get rid of the make build system, we would be missing things.
Incuding these packages' deps ensure we don't miss things.
2024-11-04 15:48:08 -05:00
Bryan Honof
c800f3fa93
chore: run formatters 2024-11-04 14:41:40 +01:00
Bryan Honof
affd2dbc6c
test(functional): add tests for new environment operation flags 2024-11-04 14:41:33 +01:00
Bryan Honof
0b790b4849
feat: add flag set-env-var to MixEnvironment 2024-11-04 14:02:29 +01:00
Eelco Dolstra
655bfa6b59
Merge pull request #11797 from nix-windows/windows-build/eval-error
Fix compilation of eval under Windows
2024-11-04 13:37:16 +01:00
Brian McKenna
d711c7e965 Fix compilation of eval under Windows 2024-11-04 19:32:41 +11:00
Brian McKenna
7b7e8a3307 Fix compilation of nix-build on Windows 2024-11-04 11:53:49 +11:00