From df2bfebf33a8f467585d640d2c6f74e09ed64523 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Aug 2024 14:15:15 +0300 Subject: [PATCH 1/4] lammps: don't use with lib in meta --- .../science/molecular-dynamics/lammps/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index b881d339300c..0288664dca3b 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -99,7 +99,7 @@ stdenv.mkDerivation (finalAttrs: { ln -s $out/share/vim-plugins/lammps $out/share/nvim/site ''; - meta = with lib; { + meta = { description = "Classical Molecular Dynamics simulation code"; longDescription = '' LAMMPS is a classical molecular dynamics simulation code designed to @@ -109,13 +109,16 @@ stdenv.mkDerivation (finalAttrs: { under the terms of the GNU Public License (GPL). ''; homepage = "https://www.lammps.org"; - license = licenses.gpl2Only; - platforms = platforms.linux; + license = lib.licenses.gpl2Only; + platforms = lib.platforms.linux; # compiling lammps with 64 bit support blas and lapack might cause runtime # segfaults. In anycase both blas and lapack should have the same #bits # support. broken = (blas.isILP64 && lapack.isILP64); - maintainers = [ maintainers.costrouc maintainers.doronbehar ]; + maintainers = with lib.maintainers; [ + costrouc + doronbehar + ]; mainProgram = "lmp"; }; }) From 03d44579fba974e35f694e4c34242024e3900e7d Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Aug 2024 14:32:29 +0300 Subject: [PATCH 2/4] lammps: build shared libs --- pkgs/applications/science/molecular-dynamics/lammps/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 0288664dca3b..56db78963239 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -75,6 +75,7 @@ stdenv.mkDerivation (finalAttrs: { inherit extraBuildInputs; }; cmakeFlags = [ + (lib.cmakeBool "BUILD_SHARED_LIBS" true) ] ++ (builtins.map (p: "-DPKG_${p}=ON") (builtins.attrNames (lib.filterAttrs (n: v: v) packages))) ++ (lib.mapAttrsToList (n: v: "-D${n}=${v}") extraCmakeFlags) From f573aaedbb11e60be8483ba468d19dbf85fefd88 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Aug 2024 14:32:48 +0300 Subject: [PATCH 3/4] lammps: use lib.cmakeBool for packages cmakeFlags --- pkgs/applications/science/molecular-dynamics/lammps/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/pkgs/applications/science/molecular-dynamics/lammps/default.nix index 56db78963239..2474998450cb 100644 --- a/pkgs/applications/science/molecular-dynamics/lammps/default.nix +++ b/pkgs/applications/science/molecular-dynamics/lammps/default.nix @@ -77,7 +77,7 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (lib.cmakeBool "BUILD_SHARED_LIBS" true) ] - ++ (builtins.map (p: "-DPKG_${p}=ON") (builtins.attrNames (lib.filterAttrs (n: v: v) packages))) + ++ (lib.mapAttrsToList (n: v: lib.cmakeBool "PKG_${n}" v) packages) ++ (lib.mapAttrsToList (n: v: "-D${n}=${v}") extraCmakeFlags) ; From c5bc9942ad9bbb56604cbe585ff12af3908e1e58 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Aug 2024 14:33:43 +0300 Subject: [PATCH 4/4] python31{2,1}Packages.lammps: init at 2Aug2023_update3 --- .../python-modules/lammps/default.nix | 46 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 4 ++ 2 files changed, 50 insertions(+) create mode 100644 pkgs/development/python-modules/lammps/default.nix diff --git a/pkgs/development/python-modules/lammps/default.nix b/pkgs/development/python-modules/lammps/default.nix new file mode 100644 index 000000000000..b9e0f45402d0 --- /dev/null +++ b/pkgs/development/python-modules/lammps/default.nix @@ -0,0 +1,46 @@ +{ + lib, + lammps, + stdenv, + buildPythonPackage, +}: + +let + LAMMPS_SHARED_LIB = "${lib.getLib lammps}/lib/liblammps${stdenv.hostPlatform.extensions.library}"; +in +buildPythonPackage { + inherit (lammps) pname version src; + + env = { + inherit LAMMPS_SHARED_LIB; + }; + preConfigure = '' + cd python + # Upstream assumes that the shared library is located in the same directory + # as the core.py file. We want to separate the shared library (built by + # cmake) and the Python library, so we perform this substitution: + substituteInPlace lammps/core.py \ + --replace-fail \ + "from inspect import getsourcefile" \ + "getsourcefile = lambda f: \"${LAMMPS_SHARED_LIB}\"" + ''; + + pythonImportsCheck = [ + "lammps" + "lammps.pylammps" + ]; + + # We could potentially run other examples, but some of them are so old that + # they don't run with nowadays' LAMMPS. This one is simple enough and recent + # enough and it works. + checkPhase = '' + python examples/mc.py examples/in.mc + ''; + + meta = { + description = "Python Bindings for LAMMPS"; + homepage = "https://docs.lammps.org/Python_head.html"; + inherit (lammps.meta) license; + maintainers = with lib.maintainers; [ doronbehar ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index fa07ea66ecf5..7ba3da58a970 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6734,6 +6734,10 @@ self: super: with self; { lakeside = callPackage ../development/python-modules/lakeside { }; + lammps = callPackage ../development/python-modules/lammps { + inherit (pkgs) lammps; + }; + lancedb = callPackage ../development/python-modules/lancedb { }; langchain = callPackage ../development/python-modules/langchain { };