nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchpatch,
5 fetchFromGitHub,
6 rocmUpdateScript,
7 cmake,
8 rocm-cmake,
9 gfortran,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "hipfort";
14 version = "7.1.1";
15
16 src = fetchFromGitHub {
17 owner = "ROCm";
18 repo = "hipfort";
19 rev = "rocm-${finalAttrs.version}";
20 hash = "sha256-IVLhp8rYtKhkt8K8Mc0qyrp670oKoK0QeclnJjO36pY=";
21 };
22
23 patches = [
24 (fetchpatch {
25 name = "hipfort-fix-cmake-4.patch";
26 url = "https://github.com/ROCm/hipfort/commit/75552c7ec48e3bd6a914c57c9475ec573ccb37d9.patch";
27 hash = "sha256-S9r1V6cUo9QbKbu/NK4wIvXMV6BFv7+/n9mjCScVk40=";
28 includes = [ "bin/*" ];
29 })
30 ];
31
32 nativeBuildInputs = [
33 cmake
34 rocm-cmake
35 gfortran
36 ];
37
38 cmakeFlags = [
39 "-DHIPFORT_COMPILER=${gfortran}/bin/gfortran"
40 "-DHIPFORT_AR=${gfortran.cc}/bin/gcc-ar"
41 "-DHIPFORT_RANLIB=${gfortran.cc}/bin/gcc-ranlib"
42 # Manually define CMAKE_INSTALL_<DIR>
43 # See: https://github.com/NixOS/nixpkgs/pull/197838
44 "-DCMAKE_INSTALL_BINDIR=bin"
45 "-DCMAKE_INSTALL_LIBDIR=lib"
46 "-DCMAKE_INSTALL_INCLUDEDIR=include"
47 ];
48
49 postPatch = ''
50 patchShebangs bin
51
52 substituteInPlace bin/hipfc bin/mymcpu \
53 --replace "/bin/cat" "cat"
54
55 substituteInPlace bin/CMakeLists.txt \
56 --replace "/bin/mkdir" "mkdir" \
57 --replace "/bin/cp" "cp" \
58 --replace "/bin/sed" "sed" \
59 --replace "/bin/chmod" "chmod" \
60 --replace "/bin/ln" "ln"
61 '';
62
63 passthru.updateScript = rocmUpdateScript {
64 name = finalAttrs.pname;
65 inherit (finalAttrs.src) owner;
66 inherit (finalAttrs.src) repo;
67 };
68
69 meta = {
70 description = "Fortran interfaces for ROCm libraries";
71 homepage = "https://github.com/ROCm/hipfort";
72 license = with lib.licenses; [ mit ]; # mitx11
73 teams = [ lib.teams.rocm ];
74 platforms = lib.platforms.linux;
75 };
76})