mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-09 22:45:08 +00:00
e0464e4788
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" ```
50 lines
1.6 KiB
Nix
50 lines
1.6 KiB
Nix
{ lib, stdenv, fetchurl, cmake, hdf5 }:
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "medfile";
|
|
version = "5.0.0";
|
|
|
|
src = fetchurl {
|
|
url = "https://files.salome-platform.org/Salome/medfile/med-${finalAttrs.version}.tar.bz2";
|
|
hash = "sha256-Jn520MZ+xRwQ4xmUhOwVCLqo1e2EXGKK32YFKdzno9Q=";
|
|
};
|
|
|
|
outputs = [ "out" "doc" "dev" ];
|
|
|
|
postPatch = ''
|
|
# Patch cmake and source files to work with hdf5
|
|
substituteInPlace config/cmake_files/medMacros.cmake --replace-fail \
|
|
"IF (NOT HDF_VERSION_MAJOR_REF EQUAL 1 OR NOT HDF_VERSION_MINOR_REF EQUAL 12 OR NOT HDF_VERSION_RELEASE_REF GREATER 0)" \
|
|
"IF (HDF5_VERSION VERSION_LESS 1.12.0)"
|
|
substituteInPlace src/*/*.c --replace-warn \
|
|
"#if H5_VERS_MINOR > 12" \
|
|
"#if H5_VERS_MINOR > 14"
|
|
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
# Some medfile test files #define _a, which
|
|
# breaks system header files that use _a as a function parameter
|
|
substituteInPlace tests/c/*.c \
|
|
--replace-warn "_a" "_A" \
|
|
--replace-warn "_b" "_B"
|
|
# Fix compiler errors in test files
|
|
substituteInPlace tests/c/*.c \
|
|
--replace-warn "med_Bool" "med_bool" \
|
|
--replace-warn "med_Axis_type" "med_axis_type" \
|
|
--replace-warn "med_Access_mode" "med_access_mode"
|
|
'';
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
buildInputs = [ hdf5 ];
|
|
|
|
checkPhase = "make test";
|
|
|
|
postInstall = "rm -r $out/bin/testc";
|
|
|
|
meta = with lib; {
|
|
description = "Library to read and write MED files";
|
|
homepage = "https://salome-platform.org/";
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
license = licenses.lgpl3Plus;
|
|
};
|
|
})
|