Overlays: Add Smoldyn (Depends on fenix)

master
Antoine Fauroux 2025-06-10 14:07:00 -04:00
parent cd960974ff
commit 1b7e4d9a2b
7 changed files with 470 additions and 4 deletions

View File

@ -1,5 +1,26 @@
{ {
"nodes": { "nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1749537578,
"narHash": "sha256-dYEEiNRw7rClQi4Y7t9jlHjbuUvSbdTdM/jXwXuaDeQ=",
"owner": "nix-community",
"repo": "fenix",
"rev": "5e3ce25aa3048f14f206a6c4fab46af6ad939482",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -87,12 +108,30 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"fenix": "fenix",
"nix-matlab": "nix-matlab", "nix-matlab": "nix-matlab",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"
} }
}, },
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1749493129,
"narHash": "sha256-nQ+gKRLXkl7gLY836ULyAwR3O0E/+vakZt78OQ+p9Fc=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "bf6d44581085bb9b6e285902a7fae77325703171",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"sops-nix": { "sops-nix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View File

@ -16,8 +16,12 @@
# Follow the system nixpkgs # Follow the system nixpkgs
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { self, nixpkgs, nixpkgs-unstable, sops-nix, nix-matlab }@attrs: let };
outputs = { self, nixpkgs, nixpkgs-unstable, sops-nix, nix-matlab, ... }@attrs: let
system = "x86_64-linux"; system = "x86_64-linux";
unfree-overlay = final: prev: { unfree-overlay = final: prev: {
unfree = import nixpkgs { unfree = import nixpkgs {
@ -35,7 +39,7 @@
config.cudaSupport = true; config.cudaSupport = true;
}; };
}; };
python-overlay = import ./overlays/python.nix; python-overlay = import ./overlays/python.nix attrs;
applyOverlays = overlays: ({...}:{ nixpkgs.overlays = overlays; }); applyOverlays = overlays: ({...}:{ nixpkgs.overlays = overlays; });
flakes = {...}: {nix.settings.experimental-features = [ "nix-command" "flakes" ];}; flakes = {...}: {nix.settings.experimental-features = [ "nix-command" "flakes" ];};
in { in {

View File

@ -45,6 +45,8 @@
spynnaker spynnaker
# fetching neuromorphic data: # fetching neuromorphic data:
tonic tonic
# Stochastic simulation
# smoldyn-py
# Librairies to deal with mesh # Librairies to deal with mesh

56
overlays/libsbml.nix Normal file
View File

@ -0,0 +1,56 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
pkg-config,
bzip2,
libxml2,
swig,
python ? null,
withPython ? false,
}:
stdenv.mkDerivation (attrs: {
pname = "libsbml";
version = "5.20.4";
src = fetchFromGitHub {
owner = "sbmlteam";
repo = "libsbml";
rev = "v${attrs.version}";
hash = "sha256-qWTN033YU4iWzt+mXQaP5W/6IF5nebF4PwNVkyL8wTg=";
};
nativeBuildInputs = [
cmake
pkg-config
swig
] ++ lib.optional withPython python.pkgs.pythonImportsCheckHook;
buildInputs = [
bzip2.dev
libxml2
] ++ lib.optional withPython python;
# libSBML doesn't always make use of pkg-config
cmakeFlags = [
"-DLIBXML_INCLUDE_DIR=${lib.getDev libxml2}/include/libxml2"
"-DLIBXML_LIBRARY=${lib.getLib libxml2}/lib/libxml2${stdenv.hostPlatform.extensions.sharedLibrary}"
"-DPKG_CONFIG_EXECUTABLE=${lib.getBin pkg-config}/bin/pkg-config"
"-DSWIG_EXECUTABLE=${lib.getBin swig}/bin/swig"
] ++ lib.optional withPython "-DWITH_PYTHON=ON";
postInstall = lib.optional withPython ''
mv $out/${python.sitePackages}/libsbml/libsbml.py $out/${python.sitePackages}/libsbml/__init__.py
'';
pythonImportsCheck = [ "libsbml" ];
meta = with lib; {
description = "Library for manipulating Systems Biology Markup Language (SBML)";
homepage = "https://github.com/sbmlteam/libsbml";
license = licenses.lgpl21Only;
maintainers = [ maintainers.kupac ];
platforms = platforms.all;
};
})

View File

@ -126,4 +126,4 @@ final: final-py: prev-py: {
pytorch-data pytorch-data
]; ];
}; };
} // (import ./spynnaker.nix final final-py prev-py) } // (import ./spynnaker.nix final final-py prev-py) #// (import ./smoldyn.nix final final-py prev-py)

