nixpkgs/pkgs/by-name/fe/febio/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

73 lines
1.6 KiB
Nix

{
lib,
stdenv,
overrideSDK,
fetchFromGitHub,
fetchpatch2,
substituteAll,
cmake,
ninja,
zlib,
darwin,
mklSupport ? true,
mkl,
}:
let
stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
pname = "FEBio";
version = "4.7";
src = fetchFromGitHub {
owner = "febiosoftware";
repo = "FEBio";
rev = "v${finalAttrs.version}";
hash = "sha256-RRdIOyXg4jYW76ABfJdMfVtCYMLYFdvyOI98nHXCof8=";
};
patches = [
# Fix library searching and installation
(substituteAll {
src = ./fix-cmake.patch;
so = stdenv.hostPlatform.extensions.sharedLibrary;
})
# Fixed missing header include for strcpy
# https://github.com/febiosoftware/FEBio/pull/92
(fetchpatch2 {
url = "https://github.com/febiosoftware/FEBio/commit/ad9e80e2aa8737828855458a703822f578db2fd3.patch?full_index=1";
hash = "sha256-/uLnJB/oAwLQnsZtJnUlaAEpyZVLG6o2riRwwMCH8rI=";
})
];
cmakeFlags = lib.optionals mklSupport [
(lib.cmakeBool "USE_MKL" true)
(lib.cmakeFeature "MKLROOT" "${mkl}")
];
nativeBuildInputs = [
cmake
ninja
];
buildInputs =
[ zlib ]
++ lib.optionals mklSupport [ mkl ]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.CoreGraphics
darwin.apple_sdk.frameworks.CoreVideo
darwin.apple_sdk.frameworks.Accelerate
];
meta = {
description = "FEBio Suite Solver";
license = with lib.licenses; [ mit ];
homepage = "https://febio.org/";
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ Scriptkiddi ];
};
})