diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-02-10 11:54:06 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-02-10 11:54:06 +0100 |
commit | 1c972cba145dc95cb0930a83caf191f1ef722f8b (patch) | |
tree | ed57b226f29a2963bd6ff46cd1919c4e5c23a063 /src/nix-store/nix-store.cc | |
parent | 5d9cd27dce30e1f221815f3f888203414e12a167 (diff) |
Make libsodium an optional dependency
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r-- | src/nix-store/nix-store.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index c59eb21fb..c16adf049 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -20,7 +20,9 @@ #include <bzlib.h> +#if HAVE_SODIUM #include <sodium.h> +#endif using namespace nix; @@ -1016,6 +1018,7 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs) if (opArgs.size() != 1) throw UsageError("one argument expected"); string keyName = opArgs.front(); +#if HAVE_SODIUM sodium_init(); unsigned char pk[crypto_sign_PUBLICKEYBYTES]; @@ -1025,6 +1028,9 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs) std::cout << keyName << ":" << base64Encode(string((char *) pk, crypto_sign_PUBLICKEYBYTES)) << std::endl; std::cout << keyName << ":" << base64Encode(string((char *) sk, crypto_sign_SECRETKEYBYTES)) << std::endl; +#else + throw Error("Nix was not compiled with libsodium, required for signed binary cache support"); +#endif } |