mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-05 12:08:02 +03:00
lib25519: init at 20240321 (#319618)
* init: lib25519 at 20240321 Signed-off-by: Jack Leightcap <jack@leightcap.com> * Add installCheckPhase to lib25519 * Set platforms for lib25519, libcpucycles and librandombytes * Fixed patch for libcpucycles * lib25519: remove openssl unneeded variable * lib25519: patch scripts to pull toolchain from environment variables * librandombytes: add regression test script * lib25519: checkpoint for successful cross-compile * testing without binfmt * compilation for arm64 without cross compiling * compilation for x86 that creates a x86 binary * lib25519: replace compiler command to fix cross- and native compiling * librandombytes, lib25519: cleanup * crosstest.sh: drop --------- Signed-off-by: Jack Leightcap <jack@leightcap.com> Co-authored-by: Roland Coeurjoly <rolandcoeurjoly@gmail.com> Co-authored-by: imad.nyc <me@imad.nyc> Co-authored-by: Enric Morales <me@enric.me> Co-authored-by: Alberto Merino Risueño <Alberto.Merino@uclm.es> Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
This commit is contained in:
parent
69367538ed
commit
c8dfaee895
48
pkgs/by-name/li/lib25519/environment-variable-tools.patch
Normal file
48
pkgs/by-name/li/lib25519/environment-variable-tools.patch
Normal file
@ -0,0 +1,48 @@
|
||||
diff --git a/configure b/configure
|
||||
index 04042b2..30d1ea9 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -210,6 +210,17 @@ for arch in sorted(os.listdir('compilers')):
|
||||
with open('compilers/%s' % arch) as f:
|
||||
for c in f.readlines():
|
||||
c = c.strip()
|
||||
+ if env_cc := os.getenv('CC'):
|
||||
+ c_as_list= c.split()
|
||||
+ # check if the compiler we're testing has the name inside the last
|
||||
+ # part of the CC env var
|
||||
+ # i.e. gcc == x86_64-linux-unknown-gnu-gcc
|
||||
+ # or gcc == gcc
|
||||
+ if c_as_list[0] == env_cc.split("-")[-1]:
|
||||
+ c_as_list[0] = env_cc
|
||||
+ c = ' '.join(c_as_list)
|
||||
+ log('patched command as %s' % c)
|
||||
+
|
||||
cv = compilerversion(c)
|
||||
if cv == None:
|
||||
log('skipping %s compiler %s' % (arch,c))
|
||||
diff --git a/scripts-build/checknamespace b/scripts-build/checknamespace
|
||||
index ae11bed..bd9cb85 100755
|
||||
--- a/scripts-build/checknamespace
|
||||
+++ b/scripts-build/checknamespace
|
||||
@@ -36,7 +36,7 @@ def doit(d):
|
||||
obj2U = {}
|
||||
|
||||
try:
|
||||
- p = subprocess.Popen(['nm','-ApP']+objs,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,universal_newlines=True)
|
||||
+ p = subprocess.Popen([os.getenv('NM', 'nm'),'-ApP']+objs,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,universal_newlines=True)
|
||||
out,err = p.communicate()
|
||||
except Exception as e:
|
||||
warn('nm failure: %s' % e)
|
||||
diff --git a/scripts-build/staticlib b/scripts-build/staticlib
|
||||
index 7683233..0445bc3 100755
|
||||
--- a/scripts-build/staticlib
|
||||
+++ b/scripts-build/staticlib
|
||||
@@ -3,6 +3,6 @@
|
||||
lib="$1"
|
||||
|
||||
rm -f package/lib/"$lib".a
|
||||
-ar cr package/lib/"$lib".a ofiles/*.o
|
||||
-ranlib package/lib/"$lib".a || :
|
||||
+${AR:-ar} cr package/lib/"$lib".a ofiles/*.o
|
||||
+${RANLIB:-ranlib} package/lib/"$lib".a || :
|
||||
chmod 644 package/lib/"$lib".a
|
75
pkgs/by-name/li/lib25519/package.nix
Normal file
75
pkgs/by-name/li/lib25519/package.nix
Normal file
@ -0,0 +1,75 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
python3,
|
||||
fetchzip,
|
||||
librandombytes,
|
||||
libcpucycles,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "lib25519";
|
||||
version = "20240321";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://lib25519.cr.yp.to/lib25519-${finalAttrs.version}.tar.gz";
|
||||
hash = "sha256-R10Q803vCjIZCS4Z/uErsx547RaXfAELGQm9NuNhw+I=";
|
||||
};
|
||||
|
||||
patches = [ ./environment-variable-tools.patch ];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs configure
|
||||
patchShebangs scripts-build
|
||||
'';
|
||||
|
||||
# NOTE: lib25519 uses a custom Python `./configure`: it does not expect standard
|
||||
# autoconfig --build --host etc. arguments: disable
|
||||
# Pass the hostPlatform string
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
./configure --host=${stdenv.buildPlatform.system} --prefix=$out
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ python3 ];
|
||||
buildInputs = [
|
||||
librandombytes
|
||||
libcpucycles
|
||||
];
|
||||
|
||||
preFixup = lib.optionalString stdenv.isDarwin ''
|
||||
install_name_tool -id "$out/lib/lib25519.1.dylib" "$out/lib/lib25519.1.dylib"
|
||||
for f in $out/bin/*; do
|
||||
install_name_tool -change "lib25519.1.dylib" "$out/lib/lib25519.1.dylib" "$f"
|
||||
done
|
||||
'';
|
||||
|
||||
# failure: crypto_pow does not handle p=q overlap
|
||||
doInstallCheck = !stdenv.isDarwin;
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
$out/bin/lib25519-test
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "https://randombytes.cr.yp.to/";
|
||||
description = "A simple API for applications generating fresh randomness";
|
||||
changelog = "https://randombytes.cr.yp.to/download.html";
|
||||
license = with lib.licenses; [
|
||||
# Upstream specifies the public domain licenses with the terms here https://cr.yp.to/spdx.html
|
||||
publicDomain
|
||||
cc0
|
||||
bsd0
|
||||
mit
|
||||
mit0
|
||||
];
|
||||
maintainers = with lib.maintainers; [
|
||||
kiike
|
||||
imadnyc
|
||||
jleightcap
|
||||
];
|
||||
# This supports whatever platforms libcpucycles supports
|
||||
inherit (libcpucycles.meta) platforms;
|
||||
};
|
||||
})
|
@ -0,0 +1,59 @@
|
||||
diff --git a/configure b/configure
|
||||
index 87d5c14..5e2a1a4 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -112,21 +112,26 @@ def compilerversion(c):
|
||||
except:
|
||||
pass
|
||||
|
||||
-firstcompiler = None
|
||||
-
|
||||
-with open('compilers/default') as f:
|
||||
- for c in f.readlines():
|
||||
- c = c.strip()
|
||||
- cv = compilerversion(c)
|
||||
- if cv == None:
|
||||
- print('skipping default compiler %s' % c)
|
||||
- continue
|
||||
- print('using default compiler %s' % c)
|
||||
- firstcompiler = c
|
||||
- break
|
||||
-
|
||||
-if firstcompiler is None:
|
||||
- raise ValueError('did not find a working compiler')
|
||||
+if c := os.getenv("CC"):
|
||||
+ firstcompiler = c
|
||||
+ print('using default compiler %s' % c)
|
||||
+else:
|
||||
+ firstcompiler = None
|
||||
+
|
||||
+ with open('compilers/default') as f:
|
||||
+ for c in f.readlines():
|
||||
+ c = c.strip()
|
||||
+ cv = compilerversion(c)
|
||||
+ if cv == None:
|
||||
+ print('skipping default compiler %s' % c)
|
||||
+ continue
|
||||
+ print('using default compiler %s' % c)
|
||||
+ firstcompiler = c
|
||||
+ break
|
||||
+
|
||||
+ if firstcompiler is None:
|
||||
+ raise ValueError('did not find a working compiler')
|
||||
+
|
||||
|
||||
with open('build/%s/scripts/compiledefault' % host,'w') as f:
|
||||
f.write('#!/bin/sh\n')
|
||||
diff --git a/scripts-build/staticlib b/scripts-build/staticlib
|
||||
index bb23658..111ab13 100755
|
||||
--- a/scripts-build/staticlib
|
||||
+++ b/scripts-build/staticlib
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f package/lib/libcpucycles.a
|
||||
-ar cr package/lib/libcpucycles.a "$@"
|
||||
-ranlib package/lib/libcpucycles.a || :
|
||||
+${AR:-ar} cr package/lib/libcpucycles.a "$@"
|
||||
+${RANLIB:-ranlib} package/lib/libcpucycles.a || :
|
||||
chmod 644 package/lib/libcpucycles.a
|
@ -15,6 +15,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
hash = "sha256-Fb73EOHGgEehZJwTCtCG12xwyiqtDXFs9eFDsHBQiDo=";
|
||||
};
|
||||
|
||||
patches = [ ./environment-variable-tools.patch ];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs configure
|
||||
patchShebangs scripts-build
|
||||
@ -46,10 +48,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
imadnyc
|
||||
jleightcap
|
||||
];
|
||||
# list of architectures it supports, but currentlly untested with nix https://cpucycles.cr.yp.to/libcpucycles-20240318/cpucycles/options.html
|
||||
platforms = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
] ++ lib.platforms.darwin;
|
||||
inherit (librandombytes.meta) platforms;
|
||||
};
|
||||
})
|
||||
|
@ -46,6 +46,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
buildInputs = [ openssl ];
|
||||
|
||||
preFixup = lib.optionalString stdenv.isDarwin ''
|
||||
install_name_tool -id "$out/lib/librandombytes-kernel.1.dylib" "$out/lib/librandombytes-kernel.1.dylib"
|
||||
install_name_tool -change "librandombytes-kernel.1.dylib" "$out/lib/librandombytes-kernel.1.dylib" "$out/bin/randombytes-info"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "https://randombytes.cr.yp.to/";
|
||||
description = "A simple API for applications generating fresh randomness";
|
||||
|
Loading…
Reference in New Issue
Block a user