nixpkgs/pkgs/by-name/sp/spfft/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

76 lines
1.6 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, fftw
, cmake
, mpi
, gfortran
, llvmPackages
, cudaPackages
, rocmPackages
, config
, gpuBackend ? (
if config.cudaSupport
then "cuda"
else if config.rocmSupport
then "rocm"
else "none"
)
}:
assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ];
stdenv.mkDerivation rec {
pname = "SpFFT";
version = "1.1.0";
src = fetchFromGitHub {
owner = "eth-cscs";
repo = pname;
rev = "v${version}";
hash = "sha256-hZdB/QcjL8rjvR1YZS+CHe5U5zxedpfDq6msMih4Elc=";
};
nativeBuildInputs = [
cmake
gfortran
] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cuda_nvcc;
buildInputs = [
fftw
mpi
] ++ lib.optionals (gpuBackend == "cuda") [
cudaPackages.libcufft
cudaPackages.cuda_cudart
] ++ lib.optionals (gpuBackend == "rocm") [
rocmPackages.clr
rocmPackages.rocfft
rocmPackages.hipfft
] ++ lib.optional stdenv.hostPlatform.isDarwin llvmPackages.openmp
;
cmakeFlags = [
"-DSPFFT_OMP=ON"
"-DSPFFT_MPI=ON"
"-DSPFFT_SINGLE_PRECISION=OFF"
"-DSPFFT_FORTRAN=ON"
# Required due to broken CMake files
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
]
++ lib.optional (gpuBackend == "cuda") "-DSPFFT_GPU_BACKEND=CUDA"
++ lib.optionals (gpuBackend == "rocm") [
"-DSPFFT_GPU_BACKEND=ROCM"
"-DHIP_ROOT_DIR=${rocmPackages.clr}"
];
meta = with lib; {
description = "Sparse 3D FFT library with MPI, OpenMP, CUDA and ROCm support";
homepage = "https://github.com/eth-cscs/SpFFT";
license = licenses.bsd3;
maintainers = [ maintainers.sheepforce ];
platforms = platforms.linux;
};
}