about summary refs log tree commit diff
path: root/third_party/nix/default.nix
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-29T03·17-0400
committerglittershark <grfn@gws.fyi>2020-09-01T01·07+0000
commitc5f3b12f0484cd1a5152b6c64a336e9852d7c484 (patch)
tree25a14ecc81243b2c0cee95c06071d93a1b1481af /third_party/nix/default.nix
parente472aa016e4d8bef79930d750c65e40ce21dba3a (diff)
feat(tvix): Support systemd socket activation r/1755
When the nix daemon starts up, first check (using sd_listen_fds) whether
we have been systemd socket-activated. If so, instead of passing the nix
daemon socket path to grpc, start a manual accept(2) loop, passing the
client file descriptors to grpc via AddInsecureChannelFromFd. There's an
open grpc issue at https://github.com/grpc/grpc/issues/19133 for
building support into grpc to do this automatically, but as of right now
this appears to be the only way to make this happen.

Making this happen, by the way, was a bit of a journey - at one point I
attempted to ServerBuilder's experimental AddExternalConnectionAcceptor
API, and that didn't work either - it appears that the final missing
piece to getting this working was explicitly fcntl(2)ing the client file
descriptors to set O_NONBLOCK before passing them into gRPC. With that
set, this all works inside of the test vm.

Fixes: b/56
Change-Id: I5d2ab2b5b02eb570249b30a9674e115c61b0ab0e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1882
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/default.nix')
-rw-r--r--third_party/nix/default.nix1
1 files changed, 1 insertions, 0 deletions
diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix
index ab54206492..3403b1a14c 100644
--- a/third_party/nix/default.nix
+++ b/third_party/nix/default.nix
@@ -61,6 +61,7 @@ in lib.fix (self: pkgs.llvmPackages.libcxxStdenv.mkDerivation {
     grpc
     libseccomp
     libsodium
+    systemd.lib.dev
     openssl
     protobuf
     sqlite