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