opendp / smartnoise-core

Differential privacy validator and runtime
MIT License
290 stars 33 forks source link

How is whitenoise.rs generated? #288

Closed amanjeev closed 4 years ago

amanjeev commented 4 years ago

I am trying to build this lib on NixOS and I am running into build failure. In short, I do not see the intermediate whitenoise.rs being generated even though others are generated fine, such as bindings_analysis.rs, binding_builders.rs, components.rs and components.proto (last one being in the prototypes directory).

Thank you in advance!

amanjeev commented 4 years ago

Nevermind, I found it. It is generated via the components.proto. For anyone looking to do this on NixOS, it is a good idea to specify the environment variables PROTOC and PROTOC_INCLUDE as explained here https://docs.rs/prost-build/0.6.1/prost_build/#sourcing-protoc

In my case, I use lorri with shell.nix and my shell.nix looks like this

{ pkgs ? import <nixpkgs> {} }:
with pkgs;
mkShell {
  VENV = "env";
  buildInputs = [
    git
    python38Full
    stdenv
    libpqxx
    zlib
    zlib.dev
    libffi
    libffi.dev
    rustup
    openssl
    cargo
    protobuf
  ];
  shellHook = ''
    export PYTHONPATH=`pwd`/$VENV/${python.sitePackages}:$PYTHONPATH;
    export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
  '';
}

and that means roughly you can call

$ export PROTOC=/nix/store/<SHA>-protobuf-3.7.1/bin/protoc 

$ export PROTOC_INCLUDE=/nix/store/<SHA>-protobuf-3.7.1/include 

$ cargo build