Commit graph

9590 commits

Author SHA1 Message Date
Eelco Dolstra
b6a3fde6b7
Merge pull request #9465 from obsidiansystems/build-dir
Use `buildprefix` in a few more places
2023-11-30 15:28:37 +01:00
Eelco Dolstra
eac0a62052
Merge pull request #9491 from obsidiansystems/fix-freebsd
Improve ACL clearing support (fixing FreeBSD build)
2023-11-30 15:27:24 +01:00
Greg Pfeil
743232bf04
Don’t use execvp when we know the path 2023-11-30 00:17:25 -07:00
John Ericson
a7115a47ef Improve ACL clearing support (fixing FreeBSD build)
The problem was that f880469173 forgot
that the `#include <sys/xattr.h>` was guarded by an `#ifdef __linux__`.

However, the build failure was only on FreeBSD --- turns out other
platforms have this header too!

The fix therefore uses a new configure check so we properly clear ACLs
on more platforms.
2023-11-29 21:09:19 -05:00
Alex Ameen
02bd821f2e
fix: nlohmann::adl_serializer for std::optional (#9147)
This allows templates such as `NLOHMANN_DEFINE_TYPE_*` templates and other generators with things like `std::vector<std::optional<T>>`.

Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2023-11-30 01:26:39 +00:00
John Ericson
52e0911302 Use buildprefix in a few more places
`installcheck` doesn't yet work, but the rest of the build can now
happen mostly inside a separate build directory.

Progress on #9342

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-11-29 19:49:07 -05:00
Théophane Hufschmitt
6d1605818c Rename nix doctor to nix config check
Fix #7672
2023-11-28 14:28:19 +01:00
Théophane Hufschmitt
f300e11b05 Rename nix show-config to nix config show
Part of #7672
2023-11-28 14:28:19 +01:00
Alois Wohlschlager
20cd5eb2b3
nix repl: Only hide the progress bar while waiting for user input
In commit 0d2163c6dc, the progress bar was hidden
in nix repl because of a regression that caused it to interfere with user
input. Several users like(d) seeing the progress bar in the repl during builds.
Only hiding it while waiting for user input gives us the best of both worlds,
so do just that.
2023-11-27 19:25:15 +01:00
Robert Hensing
f0180487a0
Merge pull request #9462 from trofi/eval.o-dependency
libexpr: add missing dependency on 'flake/call-flake.nix.gen.hh'
2023-11-27 17:25:21 +01:00
Robert Hensing
68c48756fe libexpr/local.mk: Make eval compile deps regular
Dependency is now entirely through the eval.cc rule.
All gen.hh deps are now there.
2023-11-27 15:52:24 +01:00
Valentin Gagarin
384ffb4443 add deprecation warnings in documentation
this is hacky, but can serve as a stopgap until we can do it
programmatically.
2023-11-27 14:07:32 +01:00
Théophane Hufschmitt
d46230eff5
Merge pull request #7762 from yorickvP/boost-regex
Switch from std::regex to boost::regex
2023-11-27 10:59:22 +01:00
Sergei Trofimovich
75134b7513 libexpr: add missing dependency on 'flake/call-flake.nix.gen.hh'
Without the change build for `eval.o` fails occasionally as:

    $ make src/libexpr/eval.o
      GEN    Makefile.config
      GEN    src/libexpr/primops/derivation.nix.gen.hh
      GEN    src/libexpr/fetchurl.nix.gen.hh
      GEN    src/libexpr/parser-tab.cc
      GEN    src/libexpr/lexer-tab.cc
    src/libexpr/lexer.l:314: warning, -s option given but default rule can be matched
      CXX    src/libexpr/eval.o
    src/libexpr/eval.cc:519:18: fatal error: flake/call-flake.nix.gen.hh: No such file or directory
      519 |         #include "flake/call-flake.nix.gen.hh"
          |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [mk/patterns.mk:3: src/libexpr/eval.o] Error 1

Noticed in https://github.com/NixOS/nixpkgs/pull/269439
2023-11-27 08:56:24 +00:00
Moritz Angermann
f56401a114 nix flake update add deprecation warnings.
This builds on #8817, to add additional UX help for people with existing
muscle memory (or shell history) with --update-input and tries to gently
guide them towards the newly evolved CLI UI.

Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
2023-11-27 09:08:15 +01:00
Yorick van Pelt
d2f5e263e3
Switch from std::regex to boost::regex 2023-11-25 15:14:18 +01:00
John Ericson
dda0e34ecf
Merge pull request #9443 from ivan770/reproducibility
doc: fix machine-specific capabilities leaking
2023-11-24 22:59:38 -05:00
ivan770
54b6847655 doc: fix machine-specific capabilities leaking 2023-11-24 11:17:35 -05:00
Théophane Hufschmitt
7f626dba33
Merge pull request #9398 from Qyriad/fixes/flake-not-found
flakes: bare minimum fix the error message for untracked flake.nix
2023-11-24 15:33:08 +01:00
Robert Hensing
8a52325d7d
Merge pull request #9444 from phip1611/foldl-doc
doc: primops: fix typo
2023-11-24 13:36:18 +01:00
Théophane Hufschmitt
6a94755b12 Allow user input in git commit
We occasionnally commit to git repositories (like with `nix flake update --commit-lock-file`).
This shells out to `git commit`, which might wait for user input (for a signing key passphrase for instance).
Disable the progress bar while this is running to make sure that the
user can enter it.
2023-11-24 11:45:37 +01:00
Philipp Schuster
5be0e6b314 doc: primops: fix typo 2023-11-24 10:50:01 +01:00
Philipp Schuster
2ce8c9650b
doc: primops: add more info for foldl (#9254)
* doc: primops: add more info for foldl

From the existing doc it is not obvious whether the first or the
second argument is the accumulator. This is however relevant to
know, as for certain scenarios, this might change the behavior.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-11-23 21:02:20 +00:00
Théophane Hufschmitt
bf13943206
Merge pull request #9173 from vkryachko/transitive-input-overrides
Fix transitive input locking.
2023-11-23 08:54:45 +01:00
Robert Hensing
030fb86dd1
Merge pull request #9394 from NixOS/separate-file-canonicalise
Put `canonicaliseTimestampAndPermissions` in its own header/file
2023-11-22 18:27:52 +01:00
Eelco Dolstra
38844943d0
Merge pull request #9413 from edolstra/fetchToStore-cache
Persistently cache `InputAccessor::fetchToStore()`
2023-11-22 12:19:25 +01:00
Eelco Dolstra
b1ab592f28 Use the StorePath-based cache interface 2023-11-22 11:44:02 +01:00
r-vdp
5292f36426
Fix compile warning due to unused variable binding.
We still need the check, since we don't have narinfo for locally built store paths.
2023-11-22 11:34:53 +01:00
Eelco Dolstra
61b76f5f34
Apply suggestion
Co-authored-by: John Ericson <git@JohnEricson.me>
2023-11-22 11:26:12 +01:00
John Ericson
46131567da Add missing -lrapidcheck fixing build with shared lib
https://github.com/NixOS/nixpkgs/pull/269064 makes rapidcheck be build
as a shared lib, but that broke Nix because the `-lrapidcheck` was
missing. This fixes that (and doesn't break Nix what the library is a
static archive as today).
2023-11-21 23:19:25 -05:00
Robert Hensing
4e790efade Use boost::container::small_vector in place of VLAs 2023-11-21 20:52:27 +01:00
Matej Urbas
06b8902562 MountedSSHStore: stores on shared filesystems 2023-11-21 13:34:01 -05:00
Matej Urbas
226b0f3956 Extend the worker protocol with wopAddPermRoot 2023-11-21 13:26:55 -05:00
Matej Urbas
9796ebd7ef Add --process-ops flag to nix-daemon 2023-11-21 13:18:19 -05:00
John Ericson
949f5841f8 Add the MountedSSHStore experimental feature
It will be implemented in the subsequent commits of this PR.
2023-11-21 13:16:46 -05:00
John Ericson
f880469173 Put canonicaliseTimestampAndPermissions in its own header/file
It is not inherently tied to `LocalStore`, it could probably even go in
`libnixutil`. Functions not attached to `LocalStore` should not be
declared in `local-store.hh`.

I am moving it to facilitate experimenting for #9344. If
canonicalisation should be done client-side in client-side builds, there
wouldn't be a `LocalStore` at all so having to include that header to
get this freestanding function is cumbersome and wrong.

Perhaps canonicalisation should still be done server-side for security
reasons --- I don't mean to make that judgement call now --- but even if
so, this freestanding function still isn't connected to `LocalStore` so
while less urgent it is still better to move out of this header.
2023-11-21 12:57:59 -05:00
Robert Hensing
9cd69e1c39
Merge pull request #9411 from edolstra/path-display
Improve SourceAccessor path display
2023-11-21 18:12:01 +01:00
Lin Jian
4d8decbd13 doc: fix number of template attributes
This number is not updated when welcomeText is added[1][2].

[1]: f3a2940e70
[2]: https://github.com/NixOS/nix/pull/6103
2023-11-21 16:52:25 +01:00
Eelco Dolstra
c185e45ed7
Merge pull request #9410 from edolstra/shallow
Some shallow git fetching improvements
2023-11-21 12:58:01 +01:00
John Ericson
516e7ddc41
Merge pull request #9257 from Artturin/nixenvjsondrvpath
`nix-env --query`: fix `--json` ignoring `--drv-path`
2023-11-20 16:32:35 -05:00
Eelco Dolstra
99d5204baa Persistently cache InputAccessor::fetchToStore()
This avoids repeated copying of the same source tree between Nix
invocations. It requires the accessor to have a "fingerprint" (e.g. a
Git revision) that uniquely determines its contents.
2023-11-20 20:04:37 +01:00
Eelco Dolstra
a0162d5732 Improve SourceAccessor path display
Backported from lazy-trees. This allows SourceAccessors to show the
origin of the accessor. E.g. we now get

  copying '«git+https://github.com/blender/blender.git?ref=refs/heads/main&rev=4edc1389337dd3679ff66969c332d2aff52e1992»/' to the store

instead of

  copying '/' to the store
2023-11-20 18:54:36 +01:00
Eelco Dolstra
071f14a0bb Don't do shallow fetches over ssh 2023-11-20 17:25:40 +01:00
Eelco Dolstra
e4066c0444 Fetch specific Git revisions
This is more efficient, and necessary when using shallow=1 with a rev.
2023-11-20 17:25:40 +01:00
Eelco Dolstra
f450c8773c
Merge pull request #9408 from roblabla/fix-bad-format-string
Fix bad_format_string error when builder stdout contains %
2023-11-20 17:22:40 +01:00
roblabla
e2b6821ca0 Fix bad_format_string error when builder stdout contains % 2023-11-20 15:41:38 +01:00
John Ericson
e540d48c4f
Merge pull request #9400 from hercules-ci/refactors-from-5e3986f59cb
Refactors from 5e3986f59c
2023-11-20 09:38:18 -05:00
Théophane Hufschmitt
cfc6494d57
Merge pull request #9390 from DavHau/git-shallow-docs
fetchTree: clarify docs for shallow flag
2023-11-20 15:15:25 +01:00
John Ericson
4ab27e5595 Merge remote-tracking branch 'upstream/master' into libgit2 2023-11-20 08:30:26 -05:00
Robert Hensing
a5e51a9e02 refactor Worker::childStarted/Terminated: use switch
Preparation for RFC 92 dynamic derivations.
2023-11-20 13:32:48 +01:00
Robert Hensing
7ac39ff05c refactor Store::buildPaths: convert to string earlier
Preparation for RFC 92 dynamic derivations.
2023-11-20 13:11:58 +01:00
Eelco Dolstra
1d6abec993 Revert use of boost::container::small_vector in the evaluator
It caused random crashes (https://hydra.nixos.org/build/241514506,
https://hydra.nixos.org/build/241443330) because the heap allocation
done by small_vector in the not-small case is not scanned for GC
roots.
2023-11-20 12:35:35 +01:00
Qyriad
19993398a1 flakes: check for flake.nix before complaining that lstat on it fails
getFlake currently calls lstat (via isLink via canonPath) before it
performs the sanity check that a flake.nix exists in the first place.
This commit moves the check to before path canonicalization, so that
failed symlink check operations don't throw before the check does.
2023-11-20 03:37:02 -07:00
tomberek
fb68699456
Merge pull request #9370 from hercules-ci/add-value-types
refactor: Add `Value` types, use `std::span` for list iteration
2023-11-20 01:32:32 -05:00
nicoo
d5928085d5 builtins.concatMap: Fix typo in error message 2023-11-19 19:57:07 +01:00
DavHau
796a7eb92d fetchTree: clarify docs for shallow flag 2023-11-19 20:32:23 +07:00
John Ericson
c4a74d6dcc
Merge pull request #9382 from tweag/filterSource-link
doc: Add link to filterSource from path
2023-11-19 00:06:18 -05:00
Silvan Mosberger
70ddf298e0 doc: Add link to filterSource from path 2023-11-19 04:09:14 +01:00
Robert Hensing
251fb23aea Shebang parser: add virtual destructor
Fixes:

    warning: destructor called on non-final 'nix::ParseUnquoted' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
2023-11-19 01:48:08 +01:00
John Ericson
87ac33f29a
Merge branch 'master' into nixenvjsondrvpath 2023-11-18 13:47:14 -05:00
Robert Hensing
1d86bb4f70
Merge pull request #9373 from obsidiansystems/fix-make-check
Fix `make check`
2023-11-17 19:09:38 +01:00
Robert Hensing
4a539ac3ea Fix buildNoGc
Fixes https://hydra.nixos.org/build/241067941/nixlog/1

    src/libexpr/eval.cc:1776:54: error: variable 'boost::container::small_vector<nix::Value*, 4> vArgs' has initializer but incomplete type
2023-11-17 17:38:08 +01:00
John Ericson
293ae59257 Fix make check
After 9c7749e135, `libutil-tests_RUN`
doesn't exist. It needs to become `libutil-tests-exe_RUN`.
2023-11-17 11:26:45 -05:00
Théophane Hufschmitt
b1e7d7cad6
Merge pull request #9280 from R-VdP/rvdp/fix_remote_logging_phase_reporting
Include phase reporting in log file for ssh-ng builds
2023-11-17 14:37:09 +01:00
Eelco Dolstra
3a7f024a9c
Merge pull request #9363 from edolstra/symlink-regression
Fix symlink handling
2023-11-17 14:11:50 +01:00
Robert Hensing
121665f377 nix-env: Use state.mkList, required for correct stats 2023-11-17 10:23:32 +01:00
Robert Hensing
260c614762 Value: use std::span, change use of const
**`Value` and `const`**

These two deserve some explanation. We'll get to lists later.

Values can normally be thought of as immutable, except they are
are also the vehicle for call by need, which must be implemented
using mutation.

This circumstance makes a `const Value` a rather useless thing:

 - If it's a thunk, you can't evaluate it, except by copying, but
   that would not be call by need.

 - If it's not a thunk, you know the type, so the method that
   acquired it for you should have returned something more specific,
   such as a `const Bindings &` (which actually does make sense
   because that's an immutable span of pointers to mutable `Value`s.

 - If you don't care about the type yet, you might establish the
   convention that `const Value` means `deepSeq`-ed data, but
   this is hardly useful and not actually as safe as you would
   supposedly want to trust it to be - just convention.

**Lists**

`std::span` is a tuple of pointer and size - just what we need.

We don't return them as `const Value`, because considering the
first bullet point we discussed before, we'd have to force all
the list values, which isn't what we want.

So what we end up with is a nice representation of a list in
weak head normal form: the spine is immutable, but the
items may need some evaluation later.
2023-11-17 10:19:03 +01:00
Robert Hensing
7055c65285 Value: extract Value::Lambda 2023-11-17 10:19:03 +01:00
Robert Hensing
6af1d9f7b9 Value: extract Value::FunctionApplicationThunk 2023-11-17 10:19:03 +01:00
Robert Hensing
b55203e874 Value: extract Value::ClosureThunk 2023-11-17 10:19:03 +01:00
Robert Hensing
d8ff5cfe8e Value: extract Value::Path 2023-11-17 10:19:03 +01:00
Robert Hensing
2eb59c34b5 Value: extract Value::StringWithContext 2023-11-17 10:19:03 +01:00
Théophane Hufschmitt
7ba4e073e8
Merge pull request #6469 from gbpdt/fix/skipped_build_locking
Unlock output paths when a derivation is already built
2023-11-16 21:59:25 +01:00
Théophane Hufschmitt
fabae98ab4
Merge pull request #9360 from obsidiansystems/install-unit-tests
Allow installing unit tests
2023-11-16 21:25:21 +01:00
Théophane Hufschmitt
ac4431e9d0
Merge pull request #7348 from thufschmitt/dont-use-vlas
Remove the usage of VLAs in the code
2023-11-16 19:05:37 +01:00
Eelco Dolstra
96d67620d5 Fix a broken generated header file dependency
https://hydra.nixos.org/build/240882042
2023-11-16 17:12:06 +01:00
Eelco Dolstra
31ebc6028b Fix symlink handling
This restores the symlink handling behaviour prior to
94812cca98.

Fixes #9298.
2023-11-16 16:45:14 +01:00
John Ericson
6c8f4ef350 Allow installing unit tests
Closes #9343

See that issue for motivation.

Installing these is disabled by default, but we enable it (and the
additional output we want isntall these too so as not to clutter the
existing ones) to use in cross builds and dev shells.
2023-11-16 09:55:42 -05:00
Robert Hensing
4e27f1947a libexpr: Reduce nonRecursiveStackReservation
128 is still beyond the point where the allocation overhead is
insignificant, but we don't anticipate to overflow for these
use cases, so it's fine.
2023-11-16 15:38:21 +01:00
Robert Hensing
a96be29db5 removeAttrs: increase stack reservation to 64 2023-11-16 15:38:21 +01:00
Robert Hensing
1b9813e4e6 primops: Name stack reservation limits 2023-11-16 15:38:21 +01:00
Robert Hensing
898c47384f primops: Err on the side of less stack usage
Try to stay away from stack overflows.

These small vectors use stack space. Most instances will not need
to allocate because in general most things are small, and large
things are worth heap allocating.

16 * 3 * word = 384 bytes is still quite a bit, but these functions
tend not to be part of deep recursions.
2023-11-16 15:38:21 +01:00
Robert Hensing
91114a6fa4 ExprCall::eval: Heap allocate at arity 5+ 2023-11-16 15:38:21 +01:00
Robert Hensing
206ece0f41 builtins.{any,all}: Use constant errorCtx
Clang warned that the expanded code used to have a buffer overflow.
Very strange, but also very avoidable.
2023-11-16 15:38:21 +01:00
Robert Hensing
9fa133dde5 readProcLink: Replace unnecessary value judgement by actual info 2023-11-16 15:38:21 +01:00
Robert Hensing
12c91a823e maxPrimOpArity: 64 -> 8
This makes stack usage significantly more compact, allowing larger
amounts of data to be processed on the same stack.

PrimOp functions with more than 8 positional (curried) arguments
should use an attrset instead.
2023-11-16 15:38:21 +01:00
Eelco Dolstra
2bd2702127
Merge pull request #9354 from vicky1999/fix/8875
Renamed nix nar dump-path to nix nar pack
2023-11-16 15:06:33 +01:00
Eelco Dolstra
16c052e4e7
Merge pull request #9307 from flox/tomberek.nix_key_newline
nix key: no need for progressBar
2023-11-16 15:05:34 +01:00
Robert Hensing
0daccb1121 libexpr: Check primop arity earlier 2023-11-16 12:28:32 +01:00
Théophane Hufschmitt
ba3cb4a049 Remove all the occurences of VLAs
There's generally no strict reason for using them, and they are somewhat
fishy, so let's avoid them.
2023-11-16 12:27:30 +01:00
Théophane Hufschmitt
5196613e82 Use boost small vectors instead of VLAs in the primops
VLAs are a dangerous feature, and their usage triggers an undefined
behavior since theire size can be zero in some cases.
So replace them with `boost::small_vector`s which fit the same goal but
are safer.

It's also incidentally consistently 1% faster on the benchmarks.
2023-11-16 12:27:30 +01:00
John Ericson
e34c424279
Merge pull request #9357 from NixOS/nix-store-add
Add a new `nix store add` command
2023-11-15 13:49:44 -05:00
Théophane Hufschmitt
84128461b6 Add a new nix store add command
Deprecate `nix store add-file` and `nix store add-path`, and replace
them with a single `nix store add` command.
2023-11-15 19:21:17 +01:00
Eelco Dolstra
7ab91e7238 Implement shallow fetching 2023-11-15 15:00:17 +01:00
Eelco Dolstra
5dd4ae8687 Remove unused cacheType field 2023-11-15 14:08:34 +01:00
Eelco Dolstra
2890999911 Show Git fetch progress 2023-11-15 13:57:20 +01:00
John Ericson
9c7749e135 Fix makefile bug confusing libnixutil-test exe vs lib
The `-exe` variant is the program, the unsuffixed variant is the
library.

The corrected usage matches `libnixstore-test`.
2023-11-14 11:45:52 -05:00
Eelco Dolstra
2964a9f562 Fix relative submodule handling
Tested on

  nix flake prefetch 'git+https://github.com/blender/blender.git?rev=4ed8a360e956daf2591add4d3c9ec0719e2628fe&submodules=1'
2023-11-14 16:00:21 +01:00
Eelco Dolstra
6ec6b8aa36 Improve git submodule error reporting 2023-11-14 15:52:18 +01:00
vicky1999
e07e3c106a code cleanup 2023-11-14 20:02:33 +05:30