Commit graph

15372 commits

Author SHA1 Message Date
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
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
Silvan Mosberger 70b396649c doc: logical implication is right-associative
nix-repl> bools = [ false true ]

    nix-repl> combinations = builtins.concatMap (a: builtins.concatMap (b: map (c: { inherit a b c; }) bools) bools) bools

    nix-repl> builtins.all ({ a, b, c }: (a -> b -> c) == (a -> (b -> c))) combinations
    true

    nix-repl> builtins.all ({ a, b, c }: (a -> b -> c) == ((a -> b) -> c)) combinations
    false
2023-11-15 07:04:09 +01:00
John Ericson d23d0a074d
Merge pull request #9355 from obsidiansystems/fix-tiny-libutil-unit-test-make-bug
Fix makefile bug confusing `libnixutil-test` exe vs lib
2023-11-14 12:13:41 -05: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
Théophane Hufschmitt c889881cbb
Merge pull request #9351 from Trundle/update-chroot-store-comment
Update comment to reflect bind mounts are now used for store in chroot
2023-11-14 09:09:27 +01:00
Andreas Stührk ad99c8950b Update comment to reflect bind mounts are now used for store in chroot 2023-11-13 23:29:48 +01:00
Théophane Hufschmitt 2afe2e4fbc
Merge pull request #9333 from DeterminateSystems/option-for-nix-upgrade-url
nix upgrade-nix: make the source URL an option
2023-11-12 19:45:30 +01:00
Graham Christensen fd5a4a8467 nix upgrade-nix: make the source URL an option
This new option enables organizations to more easily manage their Nix
fleet's deployment, and ensure a consistent and planned rollout of Nix
upgrades.
2023-11-10 12:12:28 -05:00
John Ericson 458e511dc4
Merge pull request #9294 from obsidiansystems/minimal-git
Git object hashing in libutil
2023-11-10 11:24:23 -05:00
John Ericson 20b95d6223 Git object hashing in libutil
This is the core functionality but just unit-tested and not yet made
part of the store layer. This is because there is some tech debt around
(a) repeated boilerplate hashing objects (b) better integration of the
new `SourceAccessor` type that needs to be cleaned up first.

Part of RFC 133

Co-Authored-By: Matthew Bauer <mjbauer95@gmail.com>
Co-Authored-By: Carlo Nucera <carlo.nucera@protonmail.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Florian Klink <flokli@flokli.de>
2023-11-10 11:02:44 -05:00
John Ericson 9afa697ab6 Refactor bash test build system a bit
The basic idea here is to separate a few intertwined notions:

1. Not all "run bash tests" are "install tests"

2. Not all "run bash tests" use `tests/functional/init.sh`, or any
   pre-test initialization at all.

This will used in the next commit when we have a test that check unit
test golden master data.

Also, move our custom `PS4` from the test to the test runner, as it is
part of how we want to display the tests, not the test themselves.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-11-10 11:02:37 -05:00
John Ericson 3d9d5dc189 Create MemorySink
This is for writing to a `MemorySourceAccessor`.
2023-11-10 11:02:37 -05:00
Eelco Dolstra d1a1888a3e
Merge pull request #9328 from obsidiansystems/editorconfig-perl
`.editorconfig`: Also affect Perl FFI `xs` file
2023-11-10 13:45:07 +01:00
John Ericson 1d5a48240c .editorconfig: Also affect Perl FFI xs file
This way `perl/lib/Nix/Store.xs` is affected.
2023-11-09 23:11:52 -05:00
Robert Hensing df9bd755a1
Merge pull request #9326 from NixOS/unstable-fetchTree-git
Mark `fetchTree` as unstable again
2023-11-09 07:44:48 +01:00
Robert Hensing 12953b942c
Fixup docs 2023-11-09 07:08:56 +01:00
John Ericson f0adb72c23 Mark fetchTree as unstable again
As discussed in our last meeting, we need a bit more time, but we are
"time boxing" the work left to do to ensure there is not unbounded
delay.

Rather than putting it back underneath `flakes`, though, put it
underneath its own `fetch-tree` experimental feature (which `flakes`
includes/implies). This signals our commitment to the plan to stabilize
it first without waiting to go through the rest of Flakes, and also will
give users a "release candidate" when we get closer to stabilization.

This reverts commit 4112dd1fc9.
2023-11-08 23:23:56 -05:00
John Ericson d854e8696b Specify the size of the experimental feature array in a more robust way
See doc comment for details.
2023-11-08 22:58:10 -05:00
John Ericson c14ba93290
Merge pull request #9317 from tfc/libstore-improvementswq
Libstore improvements
2023-11-08 15:36:38 -05:00
Jacek Galowicz df8bfe84cc Fix consts and casts 2023-11-08 17:29:55 +01:00
Jacek Galowicz c581143e0c Use structured binding for json iteration 2023-11-08 17:29:55 +01:00
Jacek Galowicz 77dceb2844 Drop obsolete assert and cast 2023-11-08 17:29:55 +01:00
Jacek Galowicz 6a47629530 Fix initialization of struct members (wrong order) 2023-11-08 17:29:55 +01:00
John Ericson d8e3b9aafc
Merge pull request #9313 from NixOS/maintainer-mission
maintainers: refine the mission statement phrasing
2023-11-08 10:12:09 -05:00
Felix Uhl c0c7c4b6cd Link to shebang interpreter docs from release notes 2023-11-07 22:11:48 +01:00
Robert Hensing ab69dc4da3 Test parseShebangContent round trip 2023-11-07 13:24:01 -05:00
Robert Hensing 589d338776 parseShebangs: Make strings with backtick sequences representable 2023-11-07 13:24:01 -05:00
Robert Hensing ffd414eb75 Fix nix shebang interaction with #8131 overhaul completions 2023-11-07 13:24:01 -05:00
Robert Hensing e91fd837ee Move shebang docs from rl-next to nix.md 2023-11-07 13:24:01 -05:00
Robert Hensing 51bb69535b nix/installables.cc: Use getCommandBaseDir() where possible
These usages of the working directory are perhaps unlikely to
interact with shebangs, but the code is more consistent this way,
and we're less likely to miss usages that do interact.
2023-11-07 13:24:01 -05:00
Robert Hensing 466271568b nix: Parse --file relative to shebang script 2023-11-07 13:24:01 -05:00
Robert Hensing 198bc22e3b nix: Add command baseDir to parse --expr relative to shebang script 2023-11-07 13:24:01 -05:00
Robert Hensing 20ff61ab25 nix: Reserve shebang line syntax and only parse double backtick quotes
Being restrictive about syntax leaves opportunity to improve the
syntax and functionality later.
2023-11-07 13:24:01 -05:00
Robert Hensing cc68ed8ff7 libcmd: lookupFileArg(): add baseDir
This will allow a different base directory to be used, matching
a shebang script location instead of the working directory.
2023-11-07 13:24:01 -05:00
Tom Bereknyei bbeddf0602 fix: refactor parseCmdline interface 2023-11-07 13:24:01 -05:00
Tom Bereknyei e6ed729243 doc: remove reference to nix-shell 2023-11-07 13:24:01 -05:00
Tom Bereknyei 06f3583b1c feat: break out of shebang processing for non-comments 2023-11-07 13:24:01 -05:00
Tom Bereknyei 01f61cefcb Read file incrementally 2023-11-07 13:24:01 -05:00
Tom Bereknyei bfcbf3b5bf doc: shebang release notes, docs, tests
fix: release notes
2023-11-07 13:24:01 -05:00