about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/molecular-dynamics/raspa/default.nix
blob: 149db0504bf1faea6b657808f4df123401c04860 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, makeWrapper
, fftw
, lapack
, openblas
, runCommandLocal
, raspa
, raspa-data
}:
stdenv.mkDerivation rec {
  pname = "raspa";
  version = "2.0.47";

  src = fetchFromGitHub {
    owner = "iRASPA";
    repo = "RASPA2";
    rev = "v${version}";
    hash = "sha256-i8Y+pejiOuyPNJto+/0CmRoAnMljCrnDFx8qDh4I/68=";
  };

  nativeBuildInputs = [
    autoreconfHook
    makeWrapper
  ];

  buildInputs = [
    fftw
    lapack
    openblas
  ];

  # Prepare for the Python binding packaging.
  strictDeps = true;

  enableParallelBuilding = true;

  preAutoreconf = ''
    mkdir "m4"
  '';

  postAutoreconf = ''
    automake --add-missing
    autoconf
  '';

  doCheck = true;

  # Wrap with RASPA_DIR
  # so that users can run $out/bin/simulate directly
  # without the need of a `run` srcipt.
  postInstall = ''
    wrapProgram "$out/bin/simulate" \
      --set RASPA_DIR "$out"
  '';

  passthru.tests.run-an-example = runCommandLocal "raspa-test-run-an-example" { }
    ''
      set -eu -o pipefail
      exampleDir="${raspa-data}/share/raspa/examples/Basic/1_MC_Methane_in_Box"
      exampleDirWritable="$(basename "$exampleDir")"
      cp -rT "$exampleDir" "./$exampleDirWritable"
      chmod u+rw -R "$exampleDirWritable"
      cd "$exampleDirWritable"
      ${raspa}/bin/simulate
      touch "$out"
    '';

  meta = with lib; {
    description = "A general purpose classical molecular simulation package";
    homepage = "https://iraspa.org/raspa/";
    license = licenses.mit;
    platforms = platforms.all;
    maintainers = with maintainers; [ ShamrockLee ];
    mainProgram = "simulate";
  };
}