aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-03-25Input: Replace markFileChanged() by putFile()Eelco Dolstra
Committing a lock file using markFileChanged() required the input to be writable by the caller in the local filesystem (using the path returned by getSourcePath()). putFile() abstracts over this. (cherry picked from commit 95d657c8b3ae4282e24628ba7426edb90c8f3942) Change-Id: Ie081c5d9eb4e923b229191c5e23ece85145557ff
2024-03-25Overhaul completions, redo #6693 (#8131)John Ericson
As I complained in https://github.com/NixOS/nix/pull/6784#issuecomment-1421777030 (a comment on the wrong PR, sorry again!), #6693 introduced a second completions mechanism to fix a bug. Having two completion mechanisms isn't so nice. As @thufschmitt also pointed out, it was a bummer to go from `FlakeRef` to `std::string` when collecting flake refs. Now it is `FlakeRefs` again. The underlying issue that sought to work around was that completion of arguments not at the end can still benefit from the information from latter arguments. To fix this better, we rip out that change and simply defer all completion processing until after all the (regular, already-complete) arguments have been passed. In addition, I noticed the original completion logic used some global variables. I do not like global variables, because even if they save lines of code, they also obfuscate the architecture of the code. I got rid of them moved them to a new `RootArgs` class, which now has `parseCmdline` instead of `Args`. The idea is that we have many argument parsers from subcommands and what-not, but only one root args that owns the other per actual parsing invocation. The state that was global is now part of the root args instead. This did, admittedly, add a bunch of new code. And I do feel bad about that. So I went and added a lot of API docs to try to at least make the current state of things clear to the next person. -- This is needed for RFC 134 (tracking issue #7868). It was very hard to modularize `Installable` parsing when there were two completion arguments. I wouldn't go as far as to say it is *easy* now, but at least it is less hard (and the completions test finally passed). Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Change-Id: If18cd5be78da4a70635e3fdcac6326dbfeea71a5 (cherry picked from commit 67eb37c1d0de28160cd25376e51d1ec1b1c8305b)
2024-03-25feat: notation to refer to no attribute search prefixTom Bereknyei
An attrPath prefix of "." indicates no need to try default attrPath prefixes. For example `nixpkgs#legacyPackages.x86_64-linux.ERROR` searches through ``` trying flake output attribute 'packages.x86_64-linux.legacyPackages.x86_64-linux.ERROR' using cached attrset attribute '' trying flake output attribute 'legacyPackages.x86_64-linux.legacyPackages.x86_64-linux.ERROR' using cached attrset attribute 'legacyPackages.x86_64-linux' trying flake output attribute 'legacyPackages.x86_64-linux.ERROR' using cached attrset attribute 'legacyPackages.x86_64-linux' ``` And there is no way to specify that one does not want the automatic search behavior. Now one can specify `nixpkgs#.legacyPackages.x86_64-linux.ERROR` to only refer to the rooted attribute path without any default injection of attribute search path or system. Change-Id: Iac1334e1470137b7ce11dcf845513810230638ec (cherry picked from commit d4aed18883b361133607296fb6cd789c47427a38)
2024-03-25Merge "Improve new CLI UX by supporting short `-E` flag for `--expr`" into mainlunaphied
2024-03-24Improve new CLI UX by supporting short `-E` flag for `--expr`Lunaphied
Change-Id: I55881c846da8416a92a14deedfa5bbbf09a122fb
2024-03-24libstore: despecialcase protocol version checkeldritch horrors
protocol versions are sent as u64. on the peer we read them as uint64, check that the upper half is 0, and throw an exception if not. we then read an arbitrary amount of data from the peer and dump it to the user terminal. this is a little bit ridiculous, can never happen in correct implementation, and is severly untested. let us just drop it entirely. Change-Id: Ibd2f53a765341ed6439d40d9d1eac11e79c6b5e3
2024-03-24libstore: un-inline copyNAR expansionseldritch horrors
these are copies of copyNAR with only some variables renamed. Change-Id: I98ddd7a98250fa5d304e18e1debf417e9f7768dd
2024-03-23Revert "Merge pull request #9476 from alois31/restore-progress-bar"Jade Lovelace
Observed to regress nix repl attrset printing with narrow windows. This reverts commit a2d5e803cf16e048f30f0334114759f81f6c5d20. Fixes: https://git.lix.systems/lix-project/lix/issues/168 Change-Id: I8e0031475b4ec26d6a71014357d973578b70815c
2024-03-23libutil: don't memset 64k in drainFDeldritch horrors
this is not needed and introduces a bunch of memset calls, making up for 3% of valgrind cycle estimation *alone*. real-world impact is a lot lower on our test machine, but we suspect that less powerful machines would see an impact from dropping this. Change-Id: Iad10e9d556e64fdeb0bee0059a4e52520058d11e
2024-03-22build: optionally build and install with mesonQyriad
This commit adds several meson.build, which successfully build and install Lix executables, libraries, and headers. Meson does not yet build docs, Perl bindings, or run tests, which will be added in following commits. As such, this commit does not remove the existing build system, or make it the default, and also as such, this commit has several FIXMEs and TODOs as notes for what should be done before the existing autoconf + make buildsystem can be removed and Meson made the default. This commit does not modify any source files. A Meson-enabled build is also added as a Hydra job, and to `nix flake check`. Change-Id: I667c8685b13b7bab91e281053f807a11616ae3d4
2024-03-20libexpr: unbreak PosTable performanceeldritch horrors
this was mostly an inconvenience for error reporting, but fully broke the debugger (because the debugger does *a lot* of eager position resolution). copying the line offsets into a local and filling that local when empty without also storing the calculated offsets back does kind of ... not cache anything. fixes https://git.lix.systems/lix-project/lix/issues/165 Change-Id: Iccb0ba193ce2f15c832978daecf7b9bebbbe8585
2024-03-19libutil: remove exception handling workingness checkeldritch horrors
within lix itself this problem is caught by the test suite. outside of lix itself three cases can be had: either the problem is fully inside lix libs, fully inside user code, or it exists at the boundary. the first is caught by the test suite, the second isn't caught at all, and the third is something lix should not be responsible for. Change-Id: I95aa35d8cb6f0ef5816a2941c467bc0c15916063
2024-03-18Merge changes I72c945ca,I2138bb4d,Ib96749f3 into mainjade
* changes: Release notes for builtins.nixVersion change un-nixes ur lix, a little issue importer: list issues that are *not* closed when finding existing issues
2024-03-18un-nixes ur lix, a littleJade Lovelace
I didn't really go attack the docs because we need to pull a bunch of PRs. I went looking for strings in the code that called lix nix. Change-Id: I2138bb4dd239096bc530946b281db7f875195b39
2024-03-18libutil: make AutoCloseFD a better resourceeldritch horrors
add a reset() method to close the wrapped fd instead of assigning magic constants. also make the from-fd constructor explicit so you can't accidentally assign the *wrong* magic constant, or even an unrelated integer that also just happens to be an fd by pure chance. Change-Id: I51311b0f6e040240886b5103d39d1794a6acc325
2024-03-18libexpr: associate let exprs with the correct StaticEnveldritch horrors
static env association is from expr to its enclosing scope, but let exprs set their association to their *inner* scope. this skips one level of envs and will cause segfaults if the parent is a with expr. fixes #145 Change-Id: I1d22146110f071ede21b4eed7ed34b5850ef2ef3
2024-03-18libexpr: sort binding name in debuggereldritch horrors
not doing this exposes the binding name order to the annoying interference of parse order on symbol order, which wouldn't be so bad if it didn't make the tests less reliable and, importantly, dependent on linker behavior (due to primop initialization being done in static initializer, and the order of static initializers being defined only within a single translation unit). fixes #143 Change-Id: I3cf417893fbcf19e9ad3ff8986deb7cbcf3ca511
2024-03-18Merge "Delete hasPrefix and hasSuffix from the codebase" into mainjade
2024-03-18use byte indexed locations for PosIdxeldritch horrors
we now keep not a table of all positions, but a table of all origins and their sizes. position indices are now direct pointers into the virtual concatenation of all parsed contents. this slightly reduces memory usage and time spent in the parser, at the cost of not being able to report positions if the total input size exceeds 4GiB. this limit is not unique to nix though, rustc and clang also limit their input to 4GiB (although at least clang refuses to process inputs that are larger, we will not). this new 4GiB limit probably will not cause any problems for quite a while, all of nixpkgs together is less than 100MiB in size and already needs over 700MiB of memory and multiple seconds just to parse. 4GiB worth of input will easily take multiple minutes and over 30GiB of memory without even evaluating anything. if problems *do* arise we can probably recover the old table-based system by adding some tracking to Pos::Origin (or increasing the size of PosIdx outright), but for time being this looks like more complexity than it's worth. since we now need to read the entire input again to determine the line/column of a position we'll make unsafeGetAttrPos slightly lazy: mostly the set it returns is only used to determine the file of origin of an attribute, not its exact location. the thunks do not add measurable runtime overhead. notably this change is necessary to allow changing the parser since apparently nothing supports nix's very idiosyncratic line ending choice of "anything goes", making it very hard to calculate line/column positions in the parser (while byte offsets are very easy). (cherry picked from commit 5d9fdab3de0ee17c71369ad05806b9ea06dfceda) Change-Id: Ie0b2430cb120c09097afa8c0101884d94f4bbf34
2024-03-18diagnose "unexpected EOF" at EOFeldritch horrors
this needs a string comparison because there seems to be no other way to get that information out of bison. usually the location info is going to be correct (pointing at a bad token), but since EOF isn't a token as such it'll be wrong in that this case. this hasn't shown up much so far because a single line ending *is* a token, so any file formatted in the usual manner (ie, ending in a line ending) would have its EOF position reported correctly. (cherry picked from commit 855fd5a1bb781e4f722c1d757ba43e866d370132) Change-Id: I120c56a962f4286b1ae3b71da7b71ce8ec3e0535
2024-03-18match line endings used by parser and error reportseldritch horrors
the parser treats a plain \r as a newline, error reports do not. this can lead to interesting divergences if anything makes use of this feature, with error reports pointing to wrong locations in the input (or even outside the input altogether). (cherry picked from commit 2be6b143289e5479cc4a2667bb84e879116c2447) Change-Id: Ieb7f7655bac8cb0cf5734c60bd41723388f2973c
2024-03-18report inherit attr errors at the duplicate nameeldritch horrors
previously we reported the error at the beginning of the binding block (for plain inherits) or the beginning of the attr list (for inherit-from), effectively hiding where exactly the error happened. this also carries over to runtime positions of attributes in sets as reported by unsafeGetAttrPos. we're not worried about this changing observable eval behavior because it *is* marked unsafe, and the new behavior is much more useful. (cherry picked from commit 1edd6fada53553b89847ac3981ac28025857ca02) Change-Id: I2f50eb9f3dc3977db4eb3e3da96f1cb37ccd5174
2024-03-18normalize formal order on ExprLambda::showeldritch horrors
we already normalize attr order to lexicographic, doing the same for formals makes sense. doubly so because the order of formals would otherwise depend on the context of the expression, which is not quite as useful as one might expect. (cherry picked from commit 4147ecfb1c51f3fe3b4adcbd4e753fd487dab645) Change-Id: I3fd0dbdef3ac7447a3a03ff20bb514a0d0f23fb1
2024-03-18keep copies of parser inputs that are in-memory onlyeldritch horrors
the parser modifies its inputs, which means that sharing them between the error context reporting system and the parser itself can confuse the reporting system. usually this led to early truncation of error context reports which, while not dangerous, can be quite confusing. (cherry picked from commit d384ecd553aa997270b79ee98d02f7cf7e1849e6) Change-Id: I677646b5675b12b2faa787943646aa36dc6e6ee3
2024-03-18libutil: remove vforkeldritch horrors
vfork confers a large performance advantage over fork, measured locally at 16µs per vfork agains 90µs per fork. however nix *almost always* follows a vfork up with an execve-family call, melting the performance advantage from 6x to only 15%. in most of those cases it's doing things that are undefined behavior (like manipulating the heap, or even throwing exceptions and trashing the parent process stack). most notably the one place that could benefit from the vfork performance improvement is linux derivation sandbox setup—which doesn't use vfork. Change-Id: I2037b7384d5a4ca24da219a569e1b1f39531410e
2024-03-17Delete hasPrefix and hasSuffix from the codebaseJade Lovelace
These now have equivalents in the standard lib in C++20. This change was performed with a custom clang-tidy check which I will submit later. Executed like so: ninja -C build && run-clang-tidy -checks='-*,nix-*' -load=build/libnix-clang-tidy.so -p .. -fix ../tests | tee -a clang-tidy-result Change-Id: I62679e315ff9e7ce72a40b91b79c3e9fc01b27e9
2024-03-17builtins.nixVersion: return fixed fake versionJade Lovelace
This builtin is only going to cause us problems because we are not Nix, so let's just falsify being in the 2.18 series, since that is the closest target that has any meaning. In future we might want to have a better feature detection mechanism, for when we actually add stuff to some builtin's attr set argument. But builtins.nixVersion is just going to be hopelessly broken and it should be stubbed out. Fixes https://git.lix.systems/lix-project/lix/issues/144 Change-Id: Id7390b32a29c6147f2977737d81846320de5d67e
2024-03-16diagnose duplicated attrs at correct patheldritch horrors
diagnose attr duplication at the path the duplication was detected, not at the path the current attribute wanted to place. doing the latter is only correct if a leaf attribute was duplicated, not if an attrpath was set to a non-attrset in one binding and a (potentially implied) attrset in another binding. fixes #124 Change-Id: Ic4aa9cc12a9874d4e7897c6f64408f10aa36fc82
2024-03-15Fix `gc-small-vector.hh` includesRebecca Turner
Change-Id: I4abc19029fb62712582761d4fc1895156b68803d
2024-03-15Allow dlopen of plugins to failJade Lovelace
It happens with some frequency that plugins that might be unimportant to the evaluation at hand mismatch with the nix version, leading to spurious load failures. Let's make these non fatal. Change-Id: Iba10e951d171725ccf1a121bcd9be1e1d6ad69eb
2024-03-14libexpr: fix elided value counting in printereldritch horrors
using the total-attrs-printed and total-list-items-printed counters to calculate how many attrs were elided only works properly if no nesting is involved. once things do nest the global counter can exceed the size of the currently printed object, leading to unsigned wrapping and great overestimation of elided counts. counting locally in addition to global counts fixes this. these are functional tests because creating these objects requires the evaluator to not be a huge amount of code, and we also want defaults to be tested for cli usage. fixes #14 Change-Id: Icb9a0cb21b2f4bacbc5e9dcdd8c0b9055b4088a7
2024-03-11add automated usage mode to the replJade Lovelace
This is definitely not a stable thing, but it does feel slightly crimes to put it as an experimental feature. Shrug, up for bikeshedding. Change-Id: I6ef176e3dee6fb1cac9c0a7a60d553a2c63ea728
2024-03-11Merge "refactor: repl prompts are now the job of the interacter" into mainjade
2024-03-11Merge "refactor: move readline stuff into its own file" into mainjade
2024-03-11Merge "finally.hh: delete copy constructor which is a bad idea" into mainjade
2024-03-11Merge "Add box_ptr: nonnull unique_ptr with value semantics" into mainjade
2024-03-11Merge "util.hh: split out signals stuff" into mainjade
2024-03-11refactor: repl prompts are now the job of the interacterJade Lovelace
Change-Id: I17c2873dfbbff303cdbdc7a8903deb8409ce3026
2024-03-11refactor: move readline stuff into its own fileJade Lovelace
This is in direct preparation for an automation mode of nix repl. Change-Id: I26e6ca88ef1c48aab11a2d1e939ff769f1770caa
2024-03-11finally.hh: delete copy constructor which is a bad ideaJade Lovelace
Change-Id: I6d0b5736893c44bddc6f5789b452b434f8671b9b
2024-03-11Add box_ptr: nonnull unique_ptr with value semanticsJade Lovelace
This solves the problem of collections of boxed subclasses with virtual dispatch, which should still be treated as values, since the indirection is only there due to the virtual dispatch. Change-Id: I368daedd3f31298e99c6e56a15606337a55494c6
2024-03-11util.hh: split out signals stuffJade Lovelace
Copies part of the changes of ac89bb064aeea85a62b82a6daf0ecca7190a28b7 Change-Id: I9ce601875cd6d4db5eb1132d7835c5bab9f126d8
2024-03-10Merge "Print derivation paths in `nix eval`" into mainjade
2024-03-10add doc comment justifying ExprInheritFromeldritch horrors
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> (cherry picked from commit f24e445bc024cfd3c26be5f061280af549321c22) Change-Id: I7acda5d5c34c0914a78adc2385d32782c4c275cd
2024-03-10remove ExprAttrs::AttrDef::inheritedeldritch horrors
it's no longer widely used and has a rather confusing meaning now that inherit-from is handled very differently. (cherry picked from commit 1cd87b7042d14aae1fafa47b1c28db4c5bd20de7) Change-Id: I90bbebddf06762960d8ca4f621cf042ce8ae83f9
2024-03-10evaluate inherit (from) exprs only once per directiveeldritch horrors
desugaring inherit-from to syntactic duplication of the source expr also duplicates side effects of the source expr (such as trace calls) and expensive computations (such as derivationStrict). (cherry picked from commit cefd0302b55b3360dbca59cfcb4bf6a750d6cdcf) Change-Id: Iff519f991adef2e51683ba2c552d37a3df7a179e
2024-03-10remove getDerivations deduplicationeldritch horrors
deduplication does not currently work fully, showing derivations multiple times if they have different underlying values. this can happen by selecting the same derivation twice for two different attributes of a set, using inherit-from (which reduces to the previous), importing nixpkgs twice, or any other number of things. since users already have to deal with duplicates for this reason it won't hurt to add *more* duplicates. the alternative would be to deduplicate fully, which would drop derivations that are currently returned and those pose a regression risk. Change-Id: I64b397351237e10375d270f1bddecb71f62aa131
2024-03-10group inherit by source during Expr::showeldritch horrors
for plain inherits this is really just a stylistic choice, but for inherit-from it actually fixes an exponential size increase problem during expr printing (as may happen during assertion failure reporting, on during duplicate attr detection in the parser) (cherry picked from commit ecf8b12d60ad2929f9998666cf0966475b91e291) Change-Id: Ie55f0cb01a37e766414c31f8d40f51c2c7d106b0
2024-03-10use the same bindings print for ExprAttrs and ExprLeteldritch horrors
this also has the effect of sorting let bindings lexicographically rather than by symbol creation order as was previously done, giving a better canonicalization in the process. (cherry picked from commit 6c08fba533ef31cad2bdc03ba72ecf58dc8ee5a0) Change-Id: Ia887f629305645bb8a165fbbc0d32e620912595a
2024-03-10add ExprAttrs::AttrDef::chooseByKindeldritch horrors
in place of inherited() — not quite useful yet since we don't distinguish plain and inheritFrom attr kinds so far. (cherry picked from commit 1f542adb3e18e7078e6a589182a53a47d971748a) Change-Id: If948c9d43e875de18f213a73a06a36f7c335b536