about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/primops.cc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-02-04 r/3768 chore: clean up some obsolete TODOssterni1-1/+0
* //3p/nix: probably not worth investing time into this anymore * //users/sterni/emacs: The emoji problem disappeared by itself with a newer emacs version, however a different one remains… * //web/panettone: If we ever want to change the behavior, we should just decide the behavior statically instead of using conditions and restarts, as we only call it in one place, so making different decisions depending on call sites is not really a use case we have. Change-Id: Iff9d439ce356db41ce34d690fb7b6a01822022fa Reviewed-on: https://cl.tvl.fyi/c/depot/+/5223 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: sterni <sternenseemann@systemli.org>
2021-02-02 r/2178 fix(tvix/libexpr): backport fix for functionArgs failing on primopssterni1-0/+5
Nix internally differentiates between lambdas and primops, but their type in the nix expression language is the same (lambda). The implementation of builtins.functionArgs only checks if the given expression is of type tLambda and fails if the type is tPrimop or tPrimopApp which are also functions. This most notably breaks lib.generators.toPretty when called on a builtin making for example yants fail if a primop is typechecked and an error message is generated. This fix generates an empty set for primops like for plain lambdas and is based upstream commit b2748c6e99239ff6803ba0da76c362790c8be192. Additionally we add to two tests: * eval-okay-functionargs now includes a few test cases checking that builtins.functionArgs always returns an empty set for builtins and also works as expected for normal functions. * eval-okay-types now also checks if builtins are functions. Future work would be to make builtins.functionArgs work as users would expect for builtins like builtins.fetchurl, builtins.fetchGit etc. which take a set as an argument. These currently don't register as formal arguments, but it would be an usability improvement at least if they did. See also https://github.com/NixOS/nix/pull/3626#issuecomment-698546704 Change-Id: I2bf4cb80d44a4b72ade13d3e0dbd7dfb1d049f32 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2477 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: glittershark <grfn@gws.fyi>
2020-12-23 r/2028 refactor(tvix/libexpr): Remove Bindings::SortedByKeys()Vincent Ambo1-34/+34
Since we don't have a Bindings implementation with unstable order this function is not required, as its callers can just iterate over the attributes instead. Change-Id: I01b35277b5a2dde69d684bc881dbd7c0701bcbb3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2291 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-22 r/1908 feat(tvix): Convert some DLOGs to VLOGsGriffin Smith1-1/+1
It seems like the amount of logging is causing things to move a little slower - even if that's not really the case, it gets in the way of debugging things. Refs: b/76 Change-Id: I9ea99a3b16e3307a0b0371bad22d03b0e2175af6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2134 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-11-21 r/1894 chore(3p): Bump nixpkgs to nixos-unstable from 2020-11-21Vincent Ambo1-13/+9
Included fixes for random breakage: * 3p/awscli: pick from the stable channel; it is broken on unstable * 3p/googletest: bumped version & removed patches that nixpkgs applies * 3p/lisp/cffi: bumped library version for SBCL compat * 3p/nix: fix libsystemd attribute * 3p/nix: reformatted (clang-format handling of ternaries changed) * glittershark/home: Use home-manager from nixkpgs * glittershark/kernel: bumped linux-ck patch hash * glittershark/kernel: removed "patch patch" * multi/whitby: Use home-manager from nixpkgs * tazjin/frog: drop Sourcetrail (it doesn't build currently) Note that in addition to these changes, some previous CLs updated the versions of git and cgit which was necessary for this channel bump, but which could not be done in the same commit due to the nature of the subtree merges. Change-Id: If2563e8a68e2750c4b913a976ff7b93b42e8b7f3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2110 Tested-by: BuildkiteCI Reviewed-by: multi <depot@in-addr.xyz> Reviewed-by: glittershark <grfn@gws.fyi>
2020-09-15 r/1792 refactor(3p/tvix): convert NixList usage to shared_ptrKane York1-4/+4
Starting to reclaim memory. Fairly simple mechanical replacement. Change-Id: I6b4c5c5596729470d1a049eba61e69e8097decf4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1971 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-09-01 r/1756 refactor(tvix): getEnv(): Return std::optionalEelco Dolstra1-1/+1
This allows distinguishing between an empty value and no value. Patch ported from upstream at https://github.com/NixOS/nix/commit/ba87b08f8529e4d9f8c58d8c625152058ceadb75 Change-Id: I061cc8e16b1a7a0341adfc3b0edca1c0c51d5c97 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1884 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-08-21 r/1698 refactor(tvix): Replace several DiscardLogsSink() with std::cerrVincent Ambo1-5/+2
Introduces the actual log sink in several places where we actually want the build logs to thread through correctly. This should cover *most* build paths. Change-Id: I735dff8a79f7e35a5874eb89b4abb980f9703dc2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1827 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-08-20 r/1689 chore(tvix): Thread a std::ostream through Store::buildPathsVincent Ambo1-1/+6
This part of the store API needs to carry a handle to the log sink from now on, so that it can be passed in as appropriate from the gRPC handlers. In all places where there is no such handler available at the moment, the discarding log sink has been inserted. This can be used as a convenient grep target in the future. Change-Id: I26628e30b4c6437dccdf8f722ca2e8ed827dfc19 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1797 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-15 r/1655 fix(tvix): Ensure prim_sort actually uses the right outlistVincent Ambo1-4/+5
Previously the outlist would not be used, and it would sort god knows what in the out value. This was probably introduced by the std::vector refactoring, and the language test for builtins.sort was disabled. Whatever reason there was for disabling it seems to be gone, so we're re-enabling it. Change-Id: I98941c2cad78df58ff7bea1ece3aaa4133e94bf8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1757 Reviewed-by: kanepyork <rikingcoding@gmail.com> Tested-by: BuildkiteCI
2020-08-14 r/1649 refactor(tvix): Make Store::buildPaths return a StatusGriffin Smith1-1/+2
Make Store::buildPaths return a Status with [[nodiscard]] rather than throwing exceptions to signal failure. This is the beginning of a long road to refactor the entire store API to be status/statusor based instead of using exceptions. Change-Id: I2e32371c95a25b87ad129987c217d49c6d6e0c85 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1745 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-08-14 r/1646 refactor(tvix): completely remove boehm gcKane York1-8/+4
We have decided that leaking memory is a better fate than random, non-debuggable memory corruption. Future CLs will begin changing various fields to std::unique_ptr and std::shared_ptr. It turns out that disabling the GC does not have disasterous impact. The Nix evaluator only runs on the client CLI, never in any long- running process. Even the REPL does not leak too badly under this change, because it uses one EvalState for the duration of the REPL. Building an explicitly tracing garbage collector is likely in the future of this project, but that giant amount of work cannot be done under a nix evaluator that is constantly crashing. We need to restore development velocity here, and this is the best way we've figured out to do it. Change-Id: I2fcda8fcee853c15a9a5e22eca7c5a784bc2bf76 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1720 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-08-08 r/1619 chore(3p/nix): apply google-readability-castingKane York1-4/+7
Command run: jq <compile_commands.json -r 'map(.file)|.[]' | grep -v '/generated/' | parallel clang-tidy -p compile_commands.json -checks=-*,google-readability-casting --fix Manual fixes applied in src/nix-env/nix-env.cc, src/libstore/store-api.cc Change-Id: I406b4be9368c557ca59329bf6f7002704e955f8d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1557 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in>
2020-08-06 r/1613 fix(3p/nix): Use SkipEmpty in all calls to absl::StrSplitKane York1-1/+2
The behavior to return a list containing a single empty string when provided an empty string is a behavior that absl inherited from legacy code. However, the behavior expected by legacy code in Nix is the behavior provided by the SkipEmpty option. Switch all calls to use SkipEmpty, except for the call already using SkipWhitespace. See also commit 26a59482d2427f640893517f1b24dd650a5bd5da, with the partly-prophetic message: "there may be other places we need to fix this as well." Change-Id: I6e94856a12cfb1b7e4a3b4e221769ed446648861 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1687 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-08-01 r/1534 fix(3p/nix): revert "apply all clang-tidy fixes"Kane York1-24/+21
This reverts commit ef54f5da9fa30b5c302f2a49595ee5d041f9706a. Resolved conflicts: third_party/nix/src/libexpr/eval.cc third_party/nix/src/libstore/builtins/fetchurl.cc third_party/nix/src/libstore/references.cc third_party/nix/src/libutil/hash.cc third_party/nix/src/nix-daemon/nix-daemon.cc Change-Id: Ib9cf6e96a79a23bde3983579ced3f92e530cb011 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1547 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-08-01 r/1527 feat(3p/nix): remove External values featureKane York1-3/+0
External values are only useful when using the plugin framework, which we are not interested in carrying forward. Reverts commit 320659b0cd161249c95e736c3fb309b1a73ea728 Change-Id: Ib4929c349bbb33f16224fc674e94c7b7d5953c6a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1505 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in>
2020-08-01 r/1515 chore(3p/nix/hash): prefer StatusOr over throwing constructorKane York1-7/+10
The use of `unwrap_throw` can be used as a later grep target. Change-Id: I8c54ed90c4289f07aecb8a1393dd10204c8bce4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1493 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-07-27 r/1495 fix(3p/nix): apply all clang-tidy fixesKane York1-21/+24
Change-Id: I265e763393422ee1881653527c91024458060825 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1432 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-23 r/1424 feat(3p/nix): remove builtins.importNativeAlyssa Ross1-50/+0
This is the shared object equivalent of builtins.exec, or a plugins equivalent accessible from the Nix language. Either way, since we don't have builtins.exec or plugins any more, I think it makes sense to remove this builtin. This will also allow us to drop the allow-unsafe-native-code-during-evaluation option, which formerly controlled whether builtins.exec and builtins.importNative were enabled. Cc: Griffin Smith <grfn@gws.fyi> Cc: Profpatsch <mail@profpatsch.de> Change-Id: I8993a8a79d559c102647308a2684c089bbc06713 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1340 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2020-07-19 r/1403 fix(3p/nix): Fix all remaining compiler warningsVincent Ambo1-2/+0
This compiles under `-Wall -Werror`. The largest chunk of this change is `final` qualifiers for the various Nix CLI command structs, which inherit from a Command class that has more virtual functions than are implemented by each command. Change-Id: I0925e6e1a39013f026773db5816e4a77d50f3b4a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1294 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-07-19 r/1400 refactor(3p/nix): Rename & undeprecate Bindings::lexicographicOrderVincent Ambo1-1/+1
The function is renamed to `SortedByKeys`, which is more descriptive, and annotated with a comment about what it is used for. The deprecation warning has been removed because this function is currently functionally required. Change-Id: I0ee3a76deff05f366feca9ddac8f38ab34bffbd0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1288 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-18 r/1377 refactor(3p/nix/libexpr): Back Nix lists with std::vectorVincent Ambo1-89/+69
This change does away with the previous special-casing of lists of certain element sizes, and the use of raw C-style arrays. Lists are now backed by a std::vector of nix::Value*, which uses the traceable GC allocator. This change is unfortunately quite noisy because the accessor methods were updated/removed accordingly, so all callsites of Nix-related lists have changed. For some operations in primops.cc where keeping the previous code structure would have been more difficult with a "proper" vector, the implementation has been replaced with std::vector methods. For example, list concatenation now uses appropriate range inserts. Anecdotally the performance of this is about equal, to even slightly better, than the previous implementation. All language tests pass and the depot paths I've used for testing still evaluate. Change-Id: Ib5eca6c0207429cb323a330c838c3a2200b2c693 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1266 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: Kane York <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-17 r/1346 chore(3p/nix): Remove builtins.execVincent Ambo1-43/+0
This is a bad idea, it shouldn't exist, nixpkgs doesn't use it. Change-Id: Ic4d1b936d8f059d5c40f0567af165b02427d7e36 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1241 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-13 r/1280 refactor(3p/nix/libexpr): Remove the nix::Symbol default constructorVincent Ambo1-1/+1
Having a default constructor for this causes a variety of annoying situations across the codebase in which this is initialised to an unexpected value, leading to constant guarding against those conditions. It turns out there's actually no intrinsic reason that this default constructor needs to exist. The biggest one was addressed in CL/1138 and this commit cleans up the remaining bits. Change-Id: I4a847f50bc90e72f028598196592a7d8730a4e01 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1139 Reviewed-by: isomer <isomer@tvl.fyi> Tested-by: BuildkiteCI
2020-06-23 r/1066 fix(3p/nix): Make traces log, not dlogGriffin Smith1-2/+2
We don't want traces compiled out since they're an actual language feature that're used in userspace - also their absence is breaking the tests Change-Id: Icaefca8f52e94001785f724fdc0c10a7586b24e7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/562 Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: Kane York <rikingcoding@gmail.com> Reviewed-by: lukegbot <bot@lukegb.com>
2020-05-27 r/865 refactor(3p/nix): Anchor local includes at src/Vincent Ambo1-14/+14
Previously all includes were anchored in one global mess of header files. This moves the includes into filesystem "namespaces" (if you will) for each sub-package of Nix. Note: This commit does not introduce the relevant build system changes.
2020-05-25 r/846 refactor(3p/nix): Replace tokenizeStrings with absl::StrSplitVincent Ambo1-1/+2
This function was a custom (and inefficient in the case of single-character delimiters) string splitter which was used all over the codebase. Abseil provides an appropriate replacement function.
2020-05-24 r/840 style(3p/nix): Remove 'using std::*' from types.hhVincent Ambo1-14/+15
It is considered bad form to use things from includes in headers, as these directives propagate to everywhere else and can make it confusing. types.hh (which is includes almost literally everywhere) had some of these directives, which this commit removes.
2020-05-23 r/823 fix(3p/nix/libexpr): Fix attrNames/attrValues builtins for btree_mapVincent Ambo1-21/+9
Replaces the previous implementations which performed sorting with one that instead walks through the map (which is already sorted) and yields values from it. This fixes a handful of language tests because the previous implementation did not actually yield useful values on the new implementation.
2020-05-22 r/803 chore(3p/nix/libexpr): Delete Bindings::sortVincent Ambo1-16/+1
This function does nothing anymore since the attributes are always in-order.
2020-05-22 r/802 fix(3p/nix): Update for usage of new attribute set APIVincent Ambo1-46/+51
The new attribute set API uses the iterators of the btree_map directly. This requires changes in various files because the internals of libexpr are very entangled. This code runs and compiles, but there is a bug causing empty attribute sets to be assigned incorrectly.
2020-05-21 r/797 refactor(3p/nix/libexpr): Use std::string as qualified typeVincent Ambo1-40/+43
Replaces most uses of `string` with `std::string`. This came up because I removed the "types.hh" import from "symbol-table.hh", which percolated through a bunch of files where `string` was suddenly no longer defined ... *sigh*
2020-05-21 r/795 fix(3p/nix): Compatibility with updated SymbolTableVincent Ambo1-23/+26
The functions in SymbolTable have been renamed to match the Google Style guide, and some debug-only functions have been removed.
2020-05-20 r/789 refactor(3p/nix): Apply clang-tidy's performance-* fixesVincent Ambo1-3/+4
This applies the performance fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html
2020-05-20 r/788 refactor(3p/nix): Apply clang-tidy's readability-* fixesVincent Ambo1-30/+31
This applies the readability fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html
2020-05-20 r/787 refactor(3p/nix): Apply clang-tidy's modernize-* fixesVincent Ambo1-6/+6
This applies the modernization fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html The 'modernize-use-trailing-return-type' fix was excluded due to my personal preference (more specifically, I think the 'auto' keyword is misleading in that position).
2020-05-19 r/777 style(3p/nix): Final act in the brace-wrapping sagaVincent Ambo1-84/+143
This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon.
2020-05-19 r/772 style(3p/nix): Add braces around single-line for-loopsVincent Ambo1-2/+6
These were not caught by the previous clang-tidy invocation, but were instead sorted out using amber[0] as such: ambr --regex 'for (\(.+\))\s([a-z].*;)' 'for $1 { $2 }' [0]: https://github.com/dalance/amber
2020-05-19 r/771 style(3p/nix): Add braces around single-line conditionalsVincent Ambo1-26/+78
These were not caught by the previous clang-tidy invocation, but were instead sorted out using amber[0] as such: ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }' [0]: https://github.com/dalance/amber
2020-05-19 r/768 fix(3p/nix): Fix incorrectly braced conditionals and loopsVincent Ambo1-4/+3
Fixes mistakes introduced by clang-tidy in the previous commit.
2020-05-19 r/767 style(3p/nix): Enforce braces around loops and conditionalsVincent Ambo1-34/+64
This change was generated with: fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \ --checks='-*,readability-braces-around-statements' --fix \ -fix-errors Some manual fixes were applied because some convoluted unbraced statements couldn't be untangled by clang-tidy. This commit still includes invalid files, but I decided to clean them up in a subsequent commit so that it becomes more obvious where clang-tidy failed. Maybe this will allow for a bug-report to clang-tidy.
2020-05-19 r/766 style(3p/nix): Reformat all includes to match new styleVincent Ambo1-3/+6
2020-05-19 r/760 style(3p/nix/libexpr): Reformat with clang-formatVincent Ambo1-2/+2
2020-05-19 r/758 refactor(3p/nix/libexpr): Replace logging.h with glogVincent Ambo1-8/+8
2020-05-17 r/740 style(3p/nix): Reformat project in Google C++ styleVincent Ambo1-1841/+1823
Reformatted with: fd . -e hh -e cc | xargs clang-format -i
2020-05-17 r/724 Add 'third_party/nix/' from commit 'be66c7a6b24e3c3c6157fd37b86c7203d14acf10'Vincent Ambo1-0/+2329
git-subtree-dir: third_party/nix git-subtree-mainline: cf8cd640c1adf74a3706efbcb0ea4625da106fb2 git-subtree-split: be66c7a6b24e3c3c6157fd37b86c7203d14acf10