From 0856fdbe3135e280c2b70ca20fbbd9eda94a2159 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 10 Jun 2026 07:36:54 +0000 Subject: [PATCH] numsa: init at 0.2.0 --- pkgs/by-name/nu/numsa/package.nix | 107 ++++++++++++++++++ .../nu/numsa/use-external-mstore.patch | 30 +++++ 2 files changed, 137 insertions(+) create mode 100644 pkgs/by-name/nu/numsa/package.nix create mode 100644 pkgs/by-name/nu/numsa/use-external-mstore.patch diff --git a/pkgs/by-name/nu/numsa/package.nix b/pkgs/by-name/nu/numsa/package.nix new file mode 100644 index 000000000000..c823b92a5036 --- /dev/null +++ b/pkgs/by-name/nu/numsa/package.nix @@ -0,0 +1,107 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + buildType ? "meson", + + # nativeBuildInputs + asciidoctor, + gfortran, + pkg-config, + python3, + # meson: + meson, + ninja, + # cmake: + cmake, + + # buildInputs + mstore, + test-drive, + blas, + lapack, + + # propagatedBuildInputs + mctc-lib, + + # passthru + nix-update-script, +}: + +assert ( + builtins.elem buildType [ + "meson" + "cmake" + ] +); +stdenv.mkDerivation (finalAttrs: { + pname = "numsa"; + version = "0.2.0"; + __structuredAttrs = true; + strictDeps = true; + + src = fetchFromGitHub { + owner = "grimme-lab"; + repo = "numsa"; + tag = "v${finalAttrs.version}"; + hash = "sha256-PAzxeYyg/9P/3YFxKzM4ZFm2xT0AGap6q8/ei8jD/3M="; + }; + + outputs = [ + "out" + "dev" + ]; + + patches = [ + # Use nixpkgs' mstore instead of building it from source + ./use-external-mstore.patch + ]; + + postPatch = '' + substituteInPlace config/install-mod.py \ + --replace-fail "/usr/bin/env python" "${lib.getExe python3}" + ''; + + nativeBuildInputs = [ + asciidoctor + gfortran + pkg-config + python3 + ] + ++ lib.optionals (buildType == "meson") [ + meson + ninja + ] + ++ lib.optionals (buildType == "cmake") [ + cmake + ]; + + buildInputs = [ + blas + lapack + mstore # only needed to build the bundled test suite + test-drive + ]; + + propagatedBuildInputs = [ + mctc-lib + ]; + + doCheck = true; + + preCheck = '' + export OMP_NUM_THREADS=2 + ''; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Solvent accessible surface area calculation"; + homepage = "https://github.com/grimme-lab/numsa"; + changelog = "https://github.com/grimme-lab/numsa/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ GaetanLepage ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/by-name/nu/numsa/use-external-mstore.patch b/pkgs/by-name/nu/numsa/use-external-mstore.patch new file mode 100644 index 000000000000..f490884198e1 --- /dev/null +++ b/pkgs/by-name/nu/numsa/use-external-mstore.patch @@ -0,0 +1,30 @@ +diff --git a/test/meson.build b/test/meson.build +index c60e4a4..7da0216 100644 +--- a/test/meson.build ++++ b/test/meson.build +@@ -14,20 +14,21 @@ + # You should have received a copy of the GNU Lesser General Public License + # along with numsa. If not, see . + +-# Create mstore as subproject for testing +-mstore_prj = subproject( ++# Find the molecular structure store, preferring an external installation ++# (e.g. via pkg-config) and falling back to building it as a subproject ++mstore_dep = dependency( + 'mstore', + version: '>=0.1', ++ fallback: ['mstore', 'mstore_dep'], + required: not meson.is_subproject(), + default_options: [ + 'default_library=static', + ], + ) + # If we do not find mstore and are a subproject, we just skip testing +-if not mstore_prj.found() ++if not mstore_dep.found() + subdir_done() + endif +-mstore_dep = mstore_prj.get_variable('mstore_dep') + + tests = [ + 'surface',