about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libsodium
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libsodium')
-rw-r--r--nixpkgs/pkgs/development/libraries/libsodium/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/libsodium/mingw-no-fortify.patch15
2 files changed, 56 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libsodium/default.nix b/nixpkgs/pkgs/development/libraries/libsodium/default.nix
new file mode 100644
index 000000000000..14e730d69e52
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libsodium/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchurl, autoreconfHook
+, testers
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "libsodium";
+  version = "1.0.18";
+
+  src = fetchurl {
+    url = "https://download.libsodium.org/libsodium/releases/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
+    sha256 = "1h9ncvj23qbbni958knzsli8dvybcswcjbx0qjjgi922nf848l3g";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  patches = lib.optional stdenv.targetPlatform.isMinGW ./mingw-no-fortify.patch;
+
+  nativeBuildInputs = lib.optional stdenv.targetPlatform.isMinGW autoreconfHook;
+
+  separateDebugInfo = stdenv.isLinux && stdenv.hostPlatform.libc != "musl";
+
+  enableParallelBuilding = true;
+  hardeningDisable = lib.optional (stdenv.targetPlatform.isMusl && stdenv.targetPlatform.isx86_32) "stackprotector";
+
+  # FIXME: the hardeingDisable attr above does not seems effective, so
+  # the need to disable stackprotector via configureFlags
+  configureFlags = lib.optional (stdenv.targetPlatform.isMusl && stdenv.targetPlatform.isx86_32) "--disable-ssp";
+
+  doCheck = true;
+
+  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+
+  meta = with lib; {
+    description = "A modern and easy-to-use crypto library";
+    homepage = "http://doc.libsodium.org/";
+    license = licenses.isc;
+    maintainers = with maintainers; [ raskin ];
+    pkgConfigModules = [ "libsodium" ];
+    platforms = platforms.all;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/libsodium/mingw-no-fortify.patch b/nixpkgs/pkgs/development/libraries/libsodium/mingw-no-fortify.patch
new file mode 100644
index 000000000000..e13a801f8db7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libsodium/mingw-no-fortify.patch
@@ -0,0 +1,15 @@
+diff -Naur libsodium-1.0.18-orig/configure.ac libsodium-1.0.18/configure.ac
+--- libsodium-1.0.18-orig/configure.ac	2019-05-30 16:20:24.000000000 -0400
++++ libsodium-1.0.18/configure.ac	2021-08-11 08:09:54.653907245 -0400
+@@ -217,11 +217,6 @@
+ 
+ AC_CHECK_DEFINE([__wasi__], [WASI="yes"], [])
+ 
+-AC_CHECK_DEFINE([_FORTIFY_SOURCE], [], [
+-  AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
+-    [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
+-])
+-
+ AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
+   [CFLAGS="$CFLAGS -fvisibility=hidden"])
+