View File

@ -1,5 +1,8 @@
final: prev: { inputs: final: prev:
(inputs.fenix.overlays.default final prev) // {
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [( pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [(
(import ./python-packages.nix final) (import ./python-packages.nix final)
)]; )];
libsbml = final.callPackage ./libsbml.nix { };
} }

362
overlays/smoldyn.nix Normal file
View File

@ -0,0 +1,362 @@
final: final-py: prev-py: let
rust-new = p: p.fenix.stable;
rustPlatform = final.makeRustPlatform {
inherit (rust-new final) cargo rustc;
};
py = final-py;
pyenv-smoldyn = py.python.withPackages (p: with p; [
setuptools
wheel
pybind11
pip
]);
smoldyn = final.fastStdenv.mkDerivation rec {
pname = "smoldyn";
version = "2.74";
outputs = [ "out" "py" ];
env.NIX_CFLAGS_COMPILE = "-march=native -mtune=native";
src = final.fetchzip {
url = "https://www.smoldyn.org/smoldyn-${version}.zip";
hash = "sha256-cKUMGgnPrHf2dNyFHmjpERgIMU0OltUZ/uhBfxpU4e4=";
};
nativeBuildInputs = with final; [
cmake
];
cmakeFlags = [
"-DSMOLDYN_VERSION=${version}"
"-DOPTION_ZLIB=ON"
];
buildInputs = with final; [
libGL
libGLU
freeglut
libtiff
zlib
pyenv-smoldyn
];
postInstall = ''
cp -r py $py
'';
};
in {
libsbml = final.libsbml.override {
python=py.python;
withPython=true;
};
libcombine = py.buildPythonPackage rec {
pname = "libcombine";
version = "0.2.20";
src = final.fetchFromGitHub {
owner = "sbmlteam";
repo = "libcombine";
rev = "v${version}";
fetchSubmodules = true;
hash = "sha256-9MMQr0hQLo1l8B4nlzkk48zohCohdheojRTjKrCE6og=";
};
preBuild = ''
cd ..
cp src/bindings/python/setup.py .
'';
nativeBuildInputs = with final; [
swig cmake
];
buildInputs = with py; [
libsbml
final.zlib
];
};
libsedml = py.buildPythonPackage rec {
pname = "libsedml";
version = "2.0.28";
src = final.fetchFromGitHub {
owner = "fbergmann";
repo = "libSEDML";
rev = "v${version}";
fetchSubmodules = true;
hash = "sha256-Pxts0kKj3BlfrwhXJjNvL936aSXiTb1cnccsW2lbUaM=";
};
preBuild = ''
cp src/bindings/python/setup.py .
'';
buildInputs = [
final.cmake
];
};
pyomexmeta = py.buildPythonPackage rec {
pname = "pyomexmeta";
version = "1.2.14";
src = final.fetchFromGitHub {
owner = "sys-bio";
repo = "libOmexMeta";
rev = "v${version}";
hash = "sha256-OMCq8uR3kC5cZpFyy28A02OSiVO4b49lFyWmbCeaw6c=";
};
};
# https://github.com/simularium/simulariumio/blob/main/pyproject.toml
simulariumio = py.buildPythonPackage rec {
pname = "simulariumio";
version = "1.12.0";
src = final.fetchFromGitHub {
owner = "simularium";
repo = "simulariumio";
rev = "v${version}";
hash = "sha256-Jl7KXEXeheYJRpgVcHyK6YUzyQMafQnABlrZM9d7c9g=";
leaveDotGit = true;
};
format = "pyproject";
nativeBuildInputs = with py; [
setuptools
setuptools_scm
wheel
];
SETUPTOOLS_SCM_PRETEND_VERSION=version;
propagatedBuildInputs = with py; [
numpy
pandas
pint
];
};
# https://github.com/biosimulators/Biosimulators_simularium
biosimulator_simularium = py.buildPythonPackage rec {
pname = "biosimulator";
version = "0.6.3";
src = final.fetchFromGitHub {
owner = "biosimulators";
repo = "biosimulators_simularium";
rev = "v${version}";
hash = "sha256-t0YM5Ika6Glvw3wvV71w7IHo6AovXz+7012rueEkoFw=";
};
format = "pyproject";
nativeBuildInputs = with py; [
poetry-core
];
};
biosimulator_util = py.buildPythonPackage rec {
pname = "biosimulator";
version = "0.2.3";
src = final.fetchFromGitHub {
owner = "biosimulators";
repo = "biosimulators_utils";
rev = "${version}";
hash = "sha256-/4HxruGpyJ6Guk4or/i+XI1JnHh2y7tWmw0AgdP5bkU=";
};
nativeBuildInputs = with py; [
pip
];
propagatedBuildInputs = with py; [
capturer
pkg_utils
jsonschema
flaky
bezier
rdflib
kisao
appdirs
matplotlib
docker
cement
regex
biopython
lxml
natsort
simplejson
libcombine
libsedml
pyomexmeta
pyyaml
evalidate
];
doCheck = false;
};
# https://github.com/yaroslaff/evalidate
evalidate = py.buildPythonPackage rec {
pname = "evalidate";
version = "2.0.3";
format = "pyproject";
src = final.fetchFromGitHub {
owner = "yaroslaff";
repo = "evalidate";
rev = "v${version}";
hash = "sha256-0SdGjsddX/iYeXpB9AdD7hnBH8raGHvSZ7D30a3sRXE=";
};
nativeBuildInputs = with py; [
hatchling
];
propagatedBuildInputs = with py; [
uritools
];
};
pkg_utils = py.buildPythonPackage rec {
pname = "pkg_utils";
version = "0.0.5";
src = final.fetchFromGitHub {
owner = "KarrLab";
repo = "pkg_utils";
rev = "${version}";
hash = "sha256-u6t4z1MoEkgoPkZtJuTYUbL5HyrkYthSPu9bhm8IZwo=";
};
nativeBuildInputs = with py; [
pip
];
propagatedBuildInputs = with py; [
glob2
requirements-parser
configparser
];
};
pronto = py.buildPythonPackage rec {
pname = "pronto";
version = "2.7.0";
src = final.fetchFromGitHub {
owner = "althonos";
repo = "pronto";
rev = "v${version}";
hash = "sha256-e+Nf+0kOH8d8KU2U9imxfeP1AjY2g/oZwZmQG394cts=";
};
nativeBuildInputs = with py; [
setuptools
];
buildInputs = with py; [
python-dateutil
];
format = "pyproject";
};
kisao = py.buildPythonPackage rec {
pname = "kisao";
version = "2.34";
src = final.fetchFromGitHub {
owner = "SED-ML";
repo = "Kisao";
rev = "${version}";
hash = "sha256-ozL1G9ylRhQL+lUCLwb2LSjooF5P8AgiWRMOWrBrDl8=";
};
prePatch = ''
cd libkisao/python
'';
nativeBuildInputs = with py; [
pip
];
propagatedBuildInputs = with py; [
pkg_utils
termcolor
pronto
python-dateutil
networkx
fastobo
chardet
];
};
fastobo = py.buildPythonPackage rec {
pname = "fastobo";
version = "0.13.0";
src = final.fetchFromGitHub {
owner = "fastobo";
repo = "fastobo-py";
rev = "v${version}";
hash = "sha256-8v9KjYX6Fy/ALFlYfSXpW40p0z54F5tpr10TAWenizk=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";
hash = "sha256-USh7WK18I8A4VdGsUAnbrSiJuBYyq4539MlyS5ANSGo=";
};
format = "pyproject";
nativeBuildInputs = [
rustPlatform.cargoSetupHook
(rustPlatform.maturinBuildHook.override {
pkgsHostTarget = {
inherit (rust-new final.pkgsHostTarget) cargo rustc;
inherit (final.pkgsHostTarget) maturin;
};
})
];
};
bezier = py.buildPythonPackage rec {
pname = "bezier";
version = "2020.2.3";
src = final.fetchFromGitHub {
owner = "dhermes";
repo = "bezier";
rev = "${version}";
hash = "sha256-yuq2+Yy9XO2KwLlsB0IxjseG/axNBa5KuxBZ2J22ruE=";
};
BEZIER_NO_EXTENSION="1";
nativeBuildInputs = with py; [
pip
];
buildInputs = with py; [
pytest
matplotlib
seaborn
scipy
];
propagatedBuildInputs = with py; [
numpy
sympy
];
};
smoldyn-py = py.buildPythonPackage {
pname = "smoldyn";
version = smoldyn.version;
src = smoldyn.py;
postPatch = ''
sed -e '37,38d' -i setup.py
'';
propagatedBuildInputs = with py; [
biosimulator_util
biosimulator_simularium
simulariumio
numpy
pandas
h5py
openpyxl
pyvista
];
};
}