about summary refs log tree commit diff
path: root/pkgs/development/libraries/pmix/default.nix
blob: 486164904b2bba3d93c30aa88d81f9d4c409c875 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
  lib,
  stdenv,
  fetchFromGitHub,
  perl,
  autoconf,
  automake,
  removeReferencesTo,
  libtool,
  python3,
  flex,
  libevent,
  targetPackages,
  makeWrapper,
  hwloc,
  munge,
  zlib,
  pandoc,
  gitMinimal,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "pmix";
  version = "5.0.3";

  src = fetchFromGitHub {
    repo = "openpmix";
    owner = "openpmix";
    rev = "v${finalAttrs.version}";
    hash = "sha256-5qBZj4L0Qu/RvNj8meL0OlLCdfGvBP0D916Mr+0XOCQ=";
    fetchSubmodules = true;
  };

  outputs = [ "out" ] ++ lib.optionals stdenv.hostPlatform.isLinux [ "dev" ];

  postPatch = ''
    patchShebangs ./autogen.pl
    patchShebangs ./config
  '';

  nativeBuildInputs = [
    pandoc
    perl
    autoconf
    automake
    libtool
    flex
    gitMinimal
    python3
    removeReferencesTo
    makeWrapper
  ];

  buildInputs = [
    libevent
    hwloc
    munge
    zlib
  ];

  configureFlags = [
    "--with-libevent=${lib.getDev libevent}"
    "--with-libevent-libdir=${lib.getLib libevent}/lib"
    "--with-munge=${munge}"
    "--with-hwloc=${lib.getDev hwloc}"
    "--with-hwloc-libdir=${lib.getLib hwloc}/lib"
  ];

  preConfigure = ''
    ./autogen.pl
  '';

  postInstall =
    ''
      find $out/lib/ -name "*.la" -exec rm -f \{} \;

      moveToOutput "bin/pmix_info" "''${!outputDev}"
      moveToOutput "bin/pmixcc" "''${!outputDev}"
      moveToOutput "share/pmix/pmixcc-wrapper-data.txt" "''${!outputDev}"

    ''
    # From some reason the Darwin build doesn't include this file, so we
    # currently disable this substitution for any non-Linux platform, until a
    # Darwin user will care enough about this cross platform fix.
    + lib.optionalString stdenv.hostPlatform.isLinux ''
      # Pin the compiler to the current version in a cross compiler friendly way.
      # Same pattern as for openmpi (see https://github.com/NixOS/nixpkgs/pull/58964#discussion_r275059427).
      substituteInPlace "''${!outputDev}"/share/pmix/pmixcc-wrapper-data.txt \
        --replace-fail compiler=gcc \
          compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc
    '';

  postFixup = lib.optionalString (lib.elem "dev" finalAttrs.outputs) ''
    # The build info (parameters to ./configure) are hardcoded
    # into the library. This clears all references to $dev/include.
    remove-references-to -t "''${!outputDev}" $(readlink -f $out/lib/libpmix.so)

    # The path to the pmixcc-wrapper-data.txt is hard coded and
    # points to $out instead of dev. Use wrapper to fix paths.
    wrapProgram "''${!outputDev}"/bin/pmixcc \
      --set PMIX_INCLUDEDIR "''${!outputDev}"/include \
      --set PMIX_PKGDATADIR "''${!outputDev}"/share/pmix
  '';

  enableParallelBuilding = true;

  meta = {
    description = "Process Management Interface for HPC environments";
    homepage = "https://openpmix.github.io/";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [
      markuskowa
      doronbehar
    ];
  };
})