about summary refs log tree commit diff
path: root/third_party/nix/src/libstore (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-25 r/1473 feat(3p/nix): Start implementing RPC store clientGriffin Smith4-16/+449
Add a stub class for wrapping a gRPC client to the new, proto-backed nix store protocol, along with several methods implemented but several left throwing a not implemented exception. Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: Id943d4f6d75084b8498786d580e6c9f7c92c104d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1436 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-07-25 r/1472 feat(3p/nix): Add main function for grpc daemonGriffin Smith3-4/+4
Implement the main function for the new, proto-based nix daemon. This mostly replicates the behavior of the previous nix daemon - it starts a grpc server listening on the same nix socket path and supports the same set of options - with the exception of --stdio, which has been renamed to --pipe and documented in the man page. Change-Id: Ib729283c1d5d35c0e1b0a968bc1f052f5527f2d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1356 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-07-25 r/1462 refactor(3p/nix): Remove custom base64 implementationGriffin Smith1-3/+12
Replace the custom, rather questionable base64 implementation with absl::Base64{Une,E}scape. To make sure that the custom implementation was doing the same thing I've also added a test covering nix::Hash::to_string, which was one function that used it - the test passed prior to the replacement, and continued to pass afterwards. The previous base64Decode function threw an exception on failure - to avoid going too far down the rabbit hole I've replicated that functionality at all call sites, but this should be replaced with more sensible error handling such as StatusOr eventually. Also, before this change: ❯ nix eval -f . users.tazjin.emacs.outPath "/nix/store/g6ri2q8nra96ix20bcsc734r1yyaylb1-tazjins-emacs" And after: ❯ ./result/bin/nix eval -f . users.tazjin.emacs.outPath "/nix/store/g6ri2q8nra96ix20bcsc734r1yyaylb1-tazjins-emacs" Change-Id: Id292ffbb82fe808f3f1b34670afbe7b8c13ad615 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1385 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-07-24 r/1457 fix(3p/nix): do not call vforkKane York1-3/+0
The use of vfork() in Nix is entirely illegal. Quote: If the process created by vfork() returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec*() family of functions, the behavior is undefined. -- Linux man-pages, release 5.05 Add a TODO to use the higher-performance variants of clone() on Linux when it is available. Change-Id: I42370e1568ad6e2d00d70d0b66c8aded8f1288bb Reviewed-on: https://cl.tvl.fyi/c/depot/+/1418 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: Alyssa Ross <hi@alyssa.is>
2020-07-24 r/1451 fix(3p/nix): fix more clang-tidy warningsKane York2-1/+4
Change-Id: I1e8a4852ffa450c552a4cdfc709554799854934c Reviewed-on: https://cl.tvl.fyi/c/depot/+/1416 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-24 r/1447 fix(3p/nix): Link nixutil to its dependenciesGriffin Smith1-5/+0
nixutil depends on bzip2, lzma, boost::context, brotli{enc,dec}, and openssl, but wasn't directly linking to them. This was causing linker errors in a test that only depended on nixutil. Change-Id: I60e77ea7b18b08e2946fcf9176ae0f355cd71844 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1384 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-07-23 r/1437 fix(3p/nix): remove usage of strcpyKane York2-4/+5
Change-Id: I86125609f433469a8722c780fd758234211d677e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1381 Tested-by: BuildkiteCI Reviewed-by: Alyssa Ross <hi@alyssa.is> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-22 r/1418 fix(3p/nix): Fix string escaping issue in schema includeVincent Ambo1-2/+2
The SQL schemas are included as string constants which are concatenated into a header file. In the previous Makefiles, this was done with envsubst or something - we moved it to CMake. There was a missing quote around the string to be interpolated, which meant that CMake interpreted the semicolons as part of its language syntax and did not emit them. Change-Id: Ibb4512788b26b53f297db3535094dc0194614446 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1342 Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-07-20 r/1408 chore(3p/nix): Remove support for pluginsGriffin Smith2-41/+0
Plugins seem to not really be used anywhere (I can find one plugin that's actually defined, and it doesn't seem very useful, especially since we got rid of builtins.exec) and their presence is adding additional complexity and potential sources of bugs to an already unsteady refactor. At some point we may want to bring back something *like* plugins, but their design will likely be different and it will definitely be after we have a functioning Nix again. Change-Id: I3bc40e55917f70bf260fbc208c1705e2e6a7c626 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1291 Tested-by: BuildkiteCI Reviewed-by: Alyssa Ross <hi@alyssa.is> Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-19 r/1403 fix(3p/nix): Fix all remaining compiler warningsVincent Ambo3-4/+13
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/1401 refactor(3p/nix): Remove remaining prefork-compat typeVincent Ambo1-9/+5
Removes the verbosity enum, which is no longer actively used anywhere other than a daemon protocol implementation bit that doesn't actually work. Since the verbosity was marked deprecated, this removes one of the last remaining warnings. Change-Id: Iaee9d1d6c14b30daac83bb44bcacff32a0e07fb0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1289 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-18 r/1382 feat(3p/nix/nix-daemon): Implement Worker::BuildDerivation handlerGriffin Smith4-0/+94
Implement the proto handler on the server side for Worker::BuildDerivation. This includes several additions to the proto which I had missed on the first pass, including the actual proto definition for the Derivation itself and a few sequence number reorderings which are fine because this is all provisional and not deployed yet. A couple things to note - I implemented a couple constructors for nix classes that initialize themselves based on their proto variants, which felt nice and didn't end up causing any issues. - I've made the conversions between the enum types in nix and in proto explicit via switch statements rather than using a static_cast, out of an abundance of caution that the error would get mismatched in the future and we'd convert the wrong thing to the wrong thing - this is verbose, but exceptionally future proof. Change-Id: Iecf6b88e76bc37e49efa05fd65d6cd0cb0deffed Reviewed-on: https://cl.tvl.fyi/c/depot/+/1249 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: Kane York <rikingcoding@gmail.com>
2020-07-18 r/1381 chore(3p/nix): Add missing override to UDSRemoteStore::sameMachineGriffin Smith1-1/+1
This silences a -Winconsistent-missing-override Change-Id: I2492a8ab3c0b0a33a794f012bfee6bbd0c2f0a8e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1271 Reviewed-by: Kane York <rikingcoding@gmail.com> Tested-by: BuildkiteCI
2020-07-18 r/1377 refactor(3p/nix/libexpr): Back Nix lists with std::vectorVincent Ambo1-2/+2
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-18 r/1369 test(3p/nix): Set up scaffolding & fix up tests for value-to-{json|xml}Vincent Ambo1-1/+1
Configures the CMake build to load & run the GoogleTest tests. I (grfn) also updated this to get the tests running as part of the nix derivation, which required defining our own manual configurePhase and installCheckPhase, rather than depending on the one provided by stdenv. Not doing this would cause cmake to attempt to *run* the tests as part of the buildPhase, which wouldn't work because the dynamic libraries hadn't been put into a place where the test executables knew where to find them. We're not sure *why* this fixes it, and for some reason fixing this also breaks the automatic behavior of nixpkgs of passing -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES to make, but that's eaasy enough to fix manually in a preBuild Paired-With: Griffin Smith <grfn@gws.fyi> Change-Id: I79d61854a3ff47301cdce8a40c76820a97bdf901 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1240 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-16 r/1331 chore(3p/nix/worker-protocol): Add missing includesGriffin Smith1-0/+3
These files were always implicitly depended upon by worker-protocol.hh, but just so happened also always be included in places where the other ones were already present. We are likely getting rid of this file sooner rather than later, but in the meantime this will cause clangd to shut up while I'm editing the file. Change-Id: I0d765f8b86828b6612e5483417e452221ea3c5b1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1207 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-07-16 r/1313 chore(3p/nix): {query,clear}FailedPaths are obsoleteGriffin Smith1-2/+2
They're not mentioned anywhere on the client or the server. Change-Id: Ia78c8bde49326f6bf69b4aeded083cfd3235131f Reviewed-on: https://cl.tvl.fyi/c/depot/+/1188 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-16 r/1309 refactor(3p/libstore): Optimise nix::printStringVincent Ambo1-12/+37
Slight performance optimisation of nix::printString by copying chunks of the input string which do not need escaping as contiguous blocks. Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I48bad90c8f2831ae4524c814a12b1982989922f9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1184 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-10 r/1249 fix(3p/nix/libstore): use exception instead of assertion when storepath is ↵Andreas Rammhold1-2/+11
malformed Previously the nix-daemon would crash if a user fed it invalid store paths for drv files. The crash was due to the changed assertion triggering. Whenever that assertion would hit the nix-daemon process along with all it's current childs (running builds from all users) would be interrupted. Before this patch: $ nix-store --realise /nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.drv don't know how to build these paths: /nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.drv error: unexpected end-of-file < nix-daemon terminates > With this patch: $ nix-store --realise /nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.drv don't know how to build these paths: /nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.drv error: path '/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.drv' is not a valid store path < nix-daemon does *NOT* terminate > Change-Id: I01c5048c8a43a8b9154bdeb781d05b7744869ec0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/981 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in>
2020-07-05 r/1217 chore(3p/nix/libstore): Link to nixproto libraryVincent Ambo1-0/+1
This isn't actually used yet, but forces the protos to be included in the build which is useful for iteration. Change-Id: I2abcaf297f34ae741f00ad0c929b226d5603c9d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/928 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi>
2020-06-21 r/1052 feat(3p/nix): install pkgconfig files for libexpr, libmain and libstoreLuke Granger-Brown2-4/+7
Also fixes the pkgconfig files to use the corresponding CMake variables. Change-Id: I8095b8aff39ad91e592f3edc95555c9f1f1f153d Reviewed-on: https://cl.tvl.fyi/c/depot/+/545 Reviewed-by: tazjin <mail@tazj.in>
2020-06-21 r/1051 chore(3p/nix): use GNUInstallDirs to determine output directory namesLuke Granger-Brown1-1/+1
This ensures that we install both glog's .a and all the .so files we generate into a single consistent output lib path (which is, err, lib64, but whatever). Change-Id: Ib6ac6eacf5f56e4b719cfb586db731efc122c31b Reviewed-on: https://cl.tvl.fyi/c/depot/+/544 Reviewed-by: tazjin <mail@tazj.in>
2020-06-21 r/1050 chore(3p/nix): export library headers to include/ in output.Luke Granger-Brown1-2/+7
Change-Id: I87eb6e59782d720015d351d8829dc7b8688e01f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/543 Reviewed-by: tazjin <mail@tazj.in>
2020-05-31 r/876 fix(3p/nix): passAsFile: leave out the hash prefixedef1-1/+1
Having a colon in the path may cause issues, and having the hash function indicated isn't actually necessary. We now verify the path format in the tests to prevent regressions. (cherry picked from commit c65a6fa86aef7bdf51fb4fba7bd31d265619ba3f)
2020-05-31 r/875 fix(3p/nix): passAsFile: hash the attribute name instead of numbering ↵Puck Meerburg1-2/+2
sequentially This makes the paths consistent without relying on ordering. Co-authored-by: edef <edef@edef.eu> (cherry picked from commit 515c0a263e137a00e82f7d981284dbe54db23247)
2020-05-30 r/872 chore(3p/nix): Clean up some unused definesVincent Ambo2-19/+1
2020-05-28 r/868 refactor(3p/nix): Introduce CMake as the build system for NixVincent Ambo2-6/+105
Completes the switch from Meson to CMake for the core build system in Nix. Meson was added originally because someone else had already done the work for integrating it in Nix and it was an upgrade from the previous setup. However over time it became clear that Meson is not quite mature enough for projects like Nix that have occasionally peculiar configuration constraints. Some issues encountered with Meson (some of these are due to the Meson setup in Nix): * Difficulty with generating correct compile_commands.json for external tools like clangd * Difficulty linking to libc++ when using clang * Ugly shell invocations for certain parts of the build system (I want these to be gone!!!) This CMake setup mimics the Meson configuration, but there are some differences (some temporary): * headers are now included separately for each library (see a previous commit that changes includes appropriately) * autoheaders-style configuration is currently hardcoded. Before blindly copying this I want to evaluate how much of it actually exists for portability concerns that I don't have (such as support for OS X). * Nix is built with libc++ by default. * [libstore] SQL schema is now inlined via a generated header, not an included string literal Abseil is still built as part of this build, rather than an external dependency, because it chokes on differently configured compiler invocations. Note that because of the move to libc++ an unwanted behaviour is introduced: glog log messages no longer have a body. I have yet to debug what is going on there.
2020-05-27 r/867 chore(3p/nix): Remove meson build files for core packagesVincent Ambo1-153/+0
2020-05-27 r/865 refactor(3p/nix): Anchor local includes at src/Vincent Ambo55-221/+225
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 Ambo16-76/+84
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-25 r/845 refactor(3p/nix/libutil): Replace hasPrefix/Suffix with AbseilVincent Ambo10-24/+38
Uses the equivalent absl::StartsWith and absl::EndsWith functions instead.
2020-05-25 r/844 fix(3p/nix/libstore): Fix error condition when parsing generationsVincent Ambo1-1/+1
2020-05-25 r/843 refactor(3p/nix/libutil): Replace string2Int & trim functionsVincent Ambo9-32/+54
Replaces these functions with corresponding functions from Abseil, namely absl::StripAsciiWhitespace and absl::SimpleAtoi. In the course of doing this some minor things I encountered along the way were also refactored. This also changes the signatures of the various custom readFile functions to use absl::string_view types.
2020-05-24 r/842 chore(3p/nix/libstore): Remove progress bar remnants from downloadVincent Ambo1-19/+0
2020-05-24 r/840 style(3p/nix): Remove 'using std::*' from types.hhVincent Ambo34-326/+336
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-24 r/835 refactor(3p/nix/libutil): Replace chomp() with absl::stringsVincent Ambo5-7/+16
2020-05-24 r/834 chore(3p/nix): Remove some OS X specific definesVincent Ambo5-226/+2
This project will be dropping OS X support until the core is simplified.
2020-05-20 r/789 refactor(3p/nix): Apply clang-tidy's performance-* fixesVincent Ambo23-76/+85
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 Ambo31-300/+308
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 Ambo24-141/+158
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-20 r/780 chore(third_party/nix): Dump of minor accumulated changesVincent Ambo1-18/+0
None of these are worthy of a specific commit, or even have a real reason behind them, but I didn't want to lose them.
2020-05-19 r/778 refactor(3p/nix): Make all single-argument constructors explicitVincent Ambo8-18/+18
Implicit constructors can be confusing, especially in a codebase that is already as unintentionally obfuscated as this one. https://google.github.io/styleguide/cppguide.html#Explicit_Constructors
2020-05-19 r/777 style(3p/nix): Final act in the brace-wrapping sagaVincent Ambo28-527/+954
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/775 style(3p/nix/libstore): Additional if/for bracing fixesVincent Ambo1-7/+11
2020-05-19 r/773 fix(3p/nix/libstore): Fix mistake introduced by bracing changesVincent Ambo1-1/+1
This statement got included in a loop when it shouldn't have been. At least it led to some funny derivation files!
2020-05-19 r/772 style(3p/nix): Add braces around single-line for-loopsVincent Ambo13-44/+132
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 Ambo30-289/+861
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-2/+1
Fixes mistakes introduced by clang-tidy in the previous commit.
2020-05-19 r/767 style(3p/nix): Enforce braces around loops and conditionalsVincent Ambo12-67/+138
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 Ambo39-36/+103