From e7694d9b4fabb51574c19a63f8b7ea30b3581032 Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Thu, 9 May 2024 01:01:40 +0200 Subject: liboqs: migrate to by-name --- pkgs/by-name/li/liboqs/fix-openssl-detection.patch | 36 +++++++++++++++ pkgs/by-name/li/liboqs/package.nix | 53 ++++++++++++++++++++++ pkgs/development/libraries/liboqs/default.nix | 52 --------------------- .../libraries/liboqs/fix-openssl-detection.patch | 36 --------------- pkgs/top-level/all-packages.nix | 2 - 5 files changed, 89 insertions(+), 90 deletions(-) create mode 100644 pkgs/by-name/li/liboqs/fix-openssl-detection.patch create mode 100644 pkgs/by-name/li/liboqs/package.nix delete mode 100644 pkgs/development/libraries/liboqs/default.nix delete mode 100644 pkgs/development/libraries/liboqs/fix-openssl-detection.patch diff --git a/pkgs/by-name/li/liboqs/fix-openssl-detection.patch b/pkgs/by-name/li/liboqs/fix-openssl-detection.patch new file mode 100644 index 000000000000..33be7188370f --- /dev/null +++ b/pkgs/by-name/li/liboqs/fix-openssl-detection.patch @@ -0,0 +1,36 @@ +From 6bdcf53de74ac2afba42deea63522939ca51f871 Mon Sep 17 00:00:00 2001 +From: Raphael Robatsch +Date: Mon, 25 Dec 2023 16:15:29 +0000 +Subject: [PATCH] Do not forcibly set OPENSSL_ROOT_DIR. + +CMake can already find OpenSSL via pkg-config. Setting OPENSSL_ROOT_DIR +forcibly to "/usr" breaks this. +--- + CMakeLists.txt | 11 ----------- + 1 file changed, 11 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 288bcbe8..9750fae6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -119,17 +119,6 @@ include(.CMake/compiler_opts.cmake) + include(.CMake/alg_support.cmake) + + if(${OQS_USE_OPENSSL}) +- if(NOT DEFINED OPENSSL_ROOT_DIR) +- if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") +- if(EXISTS "/usr/local/opt/openssl@1.1") +- set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1") +- elseif(EXISTS "/opt/homebrew/opt/openssl@1.1") +- set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl@1.1") +- endif() +- elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") +- set(OPENSSL_ROOT_DIR "/usr") +- endif() +- endif() + find_package(OpenSSL 1.1.1 REQUIRED) + endif() + +-- +2.42.0 + diff --git a/pkgs/by-name/li/liboqs/package.nix b/pkgs/by-name/li/liboqs/package.nix new file mode 100644 index 000000000000..f6d996bc1b1d --- /dev/null +++ b/pkgs/by-name/li/liboqs/package.nix @@ -0,0 +1,53 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + openssl, + fetchpatch, + enableStatic ? stdenv.hostPlatform.isStatic, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "liboqs"; + version = "0.10.0"; + + src = fetchFromGitHub { + owner = "open-quantum-safe"; + repo = "liboqs"; + rev = finalAttrs.version; + hash = "sha256-BFDa5NUr02lFPcT4Hnb2rjGAi+2cXvh1SHLfqX/zLlI="; + }; + + patches = [ + ./fix-openssl-detection.patch + # liboqs.pc.in path were modified in this commit + # causing malformed path with double slashes. + (fetchpatch { + url = "https://github.com/open-quantum-safe/liboqs/commit/f0e6b8646c5eae0e8052d029079ed3efa498f220.patch"; + hash = "sha256-tDfWzcDnFGikzq2ADEWiUgcUt1NSLWQ9/HVWA3rKuzc="; + revert = true; + }) + ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ openssl ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=${if enableStatic then "OFF" else "ON"}" + "-DOQS_DIST_BUILD=ON" + "-DOQS_BUILD_ONLY_LIB=ON" + ]; + + dontFixCmake = true; # fix CMake file will give an error + + outputs = [ "out" "dev" ]; + + meta = with lib; { + description = "C library for prototyping and experimenting with quantum-resistant cryptography"; + homepage = "https://openquantumsafe.org"; + license = licenses.mit; + platforms = platforms.all; + maintainers = [ maintainers.sigmanificient ]; + }; +}) diff --git a/pkgs/development/libraries/liboqs/default.nix b/pkgs/development/libraries/liboqs/default.nix deleted file mode 100644 index 13839e2a54df..000000000000 --- a/pkgs/development/libraries/liboqs/default.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - lib, - stdenv, - fetchFromGitHub, - cmake, - ninja, - openssl, - fetchpatch, - enableStatic ? stdenv.hostPlatform.isStatic, -}: - -stdenv.mkDerivation rec { - pname = "liboqs"; - version = "0.10.0"; - - src = fetchFromGitHub { - owner = "open-quantum-safe"; - repo = pname; - rev = version; - sha256 = "sha256-BFDa5NUr02lFPcT4Hnb2rjGAi+2cXvh1SHLfqX/zLlI="; - }; - - patches = [ - ./fix-openssl-detection.patch - # liboqs.pc.in path were modified in this commit - # causing malformed path with double slashes. - (fetchpatch { - url = "https://github.com/open-quantum-safe/liboqs/commit/f0e6b8646c5eae0e8052d029079ed3efa498f220.patch"; - hash = "sha256-tDfWzcDnFGikzq2ADEWiUgcUt1NSLWQ9/HVWA3rKuzc="; - revert = true; - }) - ]; - - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ openssl ]; - - cmakeFlags = [ - "-DBUILD_SHARED_LIBS=${if enableStatic then "OFF" else "ON"}" - "-DOQS_DIST_BUILD=ON" - "-DOQS_BUILD_ONLY_LIB=ON" - ]; - - dontFixCmake = true; # fix CMake file will give an error - - meta = with lib; { - description = "C library for prototyping and experimenting with quantum-resistant cryptography"; - homepage = "https://openquantumsafe.org"; - license = licenses.mit; - platforms = platforms.all; - maintainers = [ maintainers.sigmanificient ]; - }; -} diff --git a/pkgs/development/libraries/liboqs/fix-openssl-detection.patch b/pkgs/development/libraries/liboqs/fix-openssl-detection.patch deleted file mode 100644 index 33be7188370f..000000000000 --- a/pkgs/development/libraries/liboqs/fix-openssl-detection.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 6bdcf53de74ac2afba42deea63522939ca51f871 Mon Sep 17 00:00:00 2001 -From: Raphael Robatsch -Date: Mon, 25 Dec 2023 16:15:29 +0000 -Subject: [PATCH] Do not forcibly set OPENSSL_ROOT_DIR. - -CMake can already find OpenSSL via pkg-config. Setting OPENSSL_ROOT_DIR -forcibly to "/usr" breaks this. ---- - CMakeLists.txt | 11 ----------- - 1 file changed, 11 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 288bcbe8..9750fae6 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -119,17 +119,6 @@ include(.CMake/compiler_opts.cmake) - include(.CMake/alg_support.cmake) - - if(${OQS_USE_OPENSSL}) -- if(NOT DEFINED OPENSSL_ROOT_DIR) -- if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") -- if(EXISTS "/usr/local/opt/openssl@1.1") -- set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1") -- elseif(EXISTS "/opt/homebrew/opt/openssl@1.1") -- set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl@1.1") -- endif() -- elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") -- set(OPENSSL_ROOT_DIR "/usr") -- endif() -- endif() - find_package(OpenSSL 1.1.1 REQUIRED) - endif() - --- -2.42.0 - diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a38897c6125b..50de92dc7ad8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22768,8 +22768,6 @@ with pkgs; libopusenc = callPackage ../development/libraries/libopusenc { }; - liboqs = callPackage ../development/libraries/liboqs { }; - libosinfo = callPackage ../development/libraries/libosinfo { }; libosip = callPackage ../development/libraries/osip { }; -- cgit 1.4.1