From 1c972cba145dc95cb0930a83caf191f1ef722f8b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 10 Feb 2015 11:54:06 +0100 Subject: Make libsodium an optional dependency --- src/nix-store/nix-store.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index c59eb21fb456..c16adf049628 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -20,7 +20,9 @@ #include +#if HAVE_SODIUM #include +#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 } -- cgit 1.4.1