From 48e292b297c798977cd1ac9f8db4958b6f6fbf85 Mon Sep 17 00:00:00 2001 From: xenia Date: Wed, 20 Nov 2024 22:30:32 -0500 Subject: [PATCH] pkgs: add cado-nfs --- overlay.nix | 2 + ...se-PATH-lookup-for-non-cado-programs.patch | 72 +++++++++++++++ pkgs/crypto/cado-nfs/default.nix | 89 +++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 pkgs/crypto/cado-nfs/0001-use-PATH-lookup-for-non-cado-programs.patch create mode 100644 pkgs/crypto/cado-nfs/default.nix diff --git a/overlay.nix b/overlay.nix index e585eb0..daaed51 100644 --- a/overlay.nix +++ b/overlay.nix @@ -39,4 +39,6 @@ final: prev: { rbasefind = prev.callPackage ./pkgs/rust/rbasefind {}; eta = prev.callPackage ./pkgs/cmdline/eta {}; + + cado-nfs = prev.callPackage ./pkgs/crypto/cado-nfs {}; } diff --git a/pkgs/crypto/cado-nfs/0001-use-PATH-lookup-for-non-cado-programs.patch b/pkgs/crypto/cado-nfs/0001-use-PATH-lookup-for-non-cado-programs.patch new file mode 100644 index 0000000..9d74fe4 --- /dev/null +++ b/pkgs/crypto/cado-nfs/0001-use-PATH-lookup-for-non-cado-programs.patch @@ -0,0 +1,72 @@ +From b5e7381235ed64b58b267af8f796c50b01900464 Mon Sep 17 00:00:00 2001 +From: xenia +Date: Wed, 20 Nov 2024 22:16:47 -0500 +Subject: [PATCH] use PATH lookup for non-cado programs + +--- + scripts/cadofactor/cadoprograms.py | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/scripts/cadofactor/cadoprograms.py b/scripts/cadofactor/cadoprograms.py +index 6743480e1..946771f83 100755 +--- a/scripts/cadofactor/cadoprograms.py ++++ b/scripts/cadofactor/cadoprograms.py +@@ -1,4 +1,5 @@ + import os ++import shutil + import platform + import abc + import inspect +@@ -327,6 +328,8 @@ class Program(object, metaclass=InspectType): + # class attributes, which properties can't. Ergo dummy variables + binary = None + ++ use_which = False ++ + # This class variable definition should not be here. It gets overwritten + # when the InspectType meta-class creates the class object. The only purpose + # is to make pylint shut up about the class not having an init_signature +@@ -408,6 +411,8 @@ class Program(object, metaclass=InspectType): + self.execfile = execsubfile + elif os.path.isfile(execfile): + self.execfile = execfile ++ elif self.use_which and shutil.which(binary) is not None: ++ self.execfile = shutil.which(binary) + else: + self.execfile = os.sep.join([self.subdir, binary]) + if not skip_check_binary_exists: +@@ -1251,6 +1256,7 @@ class SSH(Program): + binary = "ssh" + name = binary + path = "/usr/bin" ++ use_which = True + def __init__(self, + host: PositionalParameter(), + *args: PositionalParameter(), +@@ -1268,6 +1274,7 @@ class RSync(Program): + binary = "rsync" + name = binary + path = "/usr/bin" ++ use_which = True + def __init__(self, + sourcefile: PositionalParameter(), + remotefile: PositionalParameter(), +@@ -1278,6 +1285,7 @@ class Ls(Program): + binary = "ls" + name = binary + path = "/bin" ++ use_which = True + def __init__(self, + *args : PositionalParameter(), + long : Toggle('l')=None, +@@ -1288,6 +1296,7 @@ class Kill(Program): + binary = "kill" + name = binary + path = "/bin" ++ use_which = True + def __init__(self, + *args: PositionalParameter(), + signal: Parameter("s"), +-- +2.44.2 + diff --git a/pkgs/crypto/cado-nfs/default.nix b/pkgs/crypto/cado-nfs/default.nix new file mode 100644 index 0000000..bee97bb --- /dev/null +++ b/pkgs/crypto/cado-nfs/default.nix @@ -0,0 +1,89 @@ +{ + fetchFromGitLab, + lib, + stdenv, + + # library deps + ecm, + gmp, + hwloc, + python3, + sqlite, + + # runtime deps + openssh, + rsync, + util-linux, + coreutils, + + # build deps + cmake, + curl, + inetutils, + perl, + + makeWrapper, + + # options + useArch ? "znver4", + useTune ? "znver4", +}: stdenv.mkDerivation rec { + pname = "cado-nfs"; + git-rev = "bb65fdf0aaee0cea5e2da368bb87651d35d02603"; + version = builtins.substring 0 7 git-rev; + + src = fetchFromGitLab { + domain = "gitlab.inria.fr"; + owner = pname; + repo = pname; + rev = git-rev; + hash = "sha256-Ao8nX9rZ0ky7MK5qXGgMe4N160sPN/En6h/YdeI2/JU="; + }; + + patches = [ + ./0001-use-PATH-lookup-for-non-cado-programs.patch + ]; + + buildInputs = [ + gmp + ecm + python3 + sqlite + hwloc + ]; + + nativeBuildInputs = [ + cmake + inetutils + curl + perl + + makeWrapper + ]; + + NIX_CFLAGS_COMPILE = "-Wno-stringop-overflow" + + (lib.optionalString (useArch != null) " -march=${useArch}") + + (lib.optionalString (useTune != null) " -mtune=${useTune}"); + + postPatch = '' + patchShebangs --build . + ''; + + postConfigure = '' + patchShebangs --build . + ''; + + cadoBinPath = lib.makeBinPath [ + openssh + rsync + util-linux + coreutils + ]; + + postInstall = '' + wrapProgram $out/bin/cado-nfs-client.py \ + --prefix PATH : ${cadoBinPath} + wrapProgram $out/bin/cado-nfs.py \ + --prefix PATH : ${cadoBinPath} + ''; +}