1{ lib, stdenv, fetchFromGitHub, perl, autoconf, automake
2, removeReferencesTo, libtool, python3, flex, libevent
3, targetPackages, makeWrapper
4, hwloc, munge, zlib, pandoc, gitMinimal
5} :
6
7stdenv.mkDerivation rec {
8 pname = "pmix";
9 version = "5.0.3";
10
11 src = fetchFromGitHub {
12 repo = "openpmix";
13 owner = "openpmix";
14 rev = "v${version}";
15 hash = "sha256-5qBZj4L0Qu/RvNj8meL0OlLCdfGvBP0D916Mr+0XOCQ=";
16 fetchSubmodules = true;
17 };
18
19 outputs = [ "out" "dev" ];
20
21 postPatch = ''
22 patchShebangs ./autogen.pl
23 patchShebangs ./config
24 '';
25
26 nativeBuildInputs = [
27 pandoc
28 perl
29 autoconf
30 automake
31 libtool
32 flex
33 gitMinimal
34 python3
35 removeReferencesTo
36 makeWrapper
37 ];
38
39 buildInputs = [ libevent hwloc munge zlib ];
40
41 configureFlags = [
42 "--with-libevent=${lib.getDev libevent}"
43 "--with-libevent-libdir=${lib.getLib libevent}/lib"
44 "--with-munge=${munge}"
45 "--with-hwloc=${lib.getDev hwloc}"
46 "--with-hwloc-libdir=${lib.getLib hwloc}/lib"
47 ];
48
49 preConfigure = ''
50 ./autogen.pl
51 '';
52
53 postInstall = ''
54 find $out/lib/ -name "*.la" -exec rm -f \{} \;
55
56 moveToOutput "bin/pmix_info" "''${!outputDev}"
57 moveToOutput "bin/pmixcc" "''${!outputDev}"
58 moveToOutput "share/pmix/pmixcc-wrapper-data.txt" "''${!outputDev}"
59
60 # The path to the pmixcc-wrapper-data.txt is hard coded and
61 # points to $out instead of dev. Use wrapper to fix paths.
62 wrapProgram $dev/bin/pmixcc \
63 --set PMIX_INCLUDEDIR $dev/include \
64 --set PMIX_PKGDATADIR $dev/share/pmix
65 '';
66
67 postFixup = ''
68 # The build info (parameters to ./configure) are hardcoded
69 # into the library. This clears all references to $dev/include.
70 remove-references-to -t $dev $(readlink -f $out/lib/libpmix.so)
71
72 # Pin the compiler to the current version in a cross compiler friendly way.
73 # Same pattern as for openmpi (see https://github.com/NixOS/nixpkgs/pull/58964#discussion_r275059427).
74 sed -i 's:compiler=.*:compiler=${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc:' \
75 $dev/share/pmix/pmixcc-wrapper-data.txt
76 '';
77
78 enableParallelBuilding = true;
79
80 meta = with lib; {
81 description = "Process Management Interface for HPC environments";
82 homepage = "https://openpmix.github.io/";
83 license = licenses.bsd3;
84 maintainers = [ maintainers.markuskowa ];
85 platforms = platforms.linux;
86 };
87}
88