Skip to content

Nix #4

@idontgetoutmuch

Description

@idontgetoutmuch

With a lot of help, I managed to get this to build using nix: https://nixos.org. It built for me on macOS using

nix-build --pure sundialsTest.nix -I nixpkgs=https://github.com/nixos/nixpkgs-channels/archive/nixos-unstable-small.tar.gz

I hope to get round to making it part of nixpkgs but just in case I don't, I am leaving the derivation here:

{ pkgs ? import <nixpkgs>
  { overlays = [(self: super: {



sundials = super.sundials.overrideAttrs (o: rec {

    configureFlags = "--enable-shared";
    version = "2.7.0";

    # override sundials version because SBML_odeSolver is unhappy with
    # > 2.7.0
    src = pkgs.fetchurl {
      url = "https://computation.llnl.gov/projects/${o.pname}/download/${o.pname}-${version}.tar.gz";
      sha256 = "01513g0j7nr3rh7hqjld6mw0mcx5j9z9y87bwjc16w2x2z3wm7yk";
    };
});


})]; }}:

with pkgs;

let

  libSBML = stdenv.mkDerivation rec {
  src = pkgs.fetchurl {
    url = https://sourceforge.net/projects/sbml/files/libsbml/5.17.0/stable/libSBML-5.17.0-core-src.tar.gz;
    sha256 = "153l67jb1q888y91kb439bwy6d3vsz4aqgpbcqhskmg842bx4axb";
  };
  version = "5.17.0";
  name = "libSBML-${version}";
  buildInputs = [ libxml2 ];
  NIX_CFLAGS_COMPILE = "-I${libxml2.dev}/include/libxml2";

  # these files are refering to /bin/pwd which does not exist in a nix
  # context
  patchPhase = ''
    sed -i 's/\/bin\/pwd/pwd/' config/makefile-common-vars.mk.in
    sed -i 's/\/bin\/pwd/pwd/' src/bindings/matlab/Makefile.in
    sed -i 's/\/bin\/pwd/pwd/' src/bindings/matlab/test/Makefile.in
  '';
};

in

{
  SBML_odeSolver = stdenv.mkDerivation rec {
    src = pkgs.fetchgit {
      url = git://github.com/raim/SBML_odeSolver;
      rev = "0a1aa2becadceb95b2d61a9fdafa9c3cc620748f";
      sha256 = "0mp7nik6hxifxkic8c6pi6kqnnd5vv9s2h06n1z0f8prg6cfg1ly";
    };
    version = "1.9.0.1";
    name = "SBML_odeSolver-${version}";
    buildInputs = [ sundials libSBML pkgconfig autoreconfHook libxml2 ];

    configureFlags = ["--with-libsbml=${libSBML}"
                      "--with-sundials=${sundials}"];
    doCheck = false;

    # fprintf takes a const char * as first argument, or a format
    # string
    patchPhase = ''
      sed -i 's/fprintf(stderr, errors);/fprintf(stderr, "%s", errors);/' examples/ChangingParameterIntegrator.c
      '';

  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